From 638f562817a81a513704a888035c78be48cabe70 Mon Sep 17 00:00:00 2001 From: sunnycarter <36891339+sunnycarter@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:06:54 +0100 Subject: [PATCH] Add aosm extension (#6426) * removed deploy with sdk * added artifact list * push example cnf bicep * Add temporary build workflow for AOSM extension (#4) * Add temporary build workflow for AOSM extension * Add Releaser to maintain a release with the latest build in a consistent place * added output dir; fixing getchartmappingschema * Add empty init files to inner modules so setuptools recognises them as modules * Use latest RG model to remove unnecessary dependency on version * Use latest deployment model to remove unnecessary dependency on version * fixed parameter mappings + copied needed files to output folder * jinja2 and find value paths * fixed typos + self.aritfacts only has unique artifacts * use regex instead of string to find deploy params * delete accidentaly commited input.json * fixed deploy params; added indent to mapping file * Update readme with install/bug reporting instructions * Adjust headers so rendered readme looks nicer * renamed values.nondef + added cli errors * Split help command example lines * Clarify that bug process is internal * fixed parameter vals not updating * delete unuseed temoplate and update jinja2 templates * Update README.md * Update README.md * added docstrings; added basic error catching with file handling * small refactor of generate nfd * fixed j2 template captions; added create_nfd to cnf; edited error messages; added deleting existing folder to custom.py * fixed file not found erroe * Refactor commands to az aosm nfd|nsd build (#10) * Refactor commands to az aosm nfd|nsd build * setup.py version * Version was wrong * remove publish option from build * lint * wrong params * fixed most style errors; ran static checks and azdev style * pre merge commit * more style changes; renamed vnfbicepnfd to vnfnfd * Update readme with workflow * added configfile validation * added temp dir to vnf; renamed shared constants * sunny markups * removed create_nfd_folder; added schema prefix to constant * added deploymentparams to constants.py * added error catching for get chart name and version * added meaningful logs; prevent auto overwriting input.json * edited vnf schema to have accepted types * added templates to setup.py * added location from input file not resourceGroup().location * added path_to_mappings to input.json; added logic to take mappings from file outside of helm package * renamed non_def_values to mappings_path * Pk5/add nsd cli (#15) * First working version of the CLI NSD create * Fully working version of the NSD CLI * minor change to nsd_generate * Sunny's refactor * First round of cleanup * Secound Round of cleanup * fix the 2023 api NSDV * description updates * deleted comment * Fix SNS creation * Fix SNS creation try 2 * markups * delete unnecessary file * Testing markups * Fix the SNS attempt 3 * minor fixes * Fix config validation * fix CNF depends on * initial commit; ran python static checks fmt (except on vendored sdks), fixed styling on _configuration.py * Name uploaded VHD correctly * Self review markups * broken config generation code * fixed up configuration.py * fixed cnf generator styling * fixed styling for cnf generator * fixed up nfd generator base and deploy with arm * fixed styling for artifact.py * fixed styling for atrifact manifest .py * Code review markups * fixed more linting * first attempt at regex * Sunny/choose deploy parameters (#23) * choose-deploy-parameters * optioned deployParameters for CNF * lint * lint2 * docs * docs * lint * 9.82 score * Fix bugs * more useful debug logs * Fix bugs and logging * lint * markups * Fix for oras target string with erroneous spaces * fixed regex; tested on existing charts and sas charts; committing to not lose prints for testing * changed regex constants + tidied * fixed blankspace * markups * initial commit * tidied code and added comments * add multi nf config * Add style and lint check * added logic for handling deployparams within lists * one line fix from review * removing print statement * added new test file and one unit test * added workflow for unit tests in pipeline + set up rough structure of unit testing * instantiated cnf class; added fake invalid helm package; added new files to use for testing * Nsd for cnfs (#33) * NSD building for CNFs * linting * Add Publish command to the CNF azure CLI (#24) * Working publish * Fix the artifact upload * Working image copy * minor fix * Minor fixes * sunny merge add-aosm-extension into patryk's branch (#25) * Sunny/choose deploy parameters (#23) * choose-deploy-parameters * optioned deployParameters for CNF * lint * lint2 * docs * docs * lint * 9.82 score * Fix bugs * more useful debug logs * Fix bugs and logging * lint * markups * comment out breaking line * minor TODOs * deleted comment * fix bring your own parameters * Markups * Fix the helm upload * Minor markups * Change error message --------- Co-authored-by: sunnycarter <36891339+sunnycarter@users.noreply.github.com> Co-authored-by: Sunny Carter * Expose NFD version and managed identities (#34) * NFDV version exposed as a CGV on an SNS * Managed identities support on NFs * Fix identiy, fix API versions * history --------- Co-authored-by: Jamie Parsons Co-authored-by: Sunny Carter * Add a first VNF test * achurchard/style fixes (#35) Fix style issues raised by `azdev style` * Add CNF UTs that will fail at the moment * Actually include all files. * Always run tests * Add another test that won't pass yet * remove github pipeline tests - they should run in Azure * Sundry fixes for CNF quickstart (#38) * Sundry fixes for CNF quickstart * merge add-aosm-ext in (#37) * markups * NSD UTs * Update read me. * Improve path handling, other small refactorings (#39) # Main changes ## Make methods relying on self._tmp_dir private - `self._tmp_dir` is only available in the context of calling `generate_nfd()`, so methods relying on `self._tmp_dir` should be private ## Use pathlib.Path rather than os file operations - Provides clearer and stronger typing than passing `str`s around - Adds some handy utility functions ## Variable renaming for clarity - E.g. consistently use 'directory' / 'dir' (rather than mix with 'folder') - Obvs somewhat subjective, but as someone new to most of this code, the changes made sense to me ## Add nfd_bicep_path as abstract property on NFDGenerator - We rely on it when calling the concrete implementations - Also use ABC rather than raise NotImplementedError ## Miscellaneous style updates to keep `azdev style aosm` happy - isort - black * Fix Artifact upload on Windows (#40) * Black * Mark ups * Sunny/fix artifact upload windows (#41) * Fix Artifact upload on Windows * mypy fixups * mypy fixes * linting * mypy * mypy for _configuration.py * mypy for vnf_nfd_generator.py * mypy appeasement * python-static-checks fmt * az style happy * lint * mypy cnf_nfd_generator * copyright * more lint * Remove windows oras workaround now 0.0.18 oras out * history --------- Co-authored-by: Jamie Parsons * Fix VNFD build (#42) * Multiple instances of the same NF * fix vnf deploy schema types (#44) * Tidy up * Mypy and docs * history.rst * Update README with logging info (#43) * Update README with logging info * Update docs * self markups * Take oras 0.1.19 to fix Windows artifact upload (#46) * Rename a few things * DRY the deploy_nfd_from_bicep code * Make conditional statements clearer * black * Update custom.py to use new nfd deploy method * Black with text processing * Create new nfRET class * Mypy passing * UTs passing * Dry the deploy_nfd_from_bicep() code (#48) - Removed duplicated code in the deploy_vnfd_from_bicep() and deploy_cnfd_from_bicep() methods - Moved variables onto the class instance and stopped passing them around in the method signatures - Also made the deployer class a dataclass for cleaner __init__ - Made parameters a property of the class, and moved the logic for getting/generating them into that property method - Improved the typing - Included adding enums for SkipSteps and DeployableResourceTypes - Added the new skip step logic for image uploads - Added a new skip step type of IMAGE_UPLOAD Testing: - No MyPy errors - Live tests for VNFS+NSD, CNFs, including all --skip options * Unit tests added * Versions are wrong in NSD template comments * Self review markups * Remove wrong comments * Code review markups * Extra markups * Fix mypy * Pk5/add integration tests (#51) * Somewhat working example * Cleanups * Update recording * fix minor linting error * More markups * Update output in tests * Pk5/minor integration tests changes (#52) * Modify changelog and rename tests * Delete recording file * Update recordings * Update developer docs * Remove credentials * Fix linting * cheeky extra change * Remove credentials from the integration test recordings (#54) * Modify changelog and rename tests * Delete recording file * Fix the credentials issue in the integration tests * Update CHANGELOG * Markups * Fix typo * Minor markups * Make cleaning up resources more robust and remove the VHD external reference * Markups * Remove the integration test from the repo (#56) * prerequisite docker for cnf * Fix bicep render on Windows (#57) * Fixes for Windows (#58) * Fix bicep render on Windows * Fixes for Windows * python-static-checks ran * ADO-880627: Use docker-less ACR login For running in environments without docker, such as CI pipelines. This affects uploading Helm charts for CNFs - the ACR login now fetches an access token, which is used to login to the Helm registry and upload the chart. * docker is not required any more * Remove pre-release build and lint files from release branch (#63) * Release markups - release branch (#65) * Markups from release comments * history * markups and fixes * README changes * linting fixes * Fix integration tests (#67) * Fix integration tests * Update src/aosm/development.md Co-authored-by: Cyclam <95434717+Cyclam@users.noreply.github.com> * Update src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py Co-authored-by: Cyclam <95434717+Cyclam@users.noreply.github.com> * Update src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py Co-authored-by: Cyclam <95434717+Cyclam@users.noreply.github.com> * Markup changes --------- Co-authored-by: Cyclam <95434717+Cyclam@users.noreply.github.com> Co-authored-by: Sunny Carter * Add aosm to service_name.json * move artifact upload to before nfd/nsd deploy (#62) * move artifact upload to before nfd/nsd deploy * markups * check in new test recording * non-working attempt to use token creds * Check for Azure features on deploy and delete (#71) * WIP: Check for features on deploy and delete * linting * Anand has confirmed names of flags * Update test recording as now has calls to Features API * Update src/aosm/azext_aosm/custom.py Co-authored-by: jamiedparsons <111778988+jamiedparsons@users.noreply.github.com> * docstring markups --------- Co-authored-by: jamiedparsons <111778988+jamiedparsons@users.noreply.github.com> * code working * Fix generate-config * Fix tests * lint * linting * Jl/nfdv proxy (#73) * added publisher scope to input file; changed to proxy nsdv * fixed get request on proxy nfdv (should be overwritten when autogenerated again) * small print bug fix --------- Co-authored-by: Jordan * Code review mark ups * Linting and fix UTs * aosm codeowner * Update HISTORY.rst * Normalise aosm version to 1.0.0b1 for release * update hashes in recording * Temporary test revert of "aosm codeowner" This reverts commit 479ba54e5e861d26166ba982cff6fbd05cf9fafe. * Fix license header formatting * Revert "Temporary test revert of "aosm codeowner"" This reverts commit 0e4d0e7f988c7b0ce7081251396a53117848599e. * Remove nonexistent entry from codeowners * Fix source_local_docker_image defaults to placeholder text (#79) * temp fix for bug * minor formatting * refactor + change validation ordering to mimic previous behaviour * add docstring --------- Co-authored-by: Jordan * renamed nsdg to nsd * Helptext + a little bit of validation * Fixed up validation * Return True if _all_ required artifact manifests exist, not just the last one checked. * Code markups + linting. * Docs: CNF publish options and permissions (#91) * Requirement for docker again * revert bad markup (#94) * Move live tests to swedensouth * Actually move to uaenorth * Don't log out ACR passwords when artifact commands fail (#97) * Don't log out passwords when artifact commands fail * Don't log out passwords when artifact commands fail part 2 * Comment to explain dropping the original exception * Fix cnf image take 2 (#101) * Fix CNF image copy to work cross subscription * Cross subscription works for image copy. Still test same subscription * lint * Error message * oops, code paste error * markups * appease mypy * Default RG and ACR Values with Publisher Name (#103) * added default rg and acr values for nf + nsd; added blob_url default for vnf * added bug fix to close Paulo's bug * change error message back --------- Co-authored-by: Jordan * Fix unauthorized error bug * Add spacing * fix unexpected symbol when parsing lists (#107) * Validation requirements on helm names (#109) * Validation requirements on helm names * lint * markups * lint * Fix error parsing * Lower case acr names (#112) * Lower case ACR names and fix interactive mode for lists * lint * remove duplicate else branch * always allow azureDeployLocation to be configurable * Add new optional VHD parameters * Make VNF publish and delete a live test only * Validate VHD parameters in build UT * Markups from the CLI team * mark-ups * remove azureDeployLocation as a configurable vhd parameter * add explanitory comments * Updates for 2023-09-01 API (#84) * Regen Python SDK from 2023-09-01 API - also uses latest AutoRest client - fix for HybridNetworkManagementClient init signature (swap order of subscription_id and credential parameters) * Update CLI extension code to use new SDK * added SAMI to publisher pre deploy * Update bicep templates to use 2023-09-01 * Update NF templates * Update metaschema * Add Allow-Publisher to required feature flags * Use secure objects for deployment parameters * Correctly get array item types in CNF deployment parameter schemas * Revert master .flake8 config * Fix double space in user output. Co-authored-by: Xing Zhou * Remove delete message to be consistent with other CLI extensions * Move "Deleted " messages to logger.info(). * Remove Blob_SAS_URL Option from ArmTemplate in input file (#119) * moved blob url to vhd config only; untested * stopped error in post innit before validate * changed ordering of inputs so that blob and filepath are next to each other; helptext for filepath different for each option * Markups from sunny * appease mypy --------- Co-authored-by: Jordan Co-authored-by: Sunny Carter --------- Co-authored-by: Jordan Co-authored-by: Jacob Darby Co-authored-by: Chaos Co-authored-by: Chaos Chhapi Co-authored-by: jordlay <72226943+jordlay@users.noreply.github.com> Co-authored-by: patrykkulik-microsoft <116072282+patrykkulik-microsoft@users.noreply.github.com> Co-authored-by: Jacob <53872686+jddarby@users.noreply.github.com> Co-authored-by: Jamie Parsons Co-authored-by: jamiedparsons <111778988+jamiedparsons@users.noreply.github.com> Co-authored-by: Andy Churchard Co-authored-by: Cyclam <95434717+Cyclam@users.noreply.github.com> Co-authored-by: William Bradley Co-authored-by: Xing Zhou --- .flake8 | 1 + .github/CODEOWNERS | 2 + src/aosm/HISTORY.rst | 10 + src/aosm/README.md | 203 + src/aosm/azext_aosm/__init__.py | 30 + src/aosm/azext_aosm/_client_factory.py | 42 + src/aosm/azext_aosm/_configuration.py | 771 + src/aosm/azext_aosm/_help.py | 85 + src/aosm/azext_aosm/_params.py | 156 + src/aosm/azext_aosm/_validators.py | 22 + src/aosm/azext_aosm/azext_metadata.json | 4 + src/aosm/azext_aosm/commands.py | 26 + src/aosm/azext_aosm/custom.py | 525 + src/aosm/azext_aosm/delete/__init__.py | 5 + src/aosm/azext_aosm/delete/delete.py | 330 + src/aosm/azext_aosm/deploy/__init__.py | 5 + src/aosm/azext_aosm/deploy/artifact.py | 644 + .../azext_aosm/deploy/artifact_manifest.py | 169 + src/aosm/azext_aosm/deploy/deploy_with_arm.py | 731 + src/aosm/azext_aosm/deploy/pre_deploy.py | 444 + src/aosm/azext_aosm/generate_nfd/__init__.py | 5 + .../generate_nfd/cnf_nfd_generator.py | 850 + .../generate_nfd/nfd_generator_base.py | 25 + .../templates/cnfartifactmanifest.bicep.j2 | 39 + .../templates/cnfdefinition.bicep.j2 | 79 + .../templates/vnfartifactmanifests.bicep | 68 + .../templates/vnfdefinition.bicep | 103 + .../generate_nfd/vnf_nfd_generator.py | 340 + src/aosm/azext_aosm/generate_nsd/__init__.py | 5 + src/aosm/azext_aosm/generate_nsd/nf_ret.py | 185 + .../azext_aosm/generate_nsd/nsd_generator.py | 261 + .../artifact_manifest_template.bicep | 39 + .../templates/nf_template.bicep.j2 | 81 + .../templates/nsd_template.bicep.j2 | 108 + src/aosm/azext_aosm/tests/__init__.py | 5 + src/aosm/azext_aosm/tests/latest/__init__.py | 5 + .../azext_aosm/tests/latest/metaschema.json | 420 + .../tests/latest/metaschema_modified.json | 416 + .../helm-charts/nf-agent-cnf-0.1.0.tgz | Bin 0 -> 5234 bytes .../helm-charts/nf-agent-cnf/.helmignore | 23 + .../helm-charts/nf-agent-cnf/Chart.yaml | 24 + .../nf-agent-cnf/templates/NOTES.txt | 22 + .../nf-agent-cnf/templates/_helpers.tpl | 62 + .../nf-agent-cnf/templates/deployment.yaml | 71 + .../nf-agent-cnf/templates/hpa.yaml | 28 + .../nf-agent-cnf/templates/ingress.yaml | 61 + .../templates/nf-agent-config-map.yaml | 27 + .../nf-agent-cnf/templates/service.yaml | 15 + .../templates/serviceaccount.yaml | 12 + .../templates/tests/test-connection.yaml | 15 + .../nf-agent-cnf/values.mappings.yaml | 89 + .../nf-agent-cnf/values.schema.json | 193 + .../helm-charts/nf-agent-cnf/values.yaml | 92 + .../helm-charts/nfconfigchart-0.1.0.tgz | Bin 0 -> 4630 bytes .../helm-charts/nfconfigchart/.helmignore | 22 + .../helm-charts/nfconfigchart/Chart.yaml | 6 + .../nfconfigchart/configmap/default.conf | 38 + .../nfconfigchartvalues.mappings.yaml | 69 + .../nfconfigchart/templates/NOTES.txt | 21 + .../nfconfigchart/templates/_helpers.tpl | 56 + .../nfconfigchart/templates/deployment.yaml | 68 + .../nfconfigchart/templates/ingress.yaml | 41 + .../templates/nginx_config_map.yaml | 56 + .../nfconfigchart/templates/service.yaml | 16 + .../templates/serviceaccount.yaml | 8 + .../templates/tests/test-connection.yaml | 15 + .../nfconfigchart/values.schema.json | 134 + .../helm-charts/nfconfigchart/values.yaml | 70 + .../latest/mock_cnf/input-nf-agent-cnf.json | 19 + .../latest/mock_cnf/input-nfconfigchart.json | 21 + .../tests/latest/mock_cnf/invalid_chart.yaml | 0 .../latest/mock_cnf/invalid_config_file.json | 16 + .../latest/mock_cnf/invalid_mappings.yaml | 0 .../tests/latest/mock_cnf/valid_chart.tgz | 0 .../tests/latest/mock_nsd/input.json | 20 + .../latest/mock_nsd/input_multi_nf_nsd.json | 29 + .../mock_nsd/input_multiple_instances.json | 20 + .../tests/latest/mock_vnf/input_with_fp.json | 18 + .../tests/latest/mock_vnf/input_with_sas.json | 21 + .../latest/mock_vnf/ubuntu-template.json | 118 + .../test_build/artifact_manifest.bicep | 39 + .../ubuntu-vm-nfdg_config_mapping.json | 9 + .../test_build/nsd_definition.bicep | 106 + .../schemas/ubuntu_ConfigGroupSchema.json | 45 + .../test_build/ubuntu-vm-nfdg_nf.bicep | 72 + .../artifact_manifest.bicep | 39 + .../ubuntu-vm-nfdg_config_mapping.json | 7 + .../nsd_definition.bicep | 106 + .../schemas/ubuntu_ConfigGroupSchema.json | 48 + .../ubuntu-vm-nfdg_nf.bicep | 72 + .../artifact_manifest.bicep | 39 + .../nginx-nfdg_config_mapping.json | 10 + .../ubuntu-nfdg_config_mapping.json | 9 + .../nginx-nfdg_nf.bicep | 74 + .../nsd_definition.bicep | 131 + .../schemas/multinf_ConfigGroupSchema.json | 75 + .../ubuntu-nfdg_nf.bicep | 72 + .../tests/latest/recording_processors.py | 87 + .../test_vnf_nsd_publish_and_delete.yaml | 8781 ++++++++++ .../cnf_mocks/nginxdemo-0.1.0.tgz | Bin 0 -> 4509 bytes .../cnf_input_template.json | 20 + .../cnf_nsd_input_template.json | 20 + .../mock_input_templates/nsd_input.json | 20 + .../mock_input_templates/vnf_input.json | 18 + .../vnf_input_template.json | 18 + .../vnf_nsd_input_template.json | 20 + .../scenario_test_mocks/vnf_mocks/ubuntu.vhd | 11 + .../vnf_mocks/ubuntu_template.json | 118 + .../test_aosm_cnf_publish_and_delete.py | 116 + .../tests/latest/test_aosm_scenario.py | 39 + .../test_aosm_vnf_publish_and_delete.py | 116 + src/aosm/azext_aosm/tests/latest/test_cnf.py | 67 + src/aosm/azext_aosm/tests/latest/test_nsd.py | 393 + src/aosm/azext_aosm/tests/latest/test_vnf.py | 89 + src/aosm/azext_aosm/util/__init__.py | 5 + src/aosm/azext_aosm/util/constants.py | 124 + .../azext_aosm/util/management_clients.py | 22 + src/aosm/azext_aosm/util/utils.py | 25 + src/aosm/azext_aosm/vendored_sdks/__init__.py | 23 + src/aosm/azext_aosm/vendored_sdks/_client.py | 177 + .../vendored_sdks/_configuration.py | 68 + src/aosm/azext_aosm/vendored_sdks/_patch.py | 31 + .../vendored_sdks/_serialization.py | 2008 +++ .../azext_aosm/vendored_sdks/aio/__init__.py | 23 + .../azext_aosm/vendored_sdks/aio/_client.py | 177 + .../vendored_sdks/aio/_configuration.py | 68 + .../azext_aosm/vendored_sdks/aio/_patch.py | 31 + .../vendored_sdks/aio/operations/__init__.py | 47 + .../aio/operations/_operations.py | 10435 ++++++++++++ .../vendored_sdks/aio/operations/_patch.py | 20 + .../vendored_sdks/models/__init__.py | 335 + .../azext_aosm/vendored_sdks/models/_enums.py | 302 + .../vendored_sdks/models/_models.py | 6325 ++++++++ .../azext_aosm/vendored_sdks/models/_patch.py | 20 + .../vendored_sdks/operations/__init__.py | 47 + .../vendored_sdks/operations/_operations.py | 13313 ++++++++++++++++ .../vendored_sdks/operations/_patch.py | 20 + src/aosm/azext_aosm/vendored_sdks/py.typed | 1 + src/aosm/pyproject.toml | 7 + src/aosm/setup.cfg | 2 + src/aosm/setup.py | 60 + src/service_name.json | 5 + 142 files changed, 53482 insertions(+) create mode 100644 src/aosm/HISTORY.rst create mode 100644 src/aosm/README.md create mode 100644 src/aosm/azext_aosm/__init__.py create mode 100644 src/aosm/azext_aosm/_client_factory.py create mode 100644 src/aosm/azext_aosm/_configuration.py create mode 100644 src/aosm/azext_aosm/_help.py create mode 100644 src/aosm/azext_aosm/_params.py create mode 100644 src/aosm/azext_aosm/_validators.py create mode 100644 src/aosm/azext_aosm/azext_metadata.json create mode 100644 src/aosm/azext_aosm/commands.py create mode 100644 src/aosm/azext_aosm/custom.py create mode 100644 src/aosm/azext_aosm/delete/__init__.py create mode 100644 src/aosm/azext_aosm/delete/delete.py create mode 100644 src/aosm/azext_aosm/deploy/__init__.py create mode 100644 src/aosm/azext_aosm/deploy/artifact.py create mode 100644 src/aosm/azext_aosm/deploy/artifact_manifest.py create mode 100644 src/aosm/azext_aosm/deploy/deploy_with_arm.py create mode 100644 src/aosm/azext_aosm/deploy/pre_deploy.py create mode 100644 src/aosm/azext_aosm/generate_nfd/__init__.py create mode 100644 src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py create mode 100644 src/aosm/azext_aosm/generate_nfd/nfd_generator_base.py create mode 100644 src/aosm/azext_aosm/generate_nfd/templates/cnfartifactmanifest.bicep.j2 create mode 100644 src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 create mode 100644 src/aosm/azext_aosm/generate_nfd/templates/vnfartifactmanifests.bicep create mode 100644 src/aosm/azext_aosm/generate_nfd/templates/vnfdefinition.bicep create mode 100644 src/aosm/azext_aosm/generate_nfd/vnf_nfd_generator.py create mode 100644 src/aosm/azext_aosm/generate_nsd/__init__.py create mode 100644 src/aosm/azext_aosm/generate_nsd/nf_ret.py create mode 100644 src/aosm/azext_aosm/generate_nsd/nsd_generator.py create mode 100644 src/aosm/azext_aosm/generate_nsd/templates/artifact_manifest_template.bicep create mode 100644 src/aosm/azext_aosm/generate_nsd/templates/nf_template.bicep.j2 create mode 100644 src/aosm/azext_aosm/generate_nsd/templates/nsd_template.bicep.j2 create mode 100644 src/aosm/azext_aosm/tests/__init__.py create mode 100644 src/aosm/azext_aosm/tests/latest/__init__.py create mode 100644 src/aosm/azext_aosm/tests/latest/metaschema.json create mode 100644 src/aosm/azext_aosm/tests/latest/metaschema_modified.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf-0.1.0.tgz create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/.helmignore create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/Chart.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/NOTES.txt create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/_helpers.tpl create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/deployment.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/hpa.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/ingress.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/nf-agent-config-map.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/service.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/serviceaccount.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/tests/test-connection.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.mappings.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.schema.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart-0.1.0.tgz create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/.helmignore create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/Chart.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/configmap/default.conf create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/nfconfigchartvalues.mappings.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/NOTES.txt create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/_helpers.tpl create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/deployment.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/ingress.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/nginx_config_map.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/service.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/serviceaccount.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/tests/test-connection.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.schema.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/input-nf-agent-cnf.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/input-nfconfigchart.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_chart.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_config_file.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_mappings.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/mock_cnf/valid_chart.tgz create mode 100644 src/aosm/azext_aosm/tests/latest/mock_nsd/input.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_nsd/input_multi_nf_nsd.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_nsd/input_multiple_instances.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json create mode 100644 src/aosm/azext_aosm/tests/latest/mock_vnf/ubuntu-template.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build/artifact_manifest.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build/configMappings/ubuntu-vm-nfdg_config_mapping.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build/nsd_definition.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build/schemas/ubuntu_ConfigGroupSchema.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build/ubuntu-vm-nfdg_nf.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/artifact_manifest.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/configMappings/ubuntu-vm-nfdg_config_mapping.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/nsd_definition.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/schemas/ubuntu_ConfigGroupSchema.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/ubuntu-vm-nfdg_nf.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/artifact_manifest.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/nginx-nfdg_config_mapping.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/ubuntu-nfdg_config_mapping.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nginx-nfdg_nf.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nsd_definition.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/schemas/multinf_ConfigGroupSchema.json create mode 100644 src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/ubuntu-nfdg_nf.bicep create mode 100644 src/aosm/azext_aosm/tests/latest/recording_processors.py create mode 100644 src/aosm/azext_aosm/tests/latest/recordings/test_vnf_nsd_publish_and_delete.yaml create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/cnf_mocks/nginxdemo-0.1.0.tgz create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_input_template.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_nsd_input_template.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/nsd_input.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input_template.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_nsd_input_template.json create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu.vhd create mode 100644 src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu_template.json create mode 100644 src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py create mode 100644 src/aosm/azext_aosm/tests/latest/test_aosm_scenario.py create mode 100644 src/aosm/azext_aosm/tests/latest/test_aosm_vnf_publish_and_delete.py create mode 100644 src/aosm/azext_aosm/tests/latest/test_cnf.py create mode 100644 src/aosm/azext_aosm/tests/latest/test_nsd.py create mode 100644 src/aosm/azext_aosm/tests/latest/test_vnf.py create mode 100644 src/aosm/azext_aosm/util/__init__.py create mode 100644 src/aosm/azext_aosm/util/constants.py create mode 100644 src/aosm/azext_aosm/util/management_clients.py create mode 100644 src/aosm/azext_aosm/util/utils.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/__init__.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/_client.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/_configuration.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/_patch.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/_serialization.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/__init__.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/_client.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/_configuration.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/_patch.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/operations/__init__.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/operations/_operations.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/aio/operations/_patch.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/models/__init__.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/models/_enums.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/models/_models.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/models/_patch.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/operations/__init__.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/operations/_operations.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/operations/_patch.py create mode 100644 src/aosm/azext_aosm/vendored_sdks/py.typed create mode 100644 src/aosm/pyproject.toml create mode 100644 src/aosm/setup.cfg create mode 100644 src/aosm/setup.py diff --git a/.flake8 b/.flake8 index 5d2b0466e0e..be946cee0b0 100644 --- a/.flake8 +++ b/.flake8 @@ -9,6 +9,7 @@ ignore = C901 # code flow is too complex, too many violations, to be removed in the future W503 # line break before binary operator effect on readability is subjective W504 # line break after binary operator effect on readability is subjective + exclude = */vendored_sdks docs diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 02d3d5ca18d..9bc3f546ded 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -292,6 +292,8 @@ /src/alb/ @jaishals +/src/aosm/ @sunnycarter + /src/managedccfs/ @msftsettiy /src/acrquery/ @CarolineNB diff --git a/src/aosm/HISTORY.rst b/src/aosm/HISTORY.rst new file mode 100644 index 00000000000..ddf8903557b --- /dev/null +++ b/src/aosm/HISTORY.rst @@ -0,0 +1,10 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++++ +* Initial release - beta quality + * `az aosm nfd|nsd generate-config` to generate an example config file to fill in for an NFD or NSD + * `az aosm nfd|nsd build|publish|delete` to prepare files for, publish or delete an NFD or NSD diff --git a/src/aosm/README.md b/src/aosm/README.md new file mode 100644 index 00000000000..ac1b4c62b03 --- /dev/null +++ b/src/aosm/README.md @@ -0,0 +1,203 @@ +# Microsoft Azure CLI 'aosm' Extension + +This package is for the 'aosm' extension to support Azure Operator Service Manager +functions. +i.e. `az aosm` + +## Background + +The `az aosm` extension is intended to provide support for working with AOSM +resources and definitions. Currently it only implements commands which aid the +process of publishing Network Function Definitions and Network Service Designs to +use with Azure Operator Service Manager or Network Function Manager. + +## Installation + +`az extension add --name aosm` + +For CNFs you will also need helm, and possibly docker installed. See [CNFs](#cnfs) below for details. + +# nfd and nsd commands + +These commands help with the publishing of Network Function Definition and Network +Service Design resources. + +## Overview of function +A generic workflow of using the tool would be: +- Find the pre-requisite items you require for your use-case +- Run a `generate-config` command to output an example JSON config file for subsequent commands +- Fill in the config file +- Run a `build` command to output one or more bicep templates for your Network Function Definition or Network Service Design +- Review the output of the build command, edit the output as necessary for your requirements +- Run a `publish` command to: + * Create all pre-requisite resources such as Resource Group, Publisher, Artifact Stores, Groups + * Deploy those bicep templates + * Upload artifacts to the artifact stores + +### Pre-requisites + +#### VNFs + +For VNFs, you will need a single ARM template which would create the Azure resources +for your VNF, for example a Virtual Machine, disks and NICs. You'll also need a VHD +image that would be used for the VNF Virtual Machine. + +#### CNFs + +For CNFs you must have these packages installed on the machine you are running the CLI from: +- `helm` package installed . Instructions on how to do this can be found [here](https://helm.sh/docs/intro/install/). +- `docker` installed only in some circumstances, those being if the source image is in your local docker repository, or you do not have subscription-wide permissions required to push charts and images. See the remainder of this section for further details. Docker provides packages that easily configure docker on [Windows](https://docs.docker.com/docker-for-windows/), or [Linux](https://docs.docker.com/engine/install/#supported-platforms) systems. + +For CNFs, you must provide: +* helm packages with an associated schema. These files must be on your disk and will be referenced in the `input.json` config file. +* images for your CNF. For these you have the following options: + - a reference to an existing Azure Container Registry which contains the images for your CNF. Currently, only one ACR and namespace is supported per CNF. The images to be copied from this ACR are populated automatically based on the helm package schema. You must have Reader/AcrPull permissions on this ACR. To use this option, fill in `source_registry` and optionally `source_registry_namespace` in the input.json file. + - or, the image name of the source docker image from local machine. This is for a limited use case where the CNF only requires a single docker image which exists in the local docker repository. To use this option, fill in `source_local_docker_image` in the input.json file. This requires docker to be installed. +* optionally, you can provide a file (on disk) path_to_mappings which is a copy of values.yaml with your chosen values replaced by deployment parameters, thus exposing them as parameters to the CNF. You can get this file auto-generated by leaving the value as a blank string, either having every value as a deployment parameter, or using `--interactive` to interactively choose. +When filling in the input.json file, you must list helm packages in the order they are to be deployed. For example, if A must be deployed before B, your input.json should look something like this: + + "helm_packages": [ + { + "name": "A", + "path_to_chart": "Path to package A", + "path_to_mappings": "Path to package A mappings", + "depends_on": [ + "Names of the Helm packages this package depends on" + ] + }, + { + "name": "B", + "path_to_chart": "Path to package B", + "path_to_mappings": "Path to package B mappings", + "depends_on": [ + "Names of the Helm packages this package depends on" + ] + }, + +##### Permissions for publishing CNFs +If sourcing the CNF images from an existing ACR, you need to have `Reader`/`AcrPull` permissions +from this ACR, and ideally, `Contributor` role + `AcrPush` role (or a custom role that allows the `importImage` action and `AcrPush`) over the whole subscription in order to be able to import to the new Artifact store. If you have these, you +do not need docker to be installed locally, and the image copy is very quick. + +If you do not have the subscription-wide permissions then you can run the `az aosm nfd publish` command using the `--no-subscription-permissions` flag to pull the image to your local machine and then push it to the Artifact Store using manifest credentials scoped only to the store. This requires docker to be installed locally. + +#### NSDs +For NSDs, you will need to have a Resource Group with a deployed Publisher, Artifact Store, Network Function Definition and Network Function Definition Version. You can use the `az aosm nfd` commands to create all of these resources. + + +### Command examples + +#### Before you start +`az login` to login to the Azure CLI. +`az account set --subscription ` to choose the subscription you will work on. + +#### NFDs + +Get help on command arguments + +`az aosm -h` +`az aosm nfd -h` +`az aosm nfd build -h` +etc... + +All these commands take a `--definition-type` argument of `vnf` or `cnf` + +Create an example config file for building a definition + +`az aosm nfd generate-config` + +This will output a file called `input.json` which must be filled in. +Once the config file has been filled in the following commands can be run. + +Build an nfd definition locally + +`az aosm nfd build --config-file input.json` + +More options on building an nfd definition locally: + +Choose which of the VNF ARM template parameters you want to expose as NFD deploymentParameters, with the option of interactively choosing each one. + +`az aosm nfd build --config-file input.json --definition_type vnf --order_params` +`az aosm nfd build --config-file input.json --definition_type vnf --order_params --interactive` + +Choose which of the CNF Helm values parameters you want to expose as NFD deploymentParameters. + +`az aosm nfd build --config-file input.json --definition_type cnf [--interactive]` + +Publish a pre-built definition + +`az aosm nfd publish --config-file input.json` + +Delete a published definition + +`az aosm nfd delete --config-file input.json` + +Delete a published definition and the publisher, artifact stores and NFD group + +`az aosm nfd delete --config-file input.json --clean` + +#### NSDs + +Get help on command arguments + +`az aosm -h` +`az aosm nsd -h` +`az aosm nsd build -h` +etc... + +Create an example config file for building a definition + +`az aosm nsd generate-config` + +This will output a file called `input.json` which must be filled in. +Once the config file has been filled in the following commands can be run. + +Build an nsd locally + +`az aosm nsd build --config-file input.json` + +Publish a pre-built design + +`az aosm nsd publish --config-file input.json` + +Delete a published design + +`az aosm nsd delete --config-file input.json` + +Delete a published design and the publisher, artifact stores and NSD group + +`az aosm nsd delete --config-file input.json --clean` + +## Bug Reporting + +It would be much appreciated if you could report these so that we're aware of them! + +Please see [Logging](#logging) for how to view and collect logs. + +Please describe what you are doing and if possible provide the input and output files. + +The (Microsoft internal) process for bug reporting during development is here: +https://eng.ms/docs/strategic-missions-and-technologies/strategic-missions-and-technologies-organization/azure-for-operators/aiops/aiops-orchestration/aosm-product-docs/processes/bug_process + +CLI issues should be tagged and triaged as UX bugs. + +## Logging + +The CLI uses the standard Azure CLI logging mechanism. To enable logging to the console, you can use the following flags depending on the desired level of logging: +- `--verbose` - This flag changes the logging level to Info and above. +- `--debug` - This flag changes the logging level to Debug and above. +- `--only-show-errors` - This flag changes the logging level to Error only, suppressing Warning. + +It is also possible to enable logging to file by running the following command: +``` +az config set logging.enable_log_file=true +``` +This will create a log file in the `~/.azure/logs` directory. + +**Note:** The above command will enable logging for all Azure CLI commands until the logging is disabled again by the user. Not disabling file logging could slow down the performance of the CLI. To disable file logging, run the following command: +``` +az config set logging.enable_log_file=false +``` + +## Development +Information about setting up and maintaining a development environment for this extension can be found [here](./development.md). diff --git a/src/aosm/azext_aosm/__init__.py b/src/aosm/azext_aosm/__init__.py new file mode 100644 index 00000000000..c15badcb435 --- /dev/null +++ b/src/aosm/azext_aosm/__init__.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader + +from azext_aosm._help import helps # pylint: disable=unused-import + + +class AosmCommandsLoader(AzCommandsLoader): + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + + aosm_custom = CliCommandType(operations_tmpl="azext_aosm.custom#{}") + super().__init__(cli_ctx=cli_ctx, custom_command_type=aosm_custom) + + def load_command_table(self, args): + from azext_aosm.commands import load_command_table + + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_aosm._params import load_arguments + + load_arguments(self, command) + + +COMMAND_LOADER_CLS = AosmCommandsLoader diff --git a/src/aosm/azext_aosm/_client_factory.py b/src/aosm/azext_aosm/_client_factory.py new file mode 100644 index 00000000000..ea716a48b2b --- /dev/null +++ b/src/aosm/azext_aosm/_client_factory.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core.commands.client_factory import get_mgmt_service_client +from azure.cli.core.profiles import ResourceType +from azure.mgmt.containerregistry import ContainerRegistryManagementClient + +from .vendored_sdks import HybridNetworkManagementClient + + +def cf_aosm(cli_ctx, *_) -> HybridNetworkManagementClient: + # By default, get_mgmt_service_client() sets a parameter called 'base_url' when creating + # the client. For us, doing so results in a key error. Setting base_url_bound=False prevents + # that from happening + return get_mgmt_service_client(cli_ctx, HybridNetworkManagementClient, base_url_bound=False) + + +def cf_resources(cli_ctx, subscription_id=None): + return get_mgmt_service_client( + cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, subscription_id=subscription_id + ) + + +def cf_features(cli_ctx, subscription_id=None): + """Return the client for checking feature enablement.""" + return get_mgmt_service_client( + cli_ctx, ResourceType.MGMT_RESOURCE_FEATURES, subscription_id=subscription_id + ) + + +def cf_acr_registries(cli_ctx, *_) -> ContainerRegistryManagementClient: + """ + Returns the client for managing container registries. + + :param cli_ctx: CLI context + :return: ContainerRegistryManagementClient object + """ + return get_mgmt_service_client( + cli_ctx, ResourceType.MGMT_CONTAINERREGISTRY + ).registries diff --git a/src/aosm/azext_aosm/_configuration.py b/src/aosm/azext_aosm/_configuration.py new file mode 100644 index 00000000000..4ae8132166f --- /dev/null +++ b/src/aosm/azext_aosm/_configuration.py @@ -0,0 +1,771 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Configuration class for input config file parsing,""" +import abc +import logging +import json +import os +from dataclasses import dataclass, field, asdict +from pathlib import Path +from typing import Any, Dict, List, Optional, Union + +from azure.cli.core.azclierror import ( + InvalidArgumentValueError, + ValidationError, +) +from azext_aosm.util.constants import ( + CNF, + NF_DEFINITION_OUTPUT_BICEP_PREFIX, + NF_DEFINITION_JSON_FILENAME, + NSD, + NSD_OUTPUT_BICEP_PREFIX, + VNF, +) + +logger = logging.getLogger(__name__) + + +@dataclass +class ArtifactConfig: + # artifact.py checks for the presence of the default descriptions, change + # there if you change the descriptions. + artifact_name: str = "" + version: Optional[str] = "" + file_path: Optional[str] = None + + @classmethod + def helptext(cls) -> "ArtifactConfig": + """ + Build an object where each value is helptext for that field. + """ + return ArtifactConfig( + artifact_name="Optional. Name of the artifact.", + version="Version of the artifact in A.B.C format.", + file_path=( + "File path of the artifact you wish to upload from your local disk. " + "Relative paths are relative to the configuration file. " + "On Windows escape any backslash with another backslash." + ), + + ) + + def validate(self): + """ + Validate the configuration. + """ + if not self.version: + raise ValidationError("version must be set.") + if not self.file_path: + raise ValidationError("file_path must be set.") + + +@dataclass +class VhdArtifactConfig(ArtifactConfig): + # If you add a new property to this class, consider updating EXTRA_VHD_PARAMETERS in + # constants.py - see comment there for details. + blob_sas_url: Optional[str] = None + image_disk_size_GB: Optional[Union[str, int]] = None + image_hyper_v_generation: Optional[str] = None + image_api_version: Optional[str] = None + + def __post_init__(self): + """ + Convert parameters to the correct types. + """ + if ( + isinstance(self.image_disk_size_GB, str) + and self.image_disk_size_GB.isdigit() + ): + self.image_disk_size_GB = int(self.image_disk_size_GB) + + @classmethod + def helptext(cls) -> "VhdArtifactConfig": + """ + Build an object where each value is helptext for that field. + """ + + artifact_config = ArtifactConfig.helptext() + artifact_config.file_path = ( + "Optional. File path of the artifact you wish to upload from your local disk. " + "Delete if not required. Relative paths are relative to the configuration file." + "On Windows escape any backslash with another backslash." + ) + artifact_config.version = ( + "Version of the artifact in A-B-C format." + ) + return VhdArtifactConfig( + blob_sas_url=( + "Optional. SAS URL of the blob artifact you wish to copy to your Artifact" + " Store. Delete if not required." + ), + image_disk_size_GB=( + "Optional. Specifies the size of empty data disks in gigabytes. " + "This value cannot be larger than 1023 GB. Delete if not required." + ), + image_hyper_v_generation=( + "Optional. Specifies the HyperVGenerationType of the VirtualMachine " + "created from the image. Valid values are V1 and V2. V1 is the default if " + "not specified. Delete if not required." + ), + image_api_version=( + "Optional. The ARM API version used to create the " + "Microsoft.Compute/images resource. Delete if not required." + ), + **asdict(artifact_config), + ) + + def validate(self): + """ + Validate the configuration. + """ + if not self.version: + raise ValidationError("version must be set for vhd.") + if self.blob_sas_url and self.file_path: + raise ValidationError("Only one of file_path or blob_sas_url may be set for vhd.") + if not (self.blob_sas_url or self.file_path): + raise ValidationError("One of file_path or sas_blob_url must be set for vhd.") + + +@dataclass +class Configuration(abc.ABC): + config_file: Optional[str] = None + publisher_name: str = "" + publisher_resource_group_name: str = "" + acr_artifact_store_name: str = "" + location: str = "" + + def __post_init__(self): + """ + Set defaults for resource group and ACR as the publisher name tagged with -rg or -acr + """ + if self.publisher_name: + if not self.publisher_resource_group_name: + self.publisher_resource_group_name = f"{self.publisher_name}-rg" + if not self.acr_artifact_store_name: + self.acr_artifact_store_name = f"{self.publisher_name}-acr" + + @classmethod + def helptext(cls): + """ + Build an object where each value is helptext for that field. + """ + return Configuration( + publisher_name=( + "Name of the Publisher resource you want your definition published to. " + "Will be created if it does not exist." + ), + publisher_resource_group_name=( + "Optional. Resource group for the Publisher resource. " + "Will be created if it does not exist (with a default name if none is supplied)." + ), + acr_artifact_store_name=( + "Optional. Name of the ACR Artifact Store resource. " + "Will be created if it does not exist (with a default name if none is supplied)." + ), + location="Azure location to use when creating resources.", + ) + + def validate(self): + """ + Validate the configuration. + """ + if not self.location: + raise ValidationError("Location must be set") + if not self.publisher_name: + raise ValidationError("Publisher name must be set") + if not self.publisher_resource_group_name: + raise ValidationError("Publisher resource group name must be set") + if not self.acr_artifact_store_name: + raise ValidationError("ACR Artifact Store name must be set") + + def path_from_cli_dir(self, path: str) -> str: + """ + Convert path from config file to path from current directory. + + We assume that the path supplied in the config file is relative to the + configuration file. That isn't the same as the path relative to where ever the + CLI is being run from. This function fixes that up. + + :param path: The path relative to the config file. + """ + assert self.config_file + + # If no path has been supplied we shouldn't try to update it. + if path == "": + return "" + + # If it is an absolute path then we don't need to monkey around with it. + if os.path.isabs(path): + return path + + config_file_dir = Path(self.config_file).parent + + updated_path = str(config_file_dir / path) + + logger.debug("Updated path: %s", updated_path) + + return updated_path + + @property + def output_directory_for_build(self) -> Path: + """Base class method to ensure subclasses implement this function.""" + raise NotImplementedError("Subclass must define property") + + @property + def acr_manifest_names(self) -> List[str]: + """The list of ACR manifest names.""" + raise NotImplementedError("Subclass must define property") + + +@dataclass +class NFConfiguration(Configuration): + """Network Function configuration.""" + + nf_name: str = "" + version: str = "" + + @classmethod + def helptext(cls) -> "NFConfiguration": + """ + Build an object where each value is helptext for that field. + """ + return NFConfiguration( + nf_name="Name of NF definition", + version="Version of the NF definition in A.B.C format.", + **asdict(Configuration.helptext()), + ) + + def validate(self): + """ + Validate the configuration. + """ + super().validate() + if not self.nf_name: + raise ValidationError("nf_name must be set") + if not self.version: + raise ValidationError("version must be set") + + @property + def nfdg_name(self) -> str: + """Return the NFD Group name from the NFD name.""" + return f"{self.nf_name}-nfdg" + + @property + def acr_manifest_names(self) -> List[str]: + """ + Return the ACR manifest name from the NFD name. + + This is returned in a list for consistency with the NSConfiguration, where there + can be multiple ACR manifests. + """ + sanitized_nf_name = self.nf_name.lower().replace("_", "-") + return [f"{sanitized_nf_name}-acr-manifest-{self.version.replace('.', '-')}"] + + +@dataclass +class VNFConfiguration(NFConfiguration): + blob_artifact_store_name: str = "" + image_name_parameter: str = "" + arm_template: Union[Dict[str, str], ArtifactConfig] = ArtifactConfig() + vhd: Union[Dict[str, str], VhdArtifactConfig] = VhdArtifactConfig() + + @classmethod + def helptext(cls) -> "VNFConfiguration": + """ + Build an object where each value is helptext for that field. + """ + return VNFConfiguration( + blob_artifact_store_name=( + "Optional. Name of the storage account Artifact Store resource. Will be created if it " + "does not exist (with a default name if none is supplied)." + ), + image_name_parameter=( + "The parameter name in the VM ARM template which specifies the name of the " + "image to use for the VM." + ), + arm_template=ArtifactConfig.helptext(), + vhd=VhdArtifactConfig.helptext(), + **asdict(NFConfiguration.helptext()), + ) + + def __post_init__(self): + """ + Cope with deserializing subclasses from dicts to ArtifactConfig. + + Used when creating VNFConfiguration object from a loaded json config file. + """ + super().__post_init__() + if self.publisher_name and not self.blob_artifact_store_name: + self.blob_artifact_store_name = f"{self.publisher_name}-sa" + + if isinstance(self.arm_template, dict): + if self.arm_template.get("file_path"): + self.arm_template["file_path"] = self.path_from_cli_dir( + self.arm_template["file_path"] + ) + self.arm_template = ArtifactConfig(**self.arm_template) + + if isinstance(self.vhd, dict): + if self.vhd.get("file_path"): + self.vhd["file_path"] = self.path_from_cli_dir(self.vhd["file_path"]) + self.vhd = VhdArtifactConfig(**self.vhd) + + def validate(self) -> None: + """ + Validate the configuration passed in. + + :raises ValidationError for any invalid config + """ + super().validate() + + assert isinstance(self.vhd, VhdArtifactConfig) + assert isinstance(self.arm_template, ArtifactConfig) + self.vhd.validate() + self.arm_template.validate() + + assert self.vhd.version + assert self.arm_template.version + + if "." in self.vhd.version or "-" not in self.vhd.version: + raise ValidationError( + "Config validation error. VHD artifact version should be in format" + " A-B-C" + ) + if "." not in self.arm_template.version or "-" in self.arm_template.version: + raise ValidationError( + "Config validation error. ARM template artifact version should be in" + " format A.B.C" + ) + + @property + def sa_manifest_name(self) -> str: + """Return the Storage account manifest name from the NFD name.""" + sanitized_nf_name = self.nf_name.lower().replace("_", "-") + return f"{sanitized_nf_name}-sa-manifest-{self.version.replace('.', '-')}" + + @property + def output_directory_for_build(self) -> Path: + """Return the local folder for generating the bicep template to.""" + assert isinstance(self.arm_template, ArtifactConfig) + assert self.arm_template.file_path + arm_template_name = Path(self.arm_template.file_path).stem + return Path(f"{NF_DEFINITION_OUTPUT_BICEP_PREFIX}{arm_template_name}") + + +@dataclass +class HelmPackageConfig: + name: str = "" + path_to_chart: str = "" + path_to_mappings: str = "" + depends_on: List[str] = field(default_factory=lambda: []) + + @classmethod + def helptext(cls): + """ + Build an object where each value is helptext for that field. + """ + return HelmPackageConfig( + name="Name of the Helm package", + path_to_chart=( + "File path of Helm Chart on local disk. Accepts .tgz, .tar or .tar.gz." + " Use Linux slash (/) file separator even if running on Windows." + ), + path_to_mappings=( + "File path of value mappings on local disk where chosen values are replaced " + "with deploymentParameter placeholders. Accepts .yaml or .yml. If left as a " + "blank string, a value mappings file will be generated with every value " + "mapped to a deployment parameter. Use a blank string and --interactive on " + "the build command to interactively choose which values to map." + ), + depends_on=( + "Names of the Helm packages this package depends on. " + "Leave as an empty array if no dependencies" + ), + ) + + def validate(self): + """ + Validate the configuration. + """ + if not self.name: + raise ValidationError("name must be set") + if not self.path_to_chart: + raise ValidationError("path_to_chart must be set") + + +@dataclass +class CNFImageConfig: + """CNF Image config settings.""" + + source_registry: str = "" + source_registry_namespace: str = "" + source_local_docker_image: str = "" + + def __post_init__(self): + """ + Ensure that all config is lower case. + + ACR names can be uppercase but the login server is always lower case and docker + and az acr import commands require lower case. Might as well do the namespace + and docker image too although much less likely that the user has accidentally + pasted these with upper case. + """ + self.source_registry = self.source_registry.lower() + self.source_registry_namespace = self.source_registry_namespace.lower() + self.source_local_docker_image = self.source_local_docker_image.lower() + + @classmethod + def helptext(cls) -> "CNFImageConfig": + """ + Build an object where each value is helptext for that field. + """ + return CNFImageConfig( + source_registry=( + "Optional. Login server of the source acr registry from which to pull the " + "image(s). For example sourceacr.azurecr.io. Leave blank if you have set " + "source_local_docker_image." + ), + source_registry_namespace=( + "Optional. Namespace of the repository of the source acr registry from which " + "to pull. For example if your repository is samples/prod/nginx then set this to" + " samples/prod . Leave blank if the image is in the root namespace or you have " + "set source_local_docker_image." + "See https://learn.microsoft.com/en-us/azure/container-registry/" + "container-registry-best-practices#repository-namespaces for further details." + ), + source_local_docker_image=( + "Optional. Image name of the source docker image from local machine. For " + "limited use case where the CNF only requires a single docker image and exists " + "in the local docker repository. Set to blank of not required." + ), + ) + + def validate(self): + """ + Validate the configuration. + """ + if self.source_registry_namespace and not self.source_registry: + raise ValidationError( + "Config validation error. The image source registry namespace should " + "only be configured if a source registry is configured." + ) + + if self.source_registry and self.source_local_docker_image: + raise ValidationError( + "Only one of source_registry and source_local_docker_image can be set." + ) + + if not (self.source_registry or self.source_local_docker_image): + raise ValidationError( + "One of source_registry or source_local_docker_image must be set." + ) + + +@dataclass +class CNFConfiguration(NFConfiguration): + images: Union[Dict[str, str], CNFImageConfig] = CNFImageConfig() + helm_packages: List[Union[Dict[str, Any], HelmPackageConfig]] = field( + default_factory=lambda: [] + ) + + def __post_init__(self): + """ + Cope with deserializing subclasses from dicts to HelmPackageConfig. + + Used when creating CNFConfiguration object from a loaded json config file. + """ + super().__post_init__() + for package_index, package in enumerate(self.helm_packages): + if isinstance(package, dict): + package["path_to_chart"] = self.path_from_cli_dir( + package["path_to_chart"] + ) + package["path_to_mappings"] = self.path_from_cli_dir( + package["path_to_mappings"] + ) + self.helm_packages[package_index] = HelmPackageConfig(**dict(package)) + if isinstance(self.images, dict): + self.images = CNFImageConfig(**self.images) + + @classmethod + def helptext(cls) -> "CNFConfiguration": + """ + Build an object where each value is helptext for that field. + """ + return CNFConfiguration( + images=CNFImageConfig.helptext(), + helm_packages=[HelmPackageConfig.helptext()], + **asdict(NFConfiguration.helptext()), + ) + + @property + def output_directory_for_build(self) -> Path: + """Return the directory the build command will writes its output to.""" + return Path(f"{NF_DEFINITION_OUTPUT_BICEP_PREFIX}{self.nf_name}") + + def validate(self): + """ + Validate the CNF config. + + :raises ValidationError: If source registry ID doesn't match the regex + """ + assert isinstance(self.images, CNFImageConfig) + super().validate() + + self.images.validate() + + for helm_package in self.helm_packages: + assert isinstance(helm_package, HelmPackageConfig) + helm_package.validate() + + +@dataclass +class NFDRETConfiguration: # pylint: disable=too-many-instance-attributes + """The configuration required for an NFDV that you want to include in an NSDV.""" + + publisher: str = "" + publisher_resource_group: str = "" + name: str = "" + version: str = "" + publisher_offering_location: str = "" + type: str = "" + multiple_instances: Union[str, bool] = False + + def __post_init__(self): + """ + Convert parameters to the correct types. + """ + # Cope with multiple_instances being supplied as a string, rather than a bool. + if isinstance(self.multiple_instances, str): + if self.multiple_instances.lower() == "true": + self.multiple_instances = True + elif self.multiple_instances.lower() == "false": + self.multiple_instances = False + + @classmethod + def helptext(cls) -> "NFDRETConfiguration": + """ + Build an object where each value is helptext for that field. + """ + return NFDRETConfiguration( + publisher="The name of the existing Network Function Definition Group to deploy using this NSD", + publisher_resource_group="The resource group that the publisher is hosted in.", + name="The name of the existing Network Function Definition Group to deploy using this NSD", + version=( + "The version of the existing Network Function Definition to base this NSD on. " + "This NSD will be able to deploy any NFDV with deployment parameters compatible " + "with this version." + ), + publisher_offering_location="The region that the NFDV is published to.", + type="Type of Network Function. Valid values are 'cnf' or 'vnf'", + multiple_instances=( + "Set to true or false. Whether the NSD should allow arbitrary numbers of this " + "type of NF. If set to false only a single instance will be allowed. Only " + "supported on VNFs, must be set to false on CNFs." + ), + ) + + def validate(self) -> None: + """ + Validate the configuration passed in. + + :raises ValidationError for any invalid config + """ + if not self.name: + raise ValidationError("Network function definition name must be set") + + if not self.publisher: + raise ValidationError(f"Publisher name must be set for {self.name}") + + if not self.publisher_resource_group: + raise ValidationError( + f"Publisher resource group name must be set for {self.name}" + ) + + if not self.version: + raise ValidationError( + f"Network function definition version must be set for {self.name}" + ) + + if not self.publisher_offering_location: + raise ValidationError( + f"Network function definition offering location must be set, for {self.name}" + ) + + if self.type not in [CNF, VNF]: + raise ValueError( + f"Network Function Type must be cnf or vnf for {self.name}" + ) + + if not isinstance(self.multiple_instances, bool): + raise ValueError( + f"multiple_instances must be a boolean for for {self.name}" + ) + + # There is currently a NFM bug that means that multiple copies of the same NF + # cannot be deployed to the same custom location: + # https://portal.microsofticm.com/imp/v3/incidents/details/405078667/home + if self.type == CNF and self.multiple_instances: + raise ValueError("Multiple instances is not supported on CNFs.") + + @property + def build_output_folder_name(self) -> Path: + """Return the local folder for generating the bicep template to.""" + current_working_directory = os.getcwd() + return Path(current_working_directory, NSD_OUTPUT_BICEP_PREFIX) + + @property + def arm_template(self) -> ArtifactConfig: + """Return the parameters of the ARM template for this RET to be uploaded as part of + the NSDV.""" + artifact = ArtifactConfig() + artifact.artifact_name = f"{self.name.lower()}_nf_artifact" + + # We want the ARM template version to match the NSD version, but we don't have + # that information here. + artifact.version = None + artifact.file_path = os.path.join( + self.build_output_folder_name, NF_DEFINITION_JSON_FILENAME + ) + return artifact + + @property + def nf_bicep_filename(self) -> str: + """Return the name of the bicep template for deploying the NFs.""" + return f"{self.name}_nf.bicep" + + @property + def resource_element_name(self) -> str: + """Return the name of the resource element.""" + artifact_name = self.arm_template.artifact_name + return f"{artifact_name}_resource_element" + + def acr_manifest_name(self, nsd_version: str) -> str: + """Return the ACR manifest name from the NFD name.""" + return ( + f"{self.name.lower().replace('_', '-')}" + f"-nf-acr-manifest-{nsd_version.replace('.', '-')}" + ) + + +@dataclass +class NSConfiguration(Configuration): + network_functions: List[Union[NFDRETConfiguration, Dict[str, Any]]] = field( + default_factory=lambda: [] + ) + nsd_name: str = "" + nsd_version: str = "" + nsdv_description: str = "" + + def __post_init__(self): + """Covert things to the correct format.""" + super().__post_init__() + if self.network_functions and isinstance(self.network_functions[0], dict): + nf_ret_list = [ + NFDRETConfiguration(**config) for config in self.network_functions + ] + self.network_functions = nf_ret_list + + @classmethod + def helptext(cls) -> "NSConfiguration": + """ + Build a NSConfiguration object where each value is helptext for that field. + """ + nsd_helptext = NSConfiguration( + network_functions=[asdict(NFDRETConfiguration.helptext())], + nsd_name=( + "Network Service Design (NSD) name. This is the collection of Network Service" + " Design Versions. Will be created if it does not exist." + ), + nsd_version=( + "Version of the NSD to be created. This should be in the format A.B.C" + ), + nsdv_description="Description of the NSDV.", + **asdict(Configuration.helptext()), + ) + + return nsd_helptext + + def validate(self): + """ + Validate the configuration passed in. + + :raises ValueError for any invalid config + """ + super().validate() + if not self.network_functions: + raise ValueError(("At least one network function must be included.")) + + for configuration in self.network_functions: + configuration.validate() + if not self.nsd_name: + raise ValueError("nsd_name must be set") + if not self.nsd_version: + raise ValueError("nsd_version must be set") + + @property + def output_directory_for_build(self) -> Path: + """Return the local folder for generating the bicep template to.""" + current_working_directory = os.getcwd() + return Path(current_working_directory, NSD_OUTPUT_BICEP_PREFIX) + + @property + def nfvi_site_name(self) -> str: + """Return the name of the NFVI used for the NSDV.""" + return f"{self.nsd_name}_NFVI" + + @property + def cg_schema_name(self) -> str: + """Return the name of the Configuration Schema used for the NSDV.""" + return f"{self.nsd_name.replace('-', '_')}_ConfigGroupSchema" + + @property + def acr_manifest_names(self) -> List[str]: + """The list of ACR manifest names for all the NF ARM templates.""" + acr_manifest_names = [] + for nf in self.network_functions: + assert isinstance(nf, NFDRETConfiguration) + acr_manifest_names.append(nf.acr_manifest_name(self.nsd_version)) + + logger.debug("ACR manifest names: %s", acr_manifest_names) + return acr_manifest_names + + +def get_configuration(configuration_type: str, config_file: str) -> Configuration: + """ + Return the correct configuration object based on the type. + + :param configuration_type: The type of configuration to return + :param config_file: The path to the config file + :return: The configuration object + """ + try: + with open(config_file, "r", encoding="utf-8") as f: + config_as_dict = json.loads(f.read()) + except json.decoder.JSONDecodeError as e: + raise InvalidArgumentValueError( + f"Config file {config_file} is not valid JSON: {e}" + ) from e + + config: Configuration + try: + if configuration_type == VNF: + config = VNFConfiguration(config_file=config_file, **config_as_dict) + elif configuration_type == CNF: + config = CNFConfiguration(config_file=config_file, **config_as_dict) + elif configuration_type == NSD: + config = NSConfiguration(config_file=config_file, **config_as_dict) + else: + raise InvalidArgumentValueError( + "Definition type not recognized, options are: vnf, cnf or nsd" + ) + except TypeError as typeerr: + raise InvalidArgumentValueError( + f"Config file {config_file} is not valid: {typeerr}" + ) from typeerr + + config.validate() + + return config diff --git a/src/aosm/azext_aosm/_help.py b/src/aosm/azext_aosm/_help.py new file mode 100644 index 00000000000..64bc5e32940 --- /dev/null +++ b/src/aosm/azext_aosm/_help.py @@ -0,0 +1,85 @@ +# 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. +# -------------------------------------------------------------------------------------------- +from knack.help_files import helps + +helps[ + "aosm" +] = """ + type: group + short-summary: Commands to interact with Azure Operator Service Manager (AOSM). +""" + +helps[ + "aosm nfd" +] = """ + type: group + short-summary: Manage AOSM publisher Network Function Definitions. +""" + +helps[ + "aosm nfd generate-config" +] = """ + type: command + short-summary: Generate configuration file for building an AOSM publisher Network Function Definition. +""" + +helps[ + "aosm nfd build" +] = """ + type: command + short-summary: Build an AOSM Network Function Definition. +""" + +helps[ + "aosm nfd publish" +] = """ + type: command + short-summary: Publish a pre-built AOSM Network Function definition. +""" + + +helps[ + "aosm nfd delete" +] = """ + type: command + short-summary: Delete AOSM Network Function Definition. +""" + +helps[ + "aosm nsd" +] = """ + type: group + short-summary: Manage AOSM publisher Network Service Designs. +""" + +helps[ + "aosm nsd generate-config" +] = """ + type: command + short-summary: Generate configuration file for building an AOSM publisher Network Service Design. +""" + +helps[ + "aosm nsd build" +] = """ + type: command + short-summary: Build an AOSM Network Service Design. +""" + +helps[ + "aosm nsd publish" +] = """ + type: command + short-summary: Publish a pre-built AOSM Network Service Design. +""" + + +helps[ + "aosm nfd delete" +] = """ + type: command + short-summary: Delete AOSM Network Function Definition. +""" diff --git a/src/aosm/azext_aosm/_params.py b/src/aosm/azext_aosm/_params.py new file mode 100644 index 00000000000..7ecb64fce85 --- /dev/null +++ b/src/aosm/azext_aosm/_params.py @@ -0,0 +1,156 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from argcomplete.completers import FilesCompleter +from azure.cli.core import AzCommandsLoader + +from .util.constants import CNF, VNF, BICEP_PUBLISH, ARTIFACT_UPLOAD, IMAGE_UPLOAD + + +def load_arguments(self: AzCommandsLoader, _): + from azure.cli.core.commands.parameters import ( + file_type, + get_enum_type, + get_three_state_flag, + ) + + definition_type = get_enum_type([VNF, CNF]) + nf_skip_steps = get_enum_type([BICEP_PUBLISH, ARTIFACT_UPLOAD, IMAGE_UPLOAD]) + ns_skip_steps = get_enum_type([BICEP_PUBLISH, ARTIFACT_UPLOAD]) + + # Set the argument context so these options are only available when this specific command + # is called. + + with self.argument_context("aosm nfd") as c: + c.argument( + "definition_type", + arg_type=definition_type, + help="Type of AOSM definition.", + required=True, + ) + c.argument( + "config_file", + options_list=["--config-file", "-f"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help="The path to the configuration file.", + ) + c.argument( + "clean", + arg_type=get_three_state_flag(), + help="Also delete artifact stores, NFD Group and Publisher. Use with care.", + ) + c.argument( + "definition_file", + options_list=["--definition-file", "-b"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help=( + "Optional path to a bicep file to publish. Use to override publish of" + " the built definition with an alternative file." + ), + ) + c.argument( + "design_file", + options_list=["--design-file", "-b"], + type=file_type, + completer=FilesCompleter(allowednames="*.bicep"), + help=( + "Optional path to a bicep file to publish. Use to override publish of" + " the built design with an alternative file." + ), + ) + c.argument( + "order_params", + arg_type=get_three_state_flag(), + help=( + "VNF definition_type only - ignored for CNF. Order deploymentParameters" + " schema and configMappings to have the parameters without default" + " values at the top and those with default values at the bottom. Can" + " make it easier to remove those with defaults which you do not want to" + " expose as NFD parameters." + ), + ) + c.argument( + "interactive", + options_list=["--interactive", "-i"], + arg_type=get_three_state_flag(), + help=( + "Prompt user to choose every parameter to expose as an NFD parameter." + " Those without defaults are automatically included." + ), + ) + c.argument( + "parameters_json_file", + options_list=["--parameters-file", "-p"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help=( + "Optional path to a parameters file for the bicep definition file. Use" + " to override publish of the built definition and config with" + " alternative parameters." + ), + ) + c.argument( + "manifest_file", + options_list=["--manifest-file", "-m"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help=( + "Optional path to a bicep file to publish manifests. Use to override" + " publish of the built definition with an alternative file." + ), + ) + c.argument( + "manifest_params_file", + options_list=["--manifest-params-file"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help=( + "Optional path to a parameters file for the manifest definition file." + " Use to override publish of the built definition and config with" + " alternative parameters." + ), + ) + c.argument( + "skip", + arg_type=nf_skip_steps, + help=( + "Optional skip steps. 'bicep-publish' will skip deploying the bicep " + "template; 'artifact-upload' will skip uploading any artifacts; " + "'image-upload' will skip uploading the VHD image (for VNFs) or the " + "container images (for CNFs)." + ), + ) + c.argument( + "no_subscription_permissions", + options_list=["--no-subscription-permissions", "-u"], + arg_type=get_three_state_flag(), + help=( + "CNF definition_type publish only - ignored for VNF." + " Set to True if you do not " + "have permission to import to the Publisher subscription (Contributor " + "role + AcrPush role, or a custom role that allows the importImage " + "action and AcrPush over the " + "whole subscription). This means that the image artifacts will be " + "pulled to your local machine and then pushed to the Artifact Store. " + "Requires Docker to be installed locally." + ), + ) + + with self.argument_context("aosm nsd") as c: + c.argument( + "config_file", + options_list=["--config-file", "-f"], + type=file_type, + completer=FilesCompleter(allowednames="*.json"), + help="The path to the configuration file.", + ) + c.argument("skip", arg_type=ns_skip_steps, help="Optional skip steps") + c.argument( + "clean", + arg_type=get_three_state_flag(), + help="Also delete NSD Group. Use with care.", + ) diff --git a/src/aosm/azext_aosm/_validators.py b/src/aosm/azext_aosm/_validators.py new file mode 100644 index 00000000000..1a9f0e39617 --- /dev/null +++ b/src/aosm/azext_aosm/_validators.py @@ -0,0 +1,22 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + # Example of a storage account name or ID validator. + # See: + # https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace="Microsoft.Storage", + type="storageAccounts", + name=namespace.storage_account, + ) diff --git a/src/aosm/azext_aosm/azext_metadata.json b/src/aosm/azext_aosm/azext_metadata.json new file mode 100644 index 00000000000..be5de02d927 --- /dev/null +++ b/src/aosm/azext_aosm/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.45.0" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/commands.py b/src/aosm/azext_aosm/commands.py new file mode 100644 index 00000000000..abc33f8444b --- /dev/null +++ b/src/aosm/azext_aosm/commands.py @@ -0,0 +1,26 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader + +from azext_aosm._client_factory import cf_aosm + + +def load_command_table(self: AzCommandsLoader, _): + with self.command_group("aosm nfd", client_factory=cf_aosm) as g: + # Add each command and bind it to a function in custom.py + g.custom_command("generate-config", "generate_definition_config") + g.custom_command("build", "build_definition") + g.custom_command("delete", "delete_published_definition") + g.custom_command("publish", "publish_definition") + with self.command_group("aosm nsd", client_factory=cf_aosm) as g: + # Add each command and bind it to a function in custom.py + g.custom_command("generate-config", "generate_design_config") + g.custom_command("build", "build_design") + g.custom_command("delete", "delete_published_design") + g.custom_command("publish", "publish_design") + + with self.command_group("aosm", is_preview=True): + pass diff --git a/src/aosm/azext_aosm/custom.py b/src/aosm/azext_aosm/custom.py new file mode 100644 index 00000000000..008b2210a21 --- /dev/null +++ b/src/aosm/azext_aosm/custom.py @@ -0,0 +1,525 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json +import os +import shutil +from dataclasses import asdict +from pathlib import Path +from typing import Optional + +from azure.cli.core.azclierror import ( + CLIInternalError, + InvalidArgumentValueError, + UnclassifiedUserFault, +) +from azure.cli.core.commands import AzCliCommand +from azure.core import exceptions as azure_exceptions +from knack.log import get_logger + +from azext_aosm._client_factory import cf_features, cf_resources +from azext_aosm._configuration import ( + CNFConfiguration, + Configuration, + NFConfiguration, + NSConfiguration, + VNFConfiguration, + get_configuration, +) +from azext_aosm.delete.delete import ResourceDeleter +from azext_aosm.deploy.deploy_with_arm import DeployerViaArm +from azext_aosm.generate_nfd.cnf_nfd_generator import CnfNfdGenerator +from azext_aosm.generate_nfd.nfd_generator_base import NFDGenerator +from azext_aosm.generate_nfd.vnf_nfd_generator import VnfNfdGenerator +from azext_aosm.generate_nsd.nsd_generator import NSDGenerator +from azext_aosm.util.constants import ( + AOSM_FEATURE_NAMESPACE, + AOSM_REQUIRED_FEATURES, + CNF, + NSD, + VNF, + DeployableResourceTypes, + SkipSteps, +) +from azext_aosm.util.management_clients import ApiClients +from azext_aosm.vendored_sdks import HybridNetworkManagementClient + +logger = get_logger(__name__) + + +def build_definition( + definition_type: str, + config_file: str, + order_params: bool = False, + interactive: bool = False, + force: bool = False, +): + """ + Build a definition. + + :param definition_type: VNF or CNF + :param config_file: path to the file + :param order_params: VNF definition_type only - ignored for CNF. Order + deploymentParameters schema and configMappings to have the parameters without + default values at the top. + :param interactive: Whether to prompt for input when creating deploy parameters + mapping files + :param force: force the build even if the design has already been built + """ + + # Read the config from the given file + config = _get_config_from_file( + config_file=config_file, configuration_type=definition_type + ) + assert isinstance(config, NFConfiguration) + + # Generate the NFD and the artifact manifest. + _generate_nfd( + definition_type=definition_type, + config=config, + order_params=order_params, + interactive=interactive, + force=force, + ) + + +def generate_definition_config(definition_type: str, output_file: str = "input.json"): + """ + Generate an example config file for building a definition. + + :param definition_type: CNF, VNF + :param output_file: path to output config file, defaults to "input.json" + """ + config: Configuration + if definition_type == CNF: + config = CNFConfiguration.helptext() + elif definition_type == VNF: + config = VNFConfiguration.helptext() + else: + raise ValueError("definition_type must be CNF or VNF") + + _generate_config(configuration=config, output_file=output_file) + + +def _get_config_from_file(config_file: str, configuration_type: str) -> Configuration: + """ + Read input config file JSON and turn it into a Configuration object. + + :param config_file: path to the file + :param configuration_type: VNF, CNF or NSD + :returns: The Configuration object + """ + + if not os.path.exists(config_file): + raise InvalidArgumentValueError( + f"Config file {config_file} not found. Please specify a valid config file" + " path." + ) + + config = get_configuration(configuration_type, config_file) + return config + + +def _generate_nfd( + definition_type: str, + config: NFConfiguration, + order_params: bool, + interactive: bool, + force: bool = False, +): + """Generate a Network Function Definition for the given type and config.""" + nfd_generator: NFDGenerator + if definition_type == VNF: + assert isinstance(config, VNFConfiguration) + nfd_generator = VnfNfdGenerator(config, order_params, interactive) + elif definition_type == CNF: + assert isinstance(config, CNFConfiguration) + nfd_generator = CnfNfdGenerator(config, interactive) + else: + raise CLIInternalError( + "Generate NFD called for unrecognised definition_type. Only VNF and CNF" + " have been implemented." + ) + if nfd_generator.nfd_bicep_path: + if not force: + carry_on = input( + f"The {nfd_generator.nfd_bicep_path.parent} directory already exists -" + " delete it and continue? (y/n)" + ) + if carry_on != "y": + raise UnclassifiedUserFault("User aborted!") + + shutil.rmtree(nfd_generator.nfd_bicep_path.parent) + nfd_generator.generate_nfd() + + +def _check_features_enabled(cmd: AzCliCommand): + """ + Check that the required Azure features are enabled on the subscription. + + :param cmd: The AzCLICommand object for the original command that was run, we use + this to retrieve the CLI context in order to get the features client for access + to the features API. + """ + features_client = cf_features(cmd.cli_ctx) + # Check that the required features are enabled on the subscription + for feature in AOSM_REQUIRED_FEATURES: + try: + feature_result = features_client.features.get( + resource_provider_namespace=AOSM_FEATURE_NAMESPACE, + feature_name=feature, + ) + if ( + not feature_result + or not feature_result.properties.state == "Registered" + ): + # We don't want to log the name of the feature to the user as it is + # a hidden feature. We do want to log it to the debug log though. + logger.debug( + "Feature %s is not registered on the subscription.", feature + ) + raise CLIInternalError( + "Your Azure subscription has not been fully onboarded to AOSM. " + "Please see the AOSM onboarding documentation for more information." + ) + except azure_exceptions.ResourceNotFoundError as rerr: + # If the feature is not found, it is not registered, but also something has + # gone wrong with the CLI code and onboarding instructions. + logger.debug( + "Feature not found error - Azure doesn't recognise the feature %s." + "This indicates a coding error or error with the AOSM onboarding " + "instructions.", + feature, + ) + logger.debug(rerr) + raise CLIInternalError( + "CLI encountered an error checking that your " + "subscription has been onboarded to AOSM. Please raise an issue against" + " the CLI." + ) from rerr + + +def publish_definition( + cmd: AzCliCommand, + client: HybridNetworkManagementClient, + definition_type, + config_file, + definition_file: Optional[str] = None, + parameters_json_file: Optional[str] = None, + manifest_file: Optional[str] = None, + manifest_params_file: Optional[str] = None, + skip: Optional[SkipSteps] = None, + no_subscription_permissions: bool = False, +): + """ + Publish a generated definition. + + :param cmd: The AzCLICommand object for the command that was run, we use this to + find the CLI context (from which, for example, subscription id and + credentials can be found, and other clients can be generated.) + :param client: The AOSM client. This is created in _client_factory.py and passed + in by commands.py - we could alternatively just use cf_aosm as + we use cf_resources, but other extensions seem to pass a client + around like this. + :type client: HybridNetworkManagementClient + :param definition_type: VNF or CNF + :param config_file: Path to the config file for the NFDV + :param definition_file: Optional path to a bicep template to deploy, in case the + user wants to edit the built NFDV template. If omitted, the default built NFDV + template will be used. + :param parameters_json_file: Optional path to a parameters file for the bicep file, + in case the user wants to edit the built NFDV template. If omitted, parameters + from config will be turned into parameters for the bicep file + :param manifest_file: Optional path to an override bicep template to deploy + manifests + :param manifest_params_file: Optional path to an override bicep parameters file for + manifest parameters + :param skip: options to skip, either publish bicep or upload artifacts + :param no_subscription_permissions: + CNF definition_type publish only - ignored for VNF. Causes the image + artifact copy from a source ACR to be done via docker pull and push, + rather than `az acr import`. This is slower but does not require + Contributor (or importImage action) and AcrPush permissions on the publisher + subscription. It requires Docker to be installed. + """ + # Check that the required features are enabled on the subscription + _check_features_enabled(cmd) + + print("Publishing definition.") + api_clients = ApiClients( + aosm_client=client, + resource_client=cf_resources(cmd.cli_ctx), + ) + + config = _get_config_from_file( + config_file=config_file, configuration_type=definition_type + ) + + deployer = DeployerViaArm( + api_clients, + resource_type=definition_type, + config=config, + bicep_path=definition_file, + parameters_json_file=parameters_json_file, + manifest_bicep_path=manifest_file, + manifest_params_file=manifest_params_file, + skip=skip, + cli_ctx=cmd.cli_ctx, + use_manifest_permissions=no_subscription_permissions, + ) + deployer.deploy_nfd_from_bicep() + + +def delete_published_definition( + cmd: AzCliCommand, + client: HybridNetworkManagementClient, + definition_type, + config_file, + clean=False, + force=False, +): + """ + Delete a published definition. + + :param cmd: The AzCLICommand object for the command that was run, we use this to + find the CLI context (from which, for example, subscription id and + credentials can be found, and other clients can be generated.) + :param client: The AOSM client. This is created in _client_factory.py and passed + in by commands.py - we could alternatively just use cf_aosm as + we use cf_resources, but other extensions seem to pass a client + around like this. + :param definition_type: CNF or VNF + :param config_file: Path to the config file + :param clean: if True, will delete the NFDG, artifact stores and publisher too. + Defaults to False. Only works if no resources have those as a parent. Use + with care. + :param force: if True, will not prompt for confirmation before deleting the resources. + """ + # Check that the required features are enabled on the subscription + _check_features_enabled(cmd) + + config = _get_config_from_file( + config_file=config_file, configuration_type=definition_type + ) + + api_clients = ApiClients( + aosm_client=client, resource_client=cf_resources(cmd.cli_ctx) + ) + + delly = ResourceDeleter(api_clients, config, cmd.cli_ctx) + if definition_type == VNF: + delly.delete_nfd(clean=clean, force=force) + elif definition_type == CNF: + delly.delete_nfd(clean=clean, force=force) + else: + raise ValueError( + "Definition type must be either 'vnf' or 'cnf'. Definition type" + f" {definition_type} is not recognised." + ) + + +def generate_design_config(output_file: str = "input.json"): + """ + Generate an example config file for building a NSD. + + :param output_file: path to output config file, defaults to "input.json" + :type output_file: str, optional + """ + _generate_config(NSConfiguration.helptext(), output_file) + + +def _generate_config(configuration: Configuration, output_file: str = "input.json"): + """ + Generic generate config function for NFDs and NSDs. + + :param configuration: The Configuration object with helptext filled in for each of + the fields. + :param output_file: path to output config file, defaults to "input.json" + """ + # Config file is a special parameter on the configuration objects. It is the path + # to the configuration file, rather than an input parameter. It therefore shouldn't + # be included here. + config = asdict(configuration) + config.pop("config_file") + + config_as_dict = json.dumps(config, indent=4) + + if Path(output_file).exists(): + carry_on = input( + f"The file {output_file} already exists - do you want to overwrite it?" + " (y/n)" + ) + if carry_on != "y": + raise UnclassifiedUserFault("User aborted!") + + with open(output_file, "w", encoding="utf-8") as f: + f.write(config_as_dict) + if isinstance(configuration, NSConfiguration): + prtName = "design" + else: + prtName = "definition" + print(f"Empty {prtName} configuration has been written to {output_file}") + logger.info( + "Empty %s configuration has been written to %s", prtName, output_file + ) + + +def build_design( + cmd: AzCliCommand, + client: HybridNetworkManagementClient, + config_file: str, + force: bool = False, +): + """ + Build a Network Service Design. + + :param cmd: The AzCLICommand object for the command that was run, we use this to + find the CLI context (from which, for example, subscription id and + credentials can be found, and other clients can be generated.) + :param client: The AOSM client. This is created in _client_factory.py and passed + in by commands.py - we could alternatively just use cf_aosm as + we use cf_resources, but other extensions seem to pass a client + around like this. + :type client: HybridNetworkManagementClient + :param config_file: path to the file + :param force: force the build, even if the design has already been built + """ + + api_clients = ApiClients( + aosm_client=client, resource_client=cf_resources(cmd.cli_ctx) + ) + + # Read the config from the given file + config = _get_config_from_file(config_file=config_file, configuration_type=NSD) + assert isinstance(config, NSConfiguration) + config.validate() + + # Generate the NSD and the artifact manifest. + # This function should not be taking deploy parameters + _generate_nsd( + config=config, + api_clients=api_clients, + force=force, + ) + + +def delete_published_design( + cmd: AzCliCommand, + client: HybridNetworkManagementClient, + config_file, + clean=False, + force=False, +): + """ + Delete a published NSD. + + :param cmd: The AzCLICommand object for the command that was run, we use this to + find the CLI context (from which, for example, subscription id and + credentials can be found, and other clients can be generated.) + :param client: The AOSM client. This is created in _client_factory.py and passed + in by commands.py - we could alternatively just use cf_aosm as + we use cf_resources, but other extensions seem to pass a client + around like this. + :param config_file: Path to the config file + :param clean: if True, will delete the NSD, artifact stores and publisher too. + Defaults to False. Only works if no resources have those as a parent. + Use with care. + :param clean: if True, will delete the NSD on top of the other resources. + :param force: if True, will not prompt for confirmation before deleting the resources. + """ + # Check that the required features are enabled on the subscription + _check_features_enabled(cmd) + + config = _get_config_from_file(config_file=config_file, configuration_type=NSD) + + api_clients = ApiClients( + aosm_client=client, resource_client=cf_resources(cmd.cli_ctx) + ) + + destroyer = ResourceDeleter(api_clients, config, cmd.cli_ctx) + destroyer.delete_nsd(clean=clean, force=force) + + +def publish_design( + cmd: AzCliCommand, + client: HybridNetworkManagementClient, + config_file, + design_file: Optional[str] = None, + parameters_json_file: Optional[str] = None, + manifest_file: Optional[str] = None, + manifest_params_file: Optional[str] = None, + skip: Optional[SkipSteps] = None, +): + """ + Publish a generated design. + + :param cmd: The AzCLICommand object for the command that was run, we use this to + find the CLI context (from which, for example, subscription id and + credentials can be found, and other clients can be generated.) + :param client: The AOSM client. This is created in _client_factory.py and passed + in by commands.py - we could alternatively just use cf_aosm as + we use cf_resources, but other extensions seem to pass a client + around like this. + :type client: HybridNetworkManagementClient + :param config_file: Path to the config file for the NSDV + :param design_file: Optional path to an override bicep template to deploy the NSDV. + :param parameters_json_file: Optional path to a parameters file for the bicep file, + in case the user wants to edit the built NSDV template. If + omitted, parameters from config will be turned into parameters + for the bicep file + :param manifest_file: Optional path to an override bicep template to deploy + manifests + :param manifest_params_file: Optional path to an override bicep parameters + file for manifest parameters + :param skip: options to skip, either publish bicep or upload artifacts + """ + # Check that the required features are enabled on the subscription + _check_features_enabled(cmd) + + print("Publishing design.") + api_clients = ApiClients( + aosm_client=client, resource_client=cf_resources(cmd.cli_ctx) + ) + + config = _get_config_from_file(config_file=config_file, configuration_type=NSD) + assert isinstance(config, NSConfiguration) + config.validate() + + deployer = DeployerViaArm( + api_clients, + resource_type=DeployableResourceTypes.NSD, + config=config, + bicep_path=design_file, + parameters_json_file=parameters_json_file, + manifest_bicep_path=manifest_file, + manifest_params_file=manifest_params_file, + skip=skip, + cli_ctx=cmd.cli_ctx, + ) + + deployer.deploy_nsd_from_bicep() + + +def _generate_nsd( + config: NSConfiguration, api_clients: ApiClients, force: bool = False +): + """Generate a Network Service Design for the given config.""" + if config: + nsd_generator = NSDGenerator(config=config, api_clients=api_clients) + else: + raise CLIInternalError("Generate NSD called without a config file") + + if os.path.exists(config.output_directory_for_build): + if not force: + carry_on = input( + f"The folder {config.output_directory_for_build} already exists - delete it" + " and continue? (y/n)" + ) + if carry_on != "y": + raise UnclassifiedUserFault("User aborted! ") + + shutil.rmtree(config.output_directory_for_build) + + nsd_generator.generate_nsd() diff --git a/src/aosm/azext_aosm/delete/__init__.py b/src/aosm/azext_aosm/delete/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/delete/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/delete/delete.py b/src/aosm/azext_aosm/delete/delete.py new file mode 100644 index 00000000000..9d990e647ba --- /dev/null +++ b/src/aosm/azext_aosm/delete/delete.py @@ -0,0 +1,330 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains class for deploying generated definitions using the Python SDK.""" +from typing import Optional +from knack.log import get_logger + +from azure.cli.core.commands import LongRunningOperation +from azext_aosm._configuration import ( + Configuration, + NFConfiguration, + NSConfiguration, + VNFConfiguration, +) +from azext_aosm.util.management_clients import ApiClients +from azext_aosm.util.utils import input_ack + +logger = get_logger(__name__) + + +class ResourceDeleter: + def __init__( + self, + api_clients: ApiClients, + config: Configuration, + cli_ctx: Optional[object] = None, + ) -> None: + """ + Initializes a new instance of the Deployer class. + + :param aosm_client: The client to use for managing AOSM resources. + :type aosm_client: HybridNetworkManagementClient + :param resource_client: The client to use for managing Azure resources. + :type resource_client: ResourceManagementClient + """ + logger.debug("Create ARM/Bicep Deployer") + self.api_clients = api_clients + self.config = config + self.cli_ctx = cli_ctx + + def delete_nfd(self, clean: bool = False, force: bool = False) -> None: + """ + Delete the NFDV and manifests. If they don't exist it still reports them as deleted. + + :param clean: Delete the NFDG, artifact stores and publisher too. Defaults to False. + Use with care. + """ + assert isinstance(self.config, NFConfiguration) + + if not force: + if clean: + print( + "Are you sure you want to delete all resources associated with NFD" + f" {self.config.nf_name} including the artifact stores and publisher" + f" {self.config.publisher_name}?" + ) + logger.warning( + "This command will fail if other NFD versions exist in the NFD group." + ) + logger.warning( + "Only do this if you are SURE you are not sharing the publisher and" + " artifact stores with other NFDs" + ) + print("There is no undo. Type the publisher name to confirm.") + if not input_ack(self.config.publisher_name.lower(), "Confirm delete:"): + print("Not proceeding with delete") + return + else: + print( + "Are you sure you want to delete the NFD Version" + f" {self.config.version} and associated manifests from group" + f" {self.config.nfdg_name} and publisher {self.config.publisher_name}?" + ) + print("There is no undo. Type 'delete' to confirm") + if not input_ack("delete", "Confirm delete:"): + print("Not proceeding with delete") + return + + self.delete_nfdv() + + if isinstance(self.config, VNFConfiguration): + self.delete_artifact_manifest("sa") + self.delete_artifact_manifest("acr") + + if clean: + logger.info("Delete called for all resources.") + self.delete_nfdg() + self.delete_artifact_store("acr") + if isinstance(self.config, VNFConfiguration): + self.delete_artifact_store("sa") + self.delete_publisher() + + def delete_nsd(self, clean: bool = False, force: bool = False) -> None: + """ + Delete the NSDV and manifests. + + If they don't exist it still reports them as deleted. + """ + assert isinstance(self.config, NSConfiguration) + + if not force: + print( + "Are you sure you want to delete the NSD Version" + f" {self.config.nsd_version}, the associated manifests" + f" {self.config.acr_manifest_names} and configuration group schema" + f" {self.config.cg_schema_name}?" + ) + if clean: + print( + f"Because of the --clean flag, the NSD {self.config.nsd_name} will also be deleted." + ) + print("There is no undo. Type 'delete' to confirm") + if not input_ack("delete", "Confirm delete:"): + print("Not proceeding with delete") + return + + self.delete_nsdv() + self.delete_artifact_manifest("acr") + self.delete_config_group_schema() + if clean: + self.delete_nsdg() + + def delete_nfdv(self): + assert isinstance(self.config, NFConfiguration) + message = ( + f"Delete NFDV {self.config.version} from group {self.config.nfdg_name} and" + f" publisher {self.config.publisher_name}" + ) + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.network_function_definition_versions.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + network_function_definition_group_name=self.config.nfdg_name, + network_function_definition_version_name=self.config.version, + ) + LongRunningOperation(self.cli_ctx, "Deleting NFDV...")(poller) + logger.info("Deleted NFDV.") + except Exception: + logger.error( + "Failed to delete NFDV %s from group %s", + self.config.version, + self.config.nfdg_name, + ) + raise + + def delete_nsdv(self): + assert isinstance(self.config, NSConfiguration) + message = ( + f"Delete NSDV {self.config.nsd_version} from group" + f" {self.config.nsd_name} and publisher {self.config.publisher_name}" + ) + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.network_service_design_versions.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + network_service_design_group_name=self.config.nsd_name, + network_service_design_version_name=self.config.nsd_version, + ) + LongRunningOperation(self.cli_ctx, "Deleting NSDV...")(poller) + logger.info("Deleted NSDV.") + except Exception: + logger.error( + "Failed to delete NSDV %s from group %s", + self.config.nsd_version, + self.config.nsd_name, + ) + raise + + def delete_artifact_manifest(self, store_type: str) -> None: + """ + _summary_ + + :param store_type: "sa" or "acr" + :raises CLIInternalError: If called with any other store type :raises + Exception if delete throws an exception + """ + if store_type == "sa": + assert isinstance(self.config, VNFConfiguration) + store_name = self.config.blob_artifact_store_name + manifest_names = [self.config.sa_manifest_name] + elif store_type == "acr": + store_name = self.config.acr_artifact_store_name + manifest_names = self.config.acr_manifest_names + else: + from azure.cli.core.azclierror import CLIInternalError + + raise CLIInternalError( + "Delete artifact manifest called for invalid store type. Valid types" + " are sa and acr." + ) + + for manifest_name in manifest_names: + message = f"Delete Artifact manifest {manifest_name} from artifact store {store_name}" + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.artifact_manifests.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + artifact_store_name=store_name, + artifact_manifest_name=manifest_name, + ) + LongRunningOperation(self.cli_ctx, "Deleting Artifact manifest...")( + poller + ) # noqa: E501 + logger.info("Deleted Artifact Manifest") + except Exception: + logger.error( + "Failed to delete Artifact manifest %s from artifact store %s", + manifest_name, + store_name, + ) + raise + + def delete_nsdg(self) -> None: + """Delete the NSD.""" + assert isinstance(self.config, NSConfiguration) + message = f"Delete NSD {self.config.nsd_name}" + logger.debug(message) + print(message) + try: + poller = ( + self.api_clients.aosm_client.network_service_design_groups.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + network_service_design_group_name=self.config.nsd_name, + ) + ) + LongRunningOperation(self.cli_ctx, "Deleting NSD...")(poller) + logger.info("Deleted NSD") + except Exception: + logger.error("Failed to delete NSD.") + raise + + def delete_nfdg(self) -> None: + """Delete the NFDG.""" + assert isinstance(self.config, NFConfiguration) + message = f"Delete NFD Group {self.config.nfdg_name}" + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.network_function_definition_groups.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + network_function_definition_group_name=self.config.nfdg_name, + ) + LongRunningOperation(self.cli_ctx, "Deleting NFD Group...")(poller) + logger.info("Deleted NFD Group") + except Exception: + logger.error("Failed to delete NFDG.") + raise + + def delete_artifact_store(self, store_type: str) -> None: + """Delete an artifact store + :param store_type: "sa" or "acr" + :raises CLIInternalError: If called with any other store type + :raises Exception if delete throws an exception.""" + if store_type == "sa": + assert isinstance(self.config, VNFConfiguration) + store_name = self.config.blob_artifact_store_name + elif store_type == "acr": + store_name = self.config.acr_artifact_store_name + else: + from azure.cli.core.azclierror import CLIInternalError + + raise CLIInternalError( + "Delete artifact store called for invalid store type. Valid types are" + " sa and acr." + ) + message = f"Delete Artifact store {store_name}" + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.artifact_stores.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + artifact_store_name=store_name, + ) + LongRunningOperation(self.cli_ctx, "Deleting Artifact store...")(poller) + logger.info("Deleted Artifact Store") + except Exception: + logger.error("Failed to delete Artifact store %s", store_name) + raise + + def delete_publisher(self) -> None: + """ + Delete the publisher. + + Warning - dangerous + """ + message = f"Delete Publisher {self.config.publisher_name}" + logger.debug(message) + print(message) + try: + poller = self.api_clients.aosm_client.publishers.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + ) + LongRunningOperation(self.cli_ctx, "Deleting Publisher...")(poller) + logger.info("Deleted Publisher") + except Exception: + logger.error("Failed to delete publisher") + raise + + def delete_config_group_schema(self) -> None: + """Delete the Configuration Group Schema.""" + assert isinstance(self.config, NSConfiguration) + message = f"Delete Configuration Group Schema {self.config.cg_schema_name}" + logger.debug(message) + print(message) + try: + poller = ( + self.api_clients.aosm_client.configuration_group_schemas.begin_delete( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + configuration_group_schema_name=self.config.cg_schema_name, + ) + ) + LongRunningOperation( + self.cli_ctx, "Deleting Configuration Group Schema..." + )(poller) + logger.info("Deleted Configuration Group Schema") + except Exception: + logger.error("Failed to delete the Configuration Group Schema") + raise diff --git a/src/aosm/azext_aosm/deploy/__init__.py b/src/aosm/azext_aosm/deploy/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/deploy/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/deploy/artifact.py b/src/aosm/azext_aosm/deploy/artifact.py new file mode 100644 index 00000000000..26c719c432b --- /dev/null +++ b/src/aosm/azext_aosm/deploy/artifact.py @@ -0,0 +1,644 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unidiomatic-typecheck +"""A module to handle interacting with artifacts.""" +import json +import math +import shutil +import subprocess +from dataclasses import dataclass +from typing import Any, Optional, Union + +from azure.storage.blob import BlobClient, BlobType +from knack.log import get_logger +from knack.util import CLIError +from oras.client import OrasClient + +from azext_aosm._configuration import ( + ArtifactConfig, + CNFImageConfig, + HelmPackageConfig, + VhdArtifactConfig, +) + +logger = get_logger(__name__) + + +@dataclass +class Artifact: + """Artifact class.""" + + artifact_name: str + artifact_type: str + artifact_version: str + artifact_client: Union[BlobClient, OrasClient] + manifest_credentials: Any + + def upload( + self, + artifact_config: Union[ArtifactConfig, HelmPackageConfig], + use_manifest_permissions: bool = False, + ) -> None: + """ + Upload artifact. + + :param artifact_config: configuration for the artifact being uploaded + """ + if isinstance(self.artifact_client, OrasClient): + if isinstance(artifact_config, HelmPackageConfig): + self._upload_helm_to_acr(artifact_config, use_manifest_permissions) + elif isinstance(artifact_config, ArtifactConfig): + self._upload_arm_to_acr(artifact_config) + elif isinstance(artifact_config, CNFImageConfig): + self._upload_or_copy_image_to_acr( + artifact_config, use_manifest_permissions + ) + else: + raise ValueError(f"Unsupported artifact type: {type(artifact_config)}.") + else: + assert isinstance(artifact_config, ArtifactConfig) + self._upload_to_storage_account(artifact_config) + + def _upload_arm_to_acr(self, artifact_config: ArtifactConfig) -> None: + """ + Upload ARM artifact to ACR. + + :param artifact_config: configuration for the artifact being uploaded + """ + assert isinstance(self.artifact_client, OrasClient) + + if artifact_config.file_path: + if not self.artifact_client.remote.hostname: + raise ValueError( + "Cannot upload ARM template as OrasClient has no remote hostname." + " Please check your ACR config." + ) + target = ( + f"{self.artifact_client.remote.hostname.replace('https://', '')}" + f"/{self.artifact_name}:{self.artifact_version}" + ) + logger.debug("Uploading %s to %s", artifact_config.file_path, target) + self.artifact_client.push(files=[artifact_config.file_path], target=target) + else: + raise NotImplementedError( + "Copying artifacts is not implemented for ACR artifacts stores." + ) + + @staticmethod + def _call_subprocess_raise_output(cmd: list) -> None: + """ + Call a subprocess and raise a CLIError with the output if it fails. + + :param cmd: command to run, in list format + :raise CLIError: if the subprocess fails + """ + log_cmd = cmd.copy() + if "--password" in log_cmd: + # Do not log out passwords. + log_cmd[log_cmd.index("--password") + 1] = "[REDACTED]" + + try: + called_process = subprocess.run( + cmd, encoding="utf-8", capture_output=True, text=True, check=True + ) + logger.debug( + "Output from %s: %s. Error: %s", + log_cmd, + called_process.stdout, + called_process.stderr, + ) + except subprocess.CalledProcessError as error: + logger.debug("Failed to run %s with %s", log_cmd, error) + + all_output: str = ( + f"Command: {'' ''.join(log_cmd)}\n" + f"Output: {error.stdout}\n" + f"Error output: {error.stderr}\n" + f"Return code: {error.returncode}" + ) + logger.debug("All the output %s", all_output) + + # Raise the error without the original exception, which may contain secrets. + raise CLIError(all_output) from None + + def _upload_helm_to_acr( + self, artifact_config: HelmPackageConfig, use_manifest_permissions: bool + ) -> None: + """ + Upload artifact to ACR. This does and az acr login and then a helm push. + + Requires helm to be installed. + + :param artifact_config: configuration for the artifact being uploaded + :param use_manifest_permissions: whether to use the manifest credentials for the + upload. If False, the CLI user credentials will be used, which does not + require Docker to be installed. If True, the manifest creds will be used, + which requires Docker. + """ + self._check_tool_installed("helm") + assert isinstance(self.artifact_client, OrasClient) + chart_path = artifact_config.path_to_chart + if not self.artifact_client.remote.hostname: + raise ValueError( + "Cannot upload artifact. Oras client has no remote hostname." + ) + registry = self._get_acr() + target_registry = f"oci://{registry}" + registry_name = registry.replace(".azurecr.io", "") + + username = self.manifest_credentials["username"] + password = self.manifest_credentials["acr_token"] + + if not use_manifest_permissions: + # Note that this uses the user running the CLI's AZ login credentials, not + # the manifest credentials retrieved from the ACR. This allows users with + # enough permissions to avoid having to install docker. It logs in to the + # registry by retrieving an access token, which allows use of this command + # in environments without docker. + # It is governed by the no-subscription-permissions CLI argument which + # default to False. + logger.debug("Using CLI user credentials to log into %s", registry_name) + acr_login_with_token_cmd = [ + str(shutil.which("az")), + "acr", + "login", + "--name", + registry_name, + "--expose-token", + "--output", + "tsv", + "--query", + "accessToken", + ] + username = "00000000-0000-0000-0000-000000000000" + try: + password = subprocess.check_output( + acr_login_with_token_cmd, encoding="utf-8", text=True + ).strip() + except subprocess.CalledProcessError as error: + unauthorized = ( + error.stderr + and (" 401" in error.stderr or "unauthorized" in error.stderr) + ) or ( + error.stdout + and (" 401" in error.stdout or "unauthorized" in error.stdout) + ) + + if unauthorized: + # As we shell out the the subprocess, I think checking for these + # strings is the best check we can do for permission failures. + raise CLIError( + " Failed to login to Artifact Store ACR.\n" + " It looks like you do not have permissions. You need to have" + " the AcrPush role over the" + " whole subscription in order to be able to upload to the new" + " Artifact store.\n\nIf you do not have them then you can" + " re-run the command using the --no-subscription-permissions" + " flag to use manifest credentials scoped" + " only to the store. This requires Docker to be installed" + " locally." + ) from error + else: + # This seems to prevent occasional helm login failures + self._check_tool_installed("docker") + acr_login_cmd = [ + str(shutil.which("az")), + "acr", + "login", + "--name", + registry_name, + "--username", + username, + "--password", + password, + ] + self._call_subprocess_raise_output(acr_login_cmd) + try: + logger.debug("Uploading %s to %s", chart_path, target_registry) + helm_login_cmd = [ + str(shutil.which("helm")), + "registry", + "login", + registry, + "--username", + username, + "--password", + password, + ] + self._call_subprocess_raise_output(helm_login_cmd) + + # helm push "$chart_path" "$target_registry" + push_command = [ + str(shutil.which("helm")), + "push", + chart_path, + target_registry, + ] + self._call_subprocess_raise_output(push_command) + finally: + helm_logout_cmd = [ + str(shutil.which("helm")), + "registry", + "logout", + registry, + ] + self._call_subprocess_raise_output(helm_logout_cmd) + + @staticmethod + def _convert_to_readable_size(size_in_bytes: Optional[int]) -> str: + """Converts a size in bytes to a human readable size.""" + if size_in_bytes is None: + return "Unknown bytes" + size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") + index = int(math.floor(math.log(size_in_bytes, 1024))) + power = math.pow(1024, index) + readable_size = round(size_in_bytes / power, 2) + return f"{readable_size} {size_name[index]}" + + def _vhd_upload_progress_callback( + self, current_bytes: int, total_bytes: Optional[int] + ) -> None: + """Callback function for VHD upload progress.""" + current_readable = self._convert_to_readable_size(current_bytes) + total_readable = self._convert_to_readable_size(total_bytes) + message = f"Uploaded {current_readable} of {total_readable} bytes" + logger.info(message) + print(message) + + def _upload_to_storage_account(self, artifact_config: ArtifactConfig) -> None: + """ + Upload artifact to storage account. + + :param artifact_config: configuration for the artifact being uploaded + """ + assert isinstance(self.artifact_client, BlobClient) + assert isinstance(artifact_config, ArtifactConfig) + + # If the file path is given, upload the artifact, else, copy it from an existing blob. + if artifact_config.file_path: + logger.info("Upload to blob store") + with open(artifact_config.file_path, "rb") as artifact: + self.artifact_client.upload_blob( + data=artifact, + overwrite=True, + blob_type=BlobType.PAGEBLOB, + progress_hook=self._vhd_upload_progress_callback, + ) + logger.info( + "Successfully uploaded %s to %s", + artifact_config.file_path, + self.artifact_client.account_name, + ) + else: + # Config Validation will raise error if not true + assert isinstance(artifact_config, VhdArtifactConfig) + assert artifact_config.blob_sas_url + logger.info("Copy from SAS URL to blob store") + source_blob = BlobClient.from_blob_url(artifact_config.blob_sas_url) + + if source_blob.exists(): + logger.debug(source_blob.url) + self.artifact_client.start_copy_from_url(source_blob.url) + logger.info( + "Successfully copied %s from %s to %s", + source_blob.blob_name, + source_blob.account_name, + self.artifact_client.account_name, + ) + else: + raise RuntimeError( + f"{source_blob.blob_name} does not exist in" + f" {source_blob.account_name}." + ) + + def _get_acr(self) -> str: + """ + Get the name of the ACR. + + :return: The name of the ACR + """ + assert hasattr(self.artifact_client, "remote") + if not self.artifact_client.remote.hostname: + raise ValueError( + "Cannot upload artifact. Oras client has no remote hostname." + ) + return self._clean_name(self.artifact_client.remote.hostname) + + def _get_acr_target_image( + self, + include_hostname: bool = True, + ) -> str: + """Format the acr url, artifact name and version into a target image string.""" + if include_hostname: + return f"{self._get_acr()}/{self.artifact_name}:{self.artifact_version}" + + return f"{self.artifact_name}:{self.artifact_version}" + + @staticmethod + def _check_tool_installed(tool_name: str) -> None: + """ + Check whether a tool such as docker or helm is installed. + + :param tool_name: name of the tool to check, e.g. docker + """ + if shutil.which(tool_name) is None: + raise CLIError(f"You must install {tool_name} to use this command.") + + def _upload_or_copy_image_to_acr( + self, artifact_config: CNFImageConfig, use_manifest_permissions: bool + ) -> None: + # Check whether the source registry has a namespace in the repository path + source_registry_namespace: str = "" + if artifact_config.source_registry_namespace: + source_registry_namespace = f"{artifact_config.source_registry_namespace}/" + + if artifact_config.source_local_docker_image: + # The user has provided a local docker image to use as the source + # for the images in the artifact manifest + self._check_tool_installed("docker") + print( + f"Using local docker image as source for image artifact upload for image artifact: {self.artifact_name}" + ) + self._push_image_from_local_registry( + local_docker_image=artifact_config.source_local_docker_image, + target_username=self.manifest_credentials["username"], + target_password=self.manifest_credentials["acr_token"], + ) + elif use_manifest_permissions: + self._check_tool_installed("docker") + print( + f"Using docker pull and push to copy image artifact: {self.artifact_name}" + ) + image_name = ( + f"{self._clean_name(artifact_config.source_registry)}/" + f"{source_registry_namespace}{self.artifact_name}" + f":{self.artifact_version}" + ) + self._pull_image_to_local_registry( + source_registry_login_server=self._clean_name( + artifact_config.source_registry + ), + source_image=image_name, + ) + self._push_image_from_local_registry( + local_docker_image=image_name, + target_username=self.manifest_credentials["username"], + target_password=self.manifest_credentials["acr_token"], + ) + else: + print(f"Using az acr import to copy image artifact: {self.artifact_name}") + self._copy_image( + source_registry_login_server=artifact_config.source_registry, + source_image=( + f"{source_registry_namespace}{self.artifact_name}" + f":{self.artifact_version}" + ), + ) + + def _push_image_from_local_registry( + self, + local_docker_image: str, + target_username: str, + target_password: str, + ): + """ + Push image to target registry using docker push. Requires docker. + + :param local_docker_image: name and tag of the source image on local registry + e.g. uploadacr.azurecr.io/samples/nginx:stable + :type local_docker_image: str + :param target_username: The username to use for the az acr login attempt + :type target_username: str + :param target_password: The password to use for the az acr login attempt + :type target_password: str + """ + assert hasattr(self.artifact_client, "remote") + target_acr = self._get_acr() + try: + target = self._get_acr_target_image() + print("Tagging source image") + + tag_image_cmd = [ + str(shutil.which("docker")), + "tag", + local_docker_image, + target, + ] + self._call_subprocess_raise_output(tag_image_cmd) + message = ( + "Logging into artifact store registry " + f"{self.artifact_client.remote.hostname}" + ) + + print(message) + logger.info(message) + acr_target_login_cmd = [ + str(shutil.which("az")), + "acr", + "login", + "--name", + target_acr, + "--username", + target_username, + "--password", + target_password, + ] + self._call_subprocess_raise_output(acr_target_login_cmd) + + print("Pushing target image using docker push") + push_target_image_cmd = [ + str(shutil.which("docker")), + "push", + target, + ] + self._call_subprocess_raise_output(push_target_image_cmd) + except CLIError as error: + logger.error( + ("Failed to tag and push %s to %s."), + local_docker_image, + target_acr, + ) + logger.debug(error, exc_info=True) + raise error + finally: + docker_logout_cmd = [ + str(shutil.which("docker")), + "logout", + target_acr, + ] + self._call_subprocess_raise_output(docker_logout_cmd) + + def _pull_image_to_local_registry( + self, + source_registry_login_server: str, + source_image: str, + ) -> None: + """ + Pull image to local registry using docker pull. Requires docker. + + Uses the CLI user's context to log in to the source registry. + + :param: source_registry_login_server: e.g. uploadacr.azurecr.io + :param: source_image: source docker image name e.g. + uploadacr.azurecr.io/samples/nginx:stable + """ + try: + # Login to the source registry with the CLI user credentials. This requires + # docker to be installed. + message = f"Logging into source registry {source_registry_login_server}" + print(message) + logger.info(message) + acr_source_login_cmd = [ + str(shutil.which("az")), + "acr", + "login", + "--name", + source_registry_login_server, + ] + self._call_subprocess_raise_output(acr_source_login_cmd) + message = f"Pulling source image {source_image}" + print(message) + logger.info(message) + pull_source_image_cmd = [ + str(shutil.which("docker")), + "pull", + source_image, + ] + self._call_subprocess_raise_output(pull_source_image_cmd) + except CLIError as error: + logger.error( + ( + "Failed to pull %s. Check if this image exists in the" + " source registry %s." + ), + source_image, + source_registry_login_server, + ) + logger.debug(error, exc_info=True) + raise error + finally: + docker_logout_cmd = [ + str(shutil.which("docker")), + "logout", + source_registry_login_server, + ] + self._call_subprocess_raise_output(docker_logout_cmd) + + @staticmethod + def _clean_name(registry_name: str) -> str: + """Remove https:// from the registry name.""" + return registry_name.replace("https://", "") + + def _copy_image( + self, + source_registry_login_server: str, + source_image: str, + ): + """ + Copy image from one ACR to another. + + Use az acr import to do the import image. Previously we used the python + sdk ContainerRegistryManagementClient.registries.begin_import_image + but this requires the source resource group name, which is more faff + at configuration time. + + Neither az acr import or begin_import_image support using the username + and acr_token retrieved from the manifest credentials, so this uses the + CLI users context to access both the source registry and the target + Artifact Store registry, which requires either Contributor role or a + custom role that allows the importImage action over the whole subscription. + + :param source_registry: source registry login server e.g. https://uploadacr.azurecr.io + :param source_image: source image including namespace and tags e.g. + samples/nginx:stable + """ + target_acr = self._get_acr() + try: + print("Copying artifact from source registry") + # In order to use az acr import cross subscription, we need to use a token + # to authenticate to the source registry. This is documented as the way to + # us az acr import cross-tenant, not cross-sub, but it also works + # cross-subscription, and meant we didn't have to make a breaking change to + # the format of input.json. Our usage here won't work cross-tenant since + # we're attempting to get the token (source) with the same context as that + # in which we are creating the ACR (i.e. the target tenant) + get_token_cmd = [str(shutil.which("az")), "account", "get-access-token"] + # Dont use _call_subprocess_raise_output here as we don't want to log the + # output + called_process = subprocess.run( # noqa: S603 + get_token_cmd, + encoding="utf-8", + capture_output=True, + text=True, + check=True, + ) + access_token_json = json.loads(called_process.stdout) + access_token = access_token_json["accessToken"] + except subprocess.CalledProcessError as get_token_err: + # This error is thrown from the az account get-access-token command + # If it errored we can log the output as it doesn't contain the token + logger.debug(get_token_err, exc_info=True) + raise CLIError( # pylint: disable=raise-missing-from + "Failed to import image: could not get an access token from your" + " Azure account. Try logging in again with `az login` and then re-run" + " the command. If it fails again, please raise an issue and try" + " repeating the command using the --no-subscription-permissions" + " flag to pull the image to your local machine and then" + " push it to the Artifact Store using manifest credentials scoped" + " only to the store. This requires Docker to be installed" + " locally." + ) + + try: + source = f"{self._clean_name(source_registry_login_server)}/{source_image}" + acr_import_image_cmd = [ + str(shutil.which("az")), + "acr", + "import", + "--name", + target_acr, + "--source", + source, + "--image", + self._get_acr_target_image(include_hostname=False), + "--password", + access_token, + ] + self._call_subprocess_raise_output(acr_import_image_cmd) + except CLIError as error: + logger.debug(error, exc_info=True) + if (" 401" in str(error)) or ("Unauthorized" in str(error)): + # As we shell out the the subprocess, I think checking for these strings + # is the best check we can do for permission failures. + raise CLIError( + " Failed to import image.\nIt looks like either the source_registry" + " in your config file does not exist or the image doesn't exist or" + " you do not have" + " permissions to import images. You need to have Reader/AcrPull" + f" from {source_registry_login_server}, and Contributor role +" + " AcrPush role, or a custom" + " role that allows the importImage action and AcrPush over the" + " whole subscription in order to be able to import to the new" + " Artifact store.\n\nIf you do not have the latter then you" + " can re-run the command using the --no-subscription-permissions" + " flag to pull the image to your local machine and then" + " push it to the Artifact Store using manifest credentials scoped" + " only to the store. This requires Docker to be installed" + " locally." + ) from error + + # The most likely failure is that the image already exists in the artifact + # store, so don't fail at this stage, log the error. + logger.error( + ( + "Failed to import %s to %s. Check if this image exists in the" + " source registry or is already present in the target registry.\n" + "%s" + ), + source_image, + target_acr, + error, + ) diff --git a/src/aosm/azext_aosm/deploy/artifact_manifest.py b/src/aosm/azext_aosm/deploy/artifact_manifest.py new file mode 100644 index 00000000000..3ca14ca3782 --- /dev/null +++ b/src/aosm/azext_aosm/deploy/artifact_manifest.py @@ -0,0 +1,169 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""A module to handle interacting with artifact manifests.""" +from functools import cached_property, lru_cache +from typing import Any, List, Union + +from azure.cli.core.azclierror import AzCLIError +from azure.storage.blob import BlobClient +from knack.log import get_logger +from oras.client import OrasClient + +from azext_aosm._configuration import Configuration +from azext_aosm.deploy.artifact import Artifact +from azext_aosm.util.management_clients import ApiClients +from azext_aosm.vendored_sdks.models import ( + ArtifactManifest, + ArtifactType, + CredentialType, + ManifestArtifactFormat, +) + +logger = get_logger(__name__) + + +class ArtifactManifestOperator: + """ArtifactManifest class.""" + + # pylint: disable=too-few-public-methods + def __init__( + self, + config: Configuration, + api_clients: ApiClients, + store_name: str, + manifest_name: str, + ) -> None: + """Init.""" + self.manifest_name = manifest_name + self.api_clients = api_clients + self.config = config + self.store_name = store_name + self.artifacts = self._get_artifact_list() + + @cached_property + def _manifest_credentials(self) -> Any: + """Gets the details for uploading the artifacts in the manifest.""" + + return self.api_clients.aosm_client.artifact_manifests.list_credential( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + artifact_store_name=self.store_name, + artifact_manifest_name=self.manifest_name, + ).as_dict() + + @lru_cache(maxsize=32) # noqa: B019 + def _oras_client(self, acr_url: str) -> OrasClient: + """ + Returns an OrasClient object for uploading to the artifact store ACR. + + :param arc_url: URL of the ACR backing the artifact manifest + """ + client = OrasClient(hostname=acr_url) + client.login( + username=self._manifest_credentials["username"], + password=self._manifest_credentials["acr_token"], + ) + return client + + def _get_artifact_list(self) -> List[Artifact]: + """Get the list of Artifacts in the Artifact Manifest.""" + artifacts = [] + + manifest: ArtifactManifest = ( + self.api_clients.aosm_client.artifact_manifests.get( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + artifact_store_name=self.store_name, + artifact_manifest_name=self.manifest_name, + ) + ) + + # Instatiate an Artifact object for each artifact in the manifest. + if manifest.properties.artifacts: + for artifact in manifest.properties.artifacts: + if not ( + artifact.artifact_name + and artifact.artifact_type + and artifact.artifact_version + ): + raise AzCLIError( + "Cannot upload artifact. Artifact returned from " + "manifest query is missing required information." + f"{artifact}" + ) + + artifacts.append( + Artifact( + artifact_name=artifact.artifact_name, + artifact_type=artifact.artifact_type, + artifact_version=artifact.artifact_version, + artifact_client=self._get_artifact_client(artifact), + manifest_credentials=self._manifest_credentials, + ) + ) + + return artifacts + + def _get_artifact_client( + self, artifact: ManifestArtifactFormat + ) -> Union[BlobClient, OrasClient]: + """ + Get the artifact client required for uploading the artifact. + + :param artifact - a ManifestArtifactFormat with the artifact info. + """ + # Appease mypy - an error will be raised before this if these are blank + assert artifact.artifact_name + assert artifact.artifact_type + assert artifact.artifact_version + if ( + self._manifest_credentials["credential_type"] + == CredentialType.AZURE_STORAGE_ACCOUNT_TOKEN + ): + # Check we have the required artifact types for this credential. Indicates + # a coding error if we hit this but worth checking. + if not ( + artifact.artifact_type + in (ArtifactType.IMAGE_FILE, ArtifactType.VHD_IMAGE_FILE) + ): + raise AzCLIError( + f"Cannot upload artifact {artifact.artifact_name}." + " Artifact manifest credentials of type " + f"{CredentialType.AZURE_STORAGE_ACCOUNT_TOKEN} are not expected " + f"for Artifacts of type {artifact.artifact_type}" + ) + + container_basename = artifact.artifact_name.replace("-", "") + container_name = f"{container_basename}-{artifact.artifact_version}" + + # For AOSM to work VHD blobs must have the suffix .vhd + if artifact.artifact_name.endswith("-vhd"): + blob_name = f"{artifact.artifact_name[:-4].replace('-', '')}-{artifact.artifact_version}.vhd" + else: + blob_name = container_name + + logger.debug("container name: %s, blob name: %s", container_name, blob_name) + + blob_url = self._get_blob_url(container_name, blob_name) + return BlobClient.from_blob_url(blob_url) + return self._oras_client(self._manifest_credentials["acr_server_url"]) + + def _get_blob_url(self, container_name: str, blob_name: str) -> str: + """ + Get the URL for the blob to be uploaded to the storage account artifact store. + + :param container_name: name of the container + :param blob_name: the name that the blob will get uploaded with + """ + for container_credential in self._manifest_credentials["container_credentials"]: + if container_credential["container_name"] == container_name: + sas_uri = str(container_credential["container_sas_uri"]) + sas_uri_prefix, sas_uri_token = sas_uri.split("?", maxsplit=1) + + blob_url = f"{sas_uri_prefix}/{blob_name}?{sas_uri_token}" + logger.debug("Blob URL: %s", blob_url) + + return blob_url + raise KeyError(f"Manifest does not include a credential for {container_name}.") diff --git a/src/aosm/azext_aosm/deploy/deploy_with_arm.py b/src/aosm/azext_aosm/deploy/deploy_with_arm.py new file mode 100644 index 00000000000..73da03a965a --- /dev/null +++ b/src/aosm/azext_aosm/deploy/deploy_with_arm.py @@ -0,0 +1,731 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains class for deploying generated definitions using ARM.""" +import json +import os +import shutil +import subprocess # noqa +import tempfile +import time +from typing import Any, Dict, Optional + +from azure.cli.core.azclierror import ValidationError +from azure.cli.core.commands import LongRunningOperation +from azure.mgmt.resource.resources.models import DeploymentExtended +from knack.log import get_logger +from knack.util import CLIError + +from azext_aosm._configuration import ( + ArtifactConfig, + CNFConfiguration, + Configuration, + NFConfiguration, + NFDRETConfiguration, + NSConfiguration, + VNFConfiguration, +) +from azext_aosm.deploy.artifact import Artifact +from azext_aosm.deploy.artifact_manifest import ArtifactManifestOperator +from azext_aosm.deploy.pre_deploy import PreDeployerViaSDK +from azext_aosm.util.constants import ( + ARTIFACT_UPLOAD, + BICEP_PUBLISH, + CNF, + CNF_DEFINITION_BICEP_TEMPLATE_FILENAME, + CNF_MANIFEST_BICEP_TEMPLATE_FILENAME, + IMAGE_UPLOAD, + NSD, + NSD_ARTIFACT_MANIFEST_BICEP_FILENAME, + NSD_BICEP_FILENAME, + VNF, + VNF_DEFINITION_BICEP_TEMPLATE_FILENAME, + VNF_MANIFEST_BICEP_TEMPLATE_FILENAME, + DeployableResourceTypes, + SkipSteps, +) +from azext_aosm.util.management_clients import ApiClients + +logger = get_logger(__name__) + + +class DeployerViaArm: # pylint: disable=too-many-instance-attributes + """ + A class to deploy Artifact Manifests, NFDs and NSDs from bicep templates using ARM. + + Uses the SDK to pre-deploy less complex resources and then ARM to deploy the bicep + templates. + """ + + def __init__( + self, + api_clients: ApiClients, + resource_type: DeployableResourceTypes, + config: Configuration, + bicep_path: Optional[str] = None, + parameters_json_file: Optional[str] = None, + manifest_bicep_path: Optional[str] = None, + manifest_params_file: Optional[str] = None, + skip: Optional[SkipSteps] = None, + cli_ctx: Optional[object] = None, + use_manifest_permissions: bool = False, + ): + """ + :param api_clients: ApiClients object for AOSM and ResourceManagement + :param config: The configuration for this NF + :param bicep_path: The path to the bicep template of the nfdv + :param parameters_json_file: path to an override file of set parameters for the nfdv + :param manifest_bicep_path: The path to the bicep template of the manifest + :param manifest_params_file: path to an override file of set parameters for + the manifest + :param skip: options to skip, either publish bicep or upload artifacts + :param cli_ctx: The CLI context. Used with CNFs and all LongRunningOperations + :param use_manifest_permissions: + CNF definition_type publish only - ignored for VNF or NSD. Causes the image + artifact copy from a source ACR to be done via docker pull and push, + rather than `az acr import`. This is slower but does not require + Contributor (or importImage action) permissions on the publisher + subscription. Also uses manifest permissions for helm chart upload. + Requires Docker to be installed locally. + """ + self.api_clients = api_clients + self.resource_type = resource_type + self.config = config + self.bicep_path = bicep_path + self.parameters_json_file = parameters_json_file + self.manifest_bicep_path = manifest_bicep_path + self.manifest_params_file = manifest_params_file + self.skip = skip + self.cli_ctx = cli_ctx + self.pre_deployer = PreDeployerViaSDK( + self.api_clients, self.config, self.cli_ctx + ) + self.use_manifest_permissions = use_manifest_permissions + + def deploy_nfd_from_bicep(self) -> None: + """ + Deploy the bicep template defining the NFD. + + Also ensure that all required predeploy resources are deployed. + """ + assert isinstance(self.config, NFConfiguration) + if self.skip == BICEP_PUBLISH: + print("Skipping bicep manifest publish") + else: + # 1) Deploy Artifact manifest bicep + # Create or check required resources + deploy_manifest_template = not self.nfd_predeploy() + if deploy_manifest_template: + self.deploy_manifest_template() + else: + print( + f"Artifact manifests exist for NFD {self.config.nf_name} " + f"version {self.config.version}" + ) + + if self.skip == ARTIFACT_UPLOAD: + print("Skipping artifact upload") + else: + # 2) Upload artifacts - must be done before nfd deployment + if self.resource_type == VNF: + self._vnfd_artifact_upload() + if self.resource_type == CNF: + self._cnfd_artifact_upload() + + if self.skip == BICEP_PUBLISH: + print("Skipping bicep nfd publish") + print("Done") + return + + # 3) Deploy NFD bicep + if not self.bicep_path: + # User has not passed in a bicep template, so we are deploying the default + # one produced from building the NFDV using this CLI + if self.resource_type == VNF: + file_name = VNF_DEFINITION_BICEP_TEMPLATE_FILENAME + if self.resource_type == CNF: + file_name = CNF_DEFINITION_BICEP_TEMPLATE_FILENAME + bicep_path = os.path.join(self.config.output_directory_for_build, file_name) + message = ( + f"Deploy bicep template for NFD {self.config.nf_name} version" + f" {self.config.version} into" + f" {self.config.publisher_resource_group_name} under publisher" + f" {self.config.publisher_name}" + ) + print(message) + logger.info(message) + logger.debug( + "Parameters used for NF definition bicep deployment: %s", + self.parameters, + ) + self.deploy_bicep_template(bicep_path, self.parameters) + print(f"Deployed NFD {self.config.nf_name} version {self.config.version}.") + + def _vnfd_artifact_upload(self) -> None: + """Uploads the VHD and ARM template artifacts.""" + assert isinstance(self.config, VNFConfiguration) + storage_account_manifest = ArtifactManifestOperator( + self.config, + self.api_clients, + self.config.blob_artifact_store_name, + self.config.sa_manifest_name, + ) + acr_manifest = ArtifactManifestOperator( + self.config, + self.api_clients, + self.config.acr_artifact_store_name, + self.config.acr_manifest_names[0], + ) + + vhd_artifact = storage_account_manifest.artifacts[0] + arm_template_artifact = acr_manifest.artifacts[0] + + vhd_config = self.config.vhd + arm_template_config = self.config.arm_template + + assert isinstance(vhd_config, ArtifactConfig) + assert isinstance(arm_template_config, ArtifactConfig) + + if self.skip == IMAGE_UPLOAD: + print("Skipping VHD artifact upload") + else: + print("Uploading VHD artifact") + vhd_artifact.upload(vhd_config) + + print("Uploading ARM template artifact") + arm_template_artifact.upload(arm_template_config) + + def _cnfd_artifact_upload(self) -> None: + """Uploads the Helm chart and any additional images.""" + assert isinstance(self.config, CNFConfiguration) + acr_properties = self.api_clients.aosm_client.artifact_stores.get( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + artifact_store_name=self.config.acr_artifact_store_name, + ) + if not acr_properties.properties.storage_resource_id: + raise CLIError( + f"Artifact store {self.config.acr_artifact_store_name} " + "has no storage resource id linked" + ) + + # The artifacts from the manifest which has been deployed by bicep + acr_manifest = ArtifactManifestOperator( + self.config, + self.api_clients, + self.config.acr_artifact_store_name, + self.config.acr_manifest_names[0], + ) + + # Create a new dictionary of artifacts from the manifest, keyed by artifact name + artifact_dictionary = {} + + for artifact in acr_manifest.artifacts: + artifact_dictionary[artifact.artifact_name] = artifact + + for helm_package in self.config.helm_packages: + # Go through the helm packages in the config that the user has provided + helm_package_name = helm_package.name # type: ignore + + if helm_package_name not in artifact_dictionary: + # Helm package in the config file but not in the artifact manifest + raise CLIError( + f"Artifact {helm_package_name} not found in the artifact manifest" + ) + # Get the artifact object that came from the manifest + manifest_artifact = artifact_dictionary[helm_package_name] + + print(f"Uploading Helm package: {helm_package_name}") + + # The artifact object will use the correct client (ORAS) to upload the + # artifact + manifest_artifact.upload(helm_package, self.use_manifest_permissions) # type: ignore + + print(f"Finished uploading Helm package: {helm_package_name}") + + # Remove this helm package artifact from the dictionary. + artifact_dictionary.pop(helm_package_name) + + # All the remaining artifacts are not in the helm_packages list. We assume that + # they are images that need to be copied from another ACR or uploaded from a + # local image. + if self.skip == IMAGE_UPLOAD: + print("Skipping upload of images") + return + + # This is the first time we have easy access to the number of images to upload + # so we validate the config file here. + if ( + len(artifact_dictionary.values()) > 1 + and self.config.images.source_local_docker_image # type: ignore + ): + raise ValidationError( + "Multiple image artifacts found to upload and a local docker image" + " was specified in the config file. source_local_docker_image is only " + "supported if there is a single image artifact to upload." + ) + for artifact in artifact_dictionary.values(): + assert isinstance(artifact, Artifact) + artifact.upload(self.config.images, self.use_manifest_permissions) # type: ignore + + def nfd_predeploy(self) -> bool: + """ + All the predeploy steps for a NFD. Create publisher, artifact stores and NFDG. + + Return True if artifact manifest already exists, False otherwise + """ + logger.debug("Ensure all required resources exist") + self.pre_deployer.ensure_config_resource_group_exists() + self.pre_deployer.ensure_config_publisher_exists() + self.pre_deployer.ensure_acr_artifact_store_exists() + if self.resource_type == VNF: + self.pre_deployer.ensure_sa_artifact_store_exists() + self.pre_deployer.ensure_config_nfdg_exists() + return self.pre_deployer.do_config_artifact_manifests_exist() + + @property + def parameters(self) -> Dict[str, Any]: + if self.parameters_json_file: + message = f"Use parameters from file {self.parameters_json_file}" + logger.info(message) + print(message) + with open(self.parameters_json_file, "r", encoding="utf-8") as f: + parameters_json = json.loads(f.read()) + parameters = parameters_json["parameters"] + else: + # User has not passed in parameters file, so we use the parameters + # required from config for the default bicep template produced from + # building the NFDV using this CLI + logger.debug("Create parameters for default template.") + parameters = self.construct_parameters() + + return parameters + + def construct_parameters(self) -> Dict[str, Any]: + """ + Create the parmeters dictionary for vnfdefinitions.bicep. + + VNF specific. + """ + if self.resource_type == VNF: + assert isinstance(self.config, VNFConfiguration) + assert isinstance(self.config.vhd, ArtifactConfig) + assert isinstance(self.config.arm_template, ArtifactConfig) + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "saArtifactStoreName": {"value": self.config.blob_artifact_store_name}, + "nfName": {"value": self.config.nf_name}, + "nfDefinitionGroup": {"value": self.config.nfdg_name}, + "nfDefinitionVersion": {"value": self.config.version}, + "vhdVersion": {"value": self.config.vhd.version}, + "armTemplateVersion": {"value": self.config.arm_template.version}, + } + if self.resource_type == CNF: + assert isinstance(self.config, CNFConfiguration) + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "nfDefinitionGroup": {"value": self.config.nfdg_name}, + "nfDefinitionVersion": {"value": self.config.version}, + } + if self.resource_type == NSD: + assert isinstance(self.config, NSConfiguration) + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "nsDesignGroup": {"value": self.config.nsd_name}, + "nsDesignVersion": {"value": self.config.nsd_version}, + "nfviSiteName": {"value": self.config.nfvi_site_name}, + } + raise TypeError( + "Unexpected config type. Expected [VNFConfiguration|CNFConfiguration|NSConfiguration]," + f" received {type(self.config)}" + ) + + def construct_manifest_parameters(self) -> Dict[str, Any]: + """Create the parmeters dictionary for VNF, CNF or NSD.""" + if self.resource_type == VNF: + assert isinstance(self.config, VNFConfiguration) + assert isinstance(self.config.vhd, ArtifactConfig) + assert isinstance(self.config.arm_template, ArtifactConfig) + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "saArtifactStoreName": {"value": self.config.blob_artifact_store_name}, + "acrManifestName": {"value": self.config.acr_manifest_names[0]}, + "saManifestName": {"value": self.config.sa_manifest_name}, + "nfName": {"value": self.config.nf_name}, + "vhdVersion": {"value": self.config.vhd.version}, + "armTemplateVersion": {"value": self.config.arm_template.version}, + } + if self.resource_type == CNF: + assert isinstance(self.config, CNFConfiguration) + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "acrManifestName": {"value": self.config.acr_manifest_names[0]}, + } + if self.resource_type == NSD: + assert isinstance(self.config, NSConfiguration) + + arm_template_names = [] + + for nf in self.config.network_functions: + assert isinstance(nf, NFDRETConfiguration) + arm_template_names.append(nf.arm_template.artifact_name) + + # Set the artifact version to be the same as the NSD version, so that they + # don't get over written when a new NSD is published. + return { + "location": {"value": self.config.location}, + "publisherName": {"value": self.config.publisher_name}, + "acrArtifactStoreName": {"value": self.config.acr_artifact_store_name}, + "acrManifestNames": {"value": self.config.acr_manifest_names}, + "armTemplateNames": {"value": arm_template_names}, + "armTemplateVersion": {"value": self.config.nsd_version}, + } + raise ValueError("Unknown configuration type") + + def deploy_nsd_from_bicep(self) -> None: + """ + Deploy the bicep template defining the VNFD. + + Also ensure that all required predeploy resources are deployed. + """ + assert isinstance(self.config, NSConfiguration) + if not self.skip == BICEP_PUBLISH: + # 1) Deploy Artifact manifest bicep + if not self.bicep_path: + # User has not passed in a bicep template, so we are deploying the default + # one produced from building the NSDV using this CLI + bicep_path = os.path.join( + self.config.output_directory_for_build, + NSD_BICEP_FILENAME, + ) + + logger.debug(self.parameters) + + # Create or check required resources + deploy_manifest_template = not self.nsd_predeploy() + + if deploy_manifest_template: + self.deploy_manifest_template() + else: + logger.debug( + "Artifact manifests %s already exist", + self.config.acr_manifest_names, + ) + print("Artifact manifests already exist") + + if self.skip == ARTIFACT_UPLOAD: + print("Skipping artifact upload") + else: + # 2) Upload artifacts - must be done before nsd deployment + for manifest, nf in zip( + self.config.acr_manifest_names, self.config.network_functions + ): + assert isinstance(nf, NFDRETConfiguration) + acr_manifest = ArtifactManifestOperator( + self.config, + self.api_clients, + self.config.acr_artifact_store_name, + manifest, + ) + + # Convert the NF bicep to ARM + arm_template_artifact_json = self.convert_bicep_to_arm( + os.path.join( + self.config.output_directory_for_build, nf.nf_bicep_filename + ) + ) + + arm_template_artifact = acr_manifest.artifacts[0] + + # appease mypy + assert ( + nf.arm_template.file_path + ), "Config missing ARM template file path" + with open(nf.arm_template.file_path, "w", encoding="utf-8") as file: + file.write(json.dumps(arm_template_artifact_json, indent=4)) + + print(f"Uploading ARM template artifact: {nf.arm_template.file_path}") + arm_template_artifact.upload(nf.arm_template) + + if self.skip == BICEP_PUBLISH: + print("Skipping bicep nsd publish") + print("Done") + return + + # 3) Deploy NSD bicep + if not self.bicep_path: + # User has not passed in a bicep template, so we are deploying the default + # one produced from building the NSDV using this CLI + bicep_path = os.path.join( + self.config.output_directory_for_build, + NSD_BICEP_FILENAME, + ) + message = ( + f"Deploy bicep template for NSDV {self.config.nsd_version} " + f"into {self.config.publisher_resource_group_name} under publisher " + f"{self.config.publisher_name}" + ) + print(message) + logger.info(message) + self.deploy_bicep_template(bicep_path, self.parameters) + print( + f"Deployed NSD {self.config.nsd_name} " + f"version {self.config.nsd_version}." + ) + + def deploy_manifest_template(self) -> None: + """Deploy the bicep template defining the manifest.""" + print("Deploy bicep template for Artifact manifests") + logger.debug("Deploy manifest bicep") + + if not self.manifest_bicep_path: + file_name: str = "" + if self.resource_type == NSD: + file_name = NSD_ARTIFACT_MANIFEST_BICEP_FILENAME + if self.resource_type == VNF: + file_name = VNF_MANIFEST_BICEP_TEMPLATE_FILENAME + if self.resource_type == CNF: + file_name = CNF_MANIFEST_BICEP_TEMPLATE_FILENAME + + manifest_bicep_path = os.path.join( + str(self.config.output_directory_for_build), + file_name, + ) + if not self.manifest_params_file: + manifest_params = self.construct_manifest_parameters() + else: + logger.info("Use provided manifest parameters") + with open(self.manifest_params_file, "r", encoding="utf-8") as f: + manifest_json = json.loads(f.read()) + manifest_params = manifest_json["parameters"] + self.deploy_bicep_template(manifest_bicep_path, manifest_params) + + def nsd_predeploy(self) -> bool: + """ + All the predeploy steps for a NSD. Check if the RG, publisher, ACR, NSD and + artifact manifest exist. + + Return True if artifact manifest already exists, False otherwise + """ + logger.debug("Ensure all required resources exist") + self.pre_deployer.ensure_config_resource_group_exists() + self.pre_deployer.ensure_config_publisher_exists() + self.pre_deployer.ensure_acr_artifact_store_exists() + self.pre_deployer.ensure_config_nsd_exists() + return self.pre_deployer.do_config_artifact_manifests_exist() + + def deploy_bicep_template( + self, bicep_template_path: str, parameters: Dict[Any, Any] + ) -> Any: + """ + Deploy a bicep template. + + :param bicep_template_path: Path to the bicep template + :param parameters: Parameters for the bicep template + :return Any output that the template produces + """ + logger.info("Deploy %s", bicep_template_path) + logger.debug("Parameters: %s", parameters) + arm_template_json = self.convert_bicep_to_arm(bicep_template_path) + + return self.validate_and_deploy_arm_template( + arm_template_json, parameters, self.config.publisher_resource_group_name + ) + + def resource_exists(self, resource_name: str) -> bool: + """ + Determine if a resource with the given name exists. + + :param resource_name: The name of the resource to check. + """ + logger.debug("Check if %s exists", resource_name) + resources = self.api_clients.resource_client.resources.list_by_resource_group( + resource_group_name=self.config.publisher_resource_group_name + ) + + resource_exists = False + + for resource in resources: + if resource.name == resource_name: + resource_exists = True + break + + return resource_exists + + def validate_and_deploy_arm_template( + self, template: Any, parameters: Dict[Any, Any], resource_group: str + ) -> Any: + """ + Validate and deploy an individual ARM template. + + This ARM template will be created in the resource group passed in. + + :param template: The JSON contents of the template to deploy + :param parameters: The JSON contents of the parameters file + :param resource_group: The name of the resource group that has been deployed + + :return: Output dictionary from the bicep template. + :raise RuntimeError if validation or deploy fails + """ + # Get current time from the time module and remove all digits after the decimal + # point + current_time = str(time.time()).split(".", maxsplit=1)[0] + + # Add a timestamp to the deployment name to ensure it is unique + deployment_name = f"AOSM_CLI_deployment_{current_time}" + + # Validation is automatically re-attempted in live runs, but not in test + # playback, causing them to fail. This explicitly re-attempts validation to + # ensure the tests pass + validation_res = None + for validation_attempt in range(2): + try: + validation = ( + self.api_clients.resource_client.deployments.begin_validate( + resource_group_name=resource_group, + deployment_name=deployment_name, + parameters={ + "properties": { + "mode": "Incremental", + "template": template, + "parameters": parameters, + } + }, + ) + ) + validation_res = LongRunningOperation( + self.cli_ctx, "Validating ARM template..." + )(validation) + break + except Exception: # pylint: disable=broad-except + if validation_attempt == 1: + raise + + if not validation_res: + # Don't expect to hit this but it appeases mypy + raise RuntimeError(f"Validation of template {template} failed.") + + logger.debug("Validation Result %s", validation_res) + if validation_res.error: + # Validation failed so don't even try to deploy + logger.error( + ( + "Template for resource group %s has failed validation. The message" + " was: %s. See logs for additional details." + ), + resource_group, + validation_res.error.message, + ) + logger.debug( + ( + "Template for resource group %s failed validation." + " Full error details: %s" + ), + resource_group, + validation_res.error, + ) + raise RuntimeError("Azure template validation failed.") + + # Validation succeeded so proceed with deployment + logger.debug("Successfully validated resources for %s", resource_group) + + poller = self.api_clients.resource_client.deployments.begin_create_or_update( + resource_group_name=resource_group, + deployment_name=deployment_name, + parameters={ + "properties": { + "mode": "Incremental", + "template": template, + "parameters": parameters, + } + }, + ) + logger.debug(poller) + + # Wait for the deployment to complete and get the outputs + deployment: DeploymentExtended = LongRunningOperation( + self.cli_ctx, "Deploying ARM template" + )(poller) + logger.debug("Finished deploying") + + if deployment.properties is not None: + depl_props = deployment.properties + else: + raise RuntimeError("The deployment has no properties.\nAborting") + logger.debug("Deployed: %s %s %s", deployment.name, deployment.id, depl_props) + + if depl_props.provisioning_state != "Succeeded": + logger.debug("Failed to provision: %s", depl_props) + raise RuntimeError( + "Deploy of template to resource group" + f" {resource_group} proceeded but the provisioning" + f" state returned is {depl_props.provisioning_state}." + "\nAborting" + ) + logger.debug( + "Provisioning state of deployment %s : %s", + resource_group, + depl_props.provisioning_state, + ) + + return depl_props.outputs + + @staticmethod + def convert_bicep_to_arm(bicep_template_path: str) -> Any: + """ + Convert a bicep template into an ARM template. + + :param bicep_template_path: The path to the bicep template to be converted + :return: Output dictionary from the bicep template. + """ + logger.debug("Converting %s to ARM template", bicep_template_path) + + with tempfile.TemporaryDirectory() as tmpdir: + bicep_filename = os.path.basename(bicep_template_path) + arm_template_name = bicep_filename.replace(".bicep", ".json") + + try: + bicep_output = subprocess.run( # noqa + [ + str(shutil.which("az")), + "bicep", + "build", + "--file", + bicep_template_path, + "--outfile", + os.path.join(tmpdir, arm_template_name), + ], + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + logger.debug("az bicep output: %s", str(bicep_output)) + except subprocess.CalledProcessError as err: + logger.error( + ( + "ARM template compilation failed! See logs for full " + "output. The failing command was %s" + ), + err.cmd, + ) + logger.debug("bicep build stdout: %s", err.stdout) + logger.debug("bicep build stderr: %s", err.stderr) + raise + + with open( + os.path.join(tmpdir, arm_template_name), "r", encoding="utf-8" + ) as template_file: + arm_json = json.loads(template_file.read()) + + return arm_json diff --git a/src/aosm/azext_aosm/deploy/pre_deploy.py b/src/aosm/azext_aosm/deploy/pre_deploy.py new file mode 100644 index 00000000000..b34a4929cc9 --- /dev/null +++ b/src/aosm/azext_aosm/deploy/pre_deploy.py @@ -0,0 +1,444 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains class for deploying resources required by NFDs/NSDs via the SDK.""" + +from typing import Optional + +from azure.cli.core.azclierror import AzCLIError +from azure.cli.core.commands import LongRunningOperation +from azure.core import exceptions as azure_exceptions +from azure.mgmt.resource.resources.models import ResourceGroup +from knack.log import get_logger + +from azext_aosm._configuration import ( + Configuration, + VNFConfiguration, +) +from azext_aosm.util.management_clients import ApiClients +from azext_aosm.vendored_sdks.models import ( + ArtifactStore, + ArtifactStorePropertiesFormat, + ArtifactStoreType, + NetworkFunctionDefinitionGroup, + NetworkServiceDesignGroup, + ProvisioningState, + Publisher, + PublisherPropertiesFormat, + ManagedServiceIdentity +) + +logger = get_logger(__name__) + + +class PreDeployerViaSDK: + """ + A class for checking or publishing resources required by NFDs/NSDs. + + Uses the SDK to deploy rather than ARM, as the objects it deploys are not complex. + """ + + def __init__( + self, + api_clients: ApiClients, + config: Configuration, + cli_ctx: Optional[object] = None, + ) -> None: + """ + Initializes a new instance of the Deployer class. + + :param api_clients: ApiClients object for AOSM and ResourceManagement + :param config: The configuration for this NF + :param cli_ctx: The CLI context. Used with all LongRunningOperation calls. + """ + + self.api_clients = api_clients + self.config = config + self.cli_ctx = cli_ctx + + def ensure_resource_group_exists(self, resource_group_name: str) -> None: + """ + Checks whether a particular resource group exists on the subscription, and + attempts to create it if not. + + :param resource_group_name: The name of the resource group + """ + if not self.api_clients.resource_client.resource_groups.check_existence( + resource_group_name + ): + logger.info("RG %s not found. Create it.", resource_group_name) + print(f"Creating resource group {resource_group_name}.") + rg_params: ResourceGroup = ResourceGroup(location=self.config.location) + self.api_clients.resource_client.resource_groups.create_or_update( + resource_group_name, rg_params + ) + else: + print(f"Resource group {resource_group_name} exists.") + self.api_clients.resource_client.resource_groups.get(resource_group_name) + + def ensure_config_resource_group_exists(self) -> None: + """ + Ensures that the resource group exists. + + Finds the parameters from self.config + """ + self.ensure_resource_group_exists(self.config.publisher_resource_group_name) + + def ensure_publisher_exists( + self, resource_group_name: str, publisher_name: str, location: str + ) -> None: + """ + Ensures that the publisher exists in the resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param publisher_name: The name of the publisher. + :type publisher_name: str + :param location: The location of the publisher. + :type location: str + """ + + try: + publisher = self.api_clients.aosm_client.publishers.get( + resource_group_name, publisher_name + ) + print( + f"Publisher {publisher.name} exists in resource group" + f" {resource_group_name}" + ) + except azure_exceptions.ResourceNotFoundError: + # Create the publisher with default SAMI and private scope + logger.info("Creating publisher %s if it does not exist", publisher_name) + print( + f"Creating publisher {publisher_name} in resource group" + f" {resource_group_name}" + ) + publisher_properties = PublisherPropertiesFormat(scope="Private") + publisher_sami = ManagedServiceIdentity(type="SystemAssigned") + poller = self.api_clients.aosm_client.publishers.begin_create_or_update( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + parameters=Publisher(location=location, properties=publisher_properties, identity=publisher_sami), + ) + LongRunningOperation(self.cli_ctx, "Creating publisher...")(poller) + + def ensure_config_publisher_exists(self) -> None: + """ + Ensures that the publisher exists in the resource group. + + Finds the parameters from self.config + """ + self.ensure_publisher_exists( + resource_group_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + location=self.config.location, + ) + + def ensure_artifact_store_exists( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_store_type: ArtifactStoreType, + location: str, + ) -> None: + """ + Ensures that the artifact store exists in the resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param publisher_name: The name of the publisher. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. + :type artifact_store_name: str + :param artifact_store_type: The type of the artifact store. + :type artifact_store_type: ArtifactStoreType + :param location: The location of the artifact store. + :type location: str + """ + logger.info( + "Creating artifact store %s if it does not exist", + artifact_store_name, + ) + try: + self.api_clients.aosm_client.artifact_stores.get( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + ) + print( + f"Artifact store {artifact_store_name} exists in resource group" + f" {resource_group_name}" + ) + except azure_exceptions.ResourceNotFoundError as ex: + print( + f"Create Artifact Store {artifact_store_name} of type" + f" {artifact_store_type}" + ) + artifact_store_properties = ArtifactStorePropertiesFormat(store_type=artifact_store_type) + poller = ( + self.api_clients.aosm_client.artifact_stores.begin_create_or_update( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + parameters=ArtifactStore( + location=location, + properties=artifact_store_properties, + ), + ) + ) + # LongRunningOperation waits for provisioning state Succeeded before + # carrying on + artifactStore: ArtifactStore = LongRunningOperation( + self.cli_ctx, "Creating Artifact Store..." + )(poller) + + if artifactStore.properties.provisioning_state != ProvisioningState.SUCCEEDED: + logger.debug("Failed to provision artifact store: %s", artifactStore.name) + raise RuntimeError( + "Creation of artifact store proceeded, but the provisioning" + f" state returned is {artifactStore.properties.provisioning_state}. " + "\nAborting" + ) from ex + logger.debug( + "Provisioning state of %s: %s", + artifact_store_name, + artifactStore.properties.provisioning_state, + ) + + def ensure_acr_artifact_store_exists(self) -> None: + """ + Ensures that the ACR Artifact store exists. + + Finds the parameters from self.config + """ + self.ensure_artifact_store_exists( + self.config.publisher_resource_group_name, + self.config.publisher_name, + self.config.acr_artifact_store_name, + ArtifactStoreType.AZURE_CONTAINER_REGISTRY, # type: ignore + self.config.location, + ) + + def ensure_sa_artifact_store_exists(self) -> None: + """ + Ensures that the Storage Account Artifact store for VNF exists. + + Finds the parameters from self.config + """ + if not isinstance(self.config, VNFConfiguration): + # This is a coding error but worth checking. + raise AzCLIError( + "Cannot check that the storage account artifact store exists as " + "the configuration file doesn't map to VNFConfiguration" + ) + + self.ensure_artifact_store_exists( + self.config.publisher_resource_group_name, + self.config.publisher_name, + self.config.blob_artifact_store_name, + ArtifactStoreType.AZURE_STORAGE_ACCOUNT, # type: ignore + self.config.location, + ) + + def ensure_nfdg_exists( + self, + resource_group_name: str, + publisher_name: str, + nfdg_name: str, + location: str, + ): + """ + Ensures that the network function definition group exists in the resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param publisher_name: The name of the publisher. + :type publisher_name: str + :param nfdg_name: The name of the network function definition group. + :type nfdg_name: str + :param location: The location of the network function definition group. + :type location: str + """ + + logger.info( + "Creating network function definition group %s if it does not exist", + nfdg_name, + ) + + try: + self.api_clients.aosm_client.network_function_definition_groups.get( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=nfdg_name, + ) + print( + f"Network function definition group {nfdg_name} exists in resource" + f" group {resource_group_name}" + ) + except azure_exceptions.ResourceNotFoundError as ex: + print(f"Create Network Function Definition Group {nfdg_name}") + poller = self.api_clients.aosm_client.network_function_definition_groups.begin_create_or_update( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=nfdg_name, + parameters=NetworkFunctionDefinitionGroup(location=location), + ) + + # Asking for result waits for provisioning state Succeeded before carrying + # on + nfdg: NetworkFunctionDefinitionGroup = LongRunningOperation( + self.cli_ctx, "Creating Network Function Definition Group..." + )(poller) + + if nfdg.properties.provisioning_state != ProvisioningState.SUCCEEDED: + logger.debug( + "Failed to provision Network Function Definition Group: %s", + nfdg.name, + ) + raise RuntimeError( + "Creation of Network Function Definition Group proceeded, but the" + f" provisioning state returned is {nfdg.properties.provisioning_state}." + " \nAborting" + ) from ex + logger.debug( + "Provisioning state of %s: %s", nfdg_name, nfdg.properties.provisioning_state + ) + + def ensure_config_nfdg_exists( + self, + ): + """ + Ensures that the Network Function Definition Group exists. + + Finds the parameters from self.config + """ + self.ensure_nfdg_exists( + self.config.publisher_resource_group_name, + self.config.publisher_name, + self.config.nfdg_name, + self.config.location, + ) + + def ensure_config_nsd_exists( + self, + ): + """ + Ensures that the Network Service Design exists. + + Finds the parameters from self.config + """ + self.ensure_nsd_exists( + self.config.publisher_resource_group_name, + self.config.publisher_name, + self.config.nsd_name, + self.config.location, + ) + + def does_artifact_manifest_exist( + self, rg_name: str, publisher_name: str, store_name: str, manifest_name: str + ) -> bool: + try: + self.api_clients.aosm_client.artifact_manifests.get( + resource_group_name=rg_name, + publisher_name=publisher_name, + artifact_store_name=store_name, + artifact_manifest_name=manifest_name, + ) + logger.debug("Artifact manifest %s exists", manifest_name) + return True + except azure_exceptions.ResourceNotFoundError: + logger.debug("Artifact manifest %s does not exist", manifest_name) + return False + + def do_config_artifact_manifests_exist( + self, + ) -> bool: + """Returns True if all required manifests exist, False otherwise.""" + all_acr_mannys_exist = True + any_acr_mannys_exist: bool = not self.config.acr_manifest_names + + for manifest in self.config.acr_manifest_names: + acr_manny_exists: bool = self.does_artifact_manifest_exist( + rg_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + store_name=self.config.acr_artifact_store_name, + manifest_name=manifest, + ) + all_acr_mannys_exist &= acr_manny_exists + any_acr_mannys_exist |= acr_manny_exists + + if isinstance(self.config, VNFConfiguration): + sa_manny_exists: bool = self.does_artifact_manifest_exist( + rg_name=self.config.publisher_resource_group_name, + publisher_name=self.config.publisher_name, + store_name=self.config.blob_artifact_store_name, + manifest_name=self.config.sa_manifest_name, + ) + if all_acr_mannys_exist and sa_manny_exists: + return True + if any_acr_mannys_exist or sa_manny_exists: + raise AzCLIError( + "Only a subset of artifact manifest exists. Cannot proceed. Please delete" + " the NFDV or NSDV as appropriate using the `az aosm nfd delete` or " + "`az aosm nsd delete` command." + ) + return False + + return all_acr_mannys_exist + + def ensure_nsd_exists( + self, + resource_group_name: str, + publisher_name: str, + nsd_name: str, + location: str, + ): + """ + Ensures that the network service design group exists in the resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param publisher_name: The name of the publisher. + :type publisher_name: str + :param nsd_name: The name of the network service design group. + :type nsd_name: str + :param location: The location of the network service design group. + :type location: str + """ + print( + f"Creating Network Service Design {nsd_name} if it does not exist", + ) + logger.info( + "Creating Network Service Design %s if it does not exist", + nsd_name, + ) + poller = self.api_clients.aosm_client.network_service_design_groups.begin_create_or_update( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=nsd_name, + parameters=NetworkServiceDesignGroup(location=location), + ) + LongRunningOperation(self.cli_ctx, "Creating Network Service Design...")(poller) + + def resource_exists_by_name(self, rg_name: str, resource_name: str) -> bool: + """ + Determine if a resource with the given name exists. No checking is done as + to the type. + + :param resource_name: The name of the resource to check. + """ + logger.debug("Check if %s exists", resource_name) + resources = self.api_clients.resource_client.resources.list_by_resource_group( + resource_group_name=rg_name + ) + + resource_exists = False + + for resource in resources: + if resource.name == resource_name: + resource_exists = True + break + + return resource_exists diff --git a/src/aosm/azext_aosm/generate_nfd/__init__.py b/src/aosm/azext_aosm/generate_nfd/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py b/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py new file mode 100644 index 00000000000..2c55558c288 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py @@ -0,0 +1,850 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains a class for generating CNF NFDs and associated resources.""" +import json +import re +import shutil +import tarfile +import tempfile +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Dict, Iterator, List, Optional, Tuple + +import yaml +from azure.cli.core.azclierror import FileOperationError, InvalidTemplateError +from jinja2 import StrictUndefined, Template +from knack.log import get_logger + +from azext_aosm._configuration import CNFConfiguration, HelmPackageConfig +from azext_aosm.generate_nfd.nfd_generator_base import NFDGenerator +from azext_aosm.util.constants import ( + CNF_DEFINITION_BICEP_TEMPLATE_FILENAME, + CNF_DEFINITION_JINJA2_SOURCE_TEMPLATE_FILENAME, + CNF_MANIFEST_BICEP_TEMPLATE_FILENAME, + CNF_MANIFEST_JINJA2_SOURCE_TEMPLATE_FILENAME, + CNF_VALUES_SCHEMA_FILENAME, + CONFIG_MAPPINGS_DIR_NAME, + DEPLOYMENT_PARAMETER_MAPPING_REGEX, + DEPLOYMENT_PARAMETERS_FILENAME, + GENERATED_VALUES_MAPPINGS_DIR_NAME, + IMAGE_NAME_AND_VERSION_REGEX, + IMAGE_PATH_REGEX, + IMAGE_PULL_SECRETS_START_STRING, + IMAGE_START_STRING, + SCHEMA_PREFIX, + SCHEMAS_DIR_NAME, +) +from azext_aosm.util.utils import input_ack + +logger = get_logger(__name__) + + +@dataclass +class Artifact: + """Information about an artifact.""" + + name: str + version: str + + +@dataclass +class NFApplicationConfiguration: # pylint: disable=too-many-instance-attributes + name: str + chartName: str + chartVersion: str + releaseName: str + dependsOnProfile: List[str] + registryValuesPaths: List[str] + imagePullSecretsValuesPaths: List[str] + valueMappingsFile: str + + def __post_init__(self): + """Format the fields based on the NFDV validation rules.""" + self._format_name() + self._format_release_name() + + def _format_name(self): + """ + Format the name field. + + The name should start with a alphabetic character, have alphanumeric characters + or '-' in-between and end with alphanumerc character, and be less than 64 + characters long. See NfdVersionValidationHelper.cs in pez codebase + """ + # Replace any non (alphanumeric or '-') characters with '-' + self.name = re.sub("[^0-9a-zA-Z-]+", "-", self.name) + # Strip leading or trailing - + self.name = self.name.strip("-") + self.name = self.name[:64] + + if not self.name: + raise InvalidTemplateError( + "The name field of the NF application configuration for helm package " + f"{self.chartName} is empty after removing invalid characters. " + "Valid characters are alphanumeric and '-'. Please fix this in the name" + " field for the helm package in your input config file." + ) + + def _format_release_name(self): + """ + Format release name. + + It must consist of lower case alphanumeric characters, '-' or '.', and must + start and end with an alphanumeric character See + AzureArcKubernetesRuleBuilderExtensions.cs and + AzureArcKubernetesNfValidationMessage.cs in pez codebase + """ + self.releaseName = self.releaseName.lower() + # Replace any non (alphanumeric or '-' or '.') characters with '-' + self.releaseName = re.sub("[^0-9a-z-.]+", "-", self.releaseName) + # Strip leading - or . + self.releaseName = self.releaseName.strip("-") + self.releaseName = self.releaseName.strip(".") + if not self.releaseName: + raise InvalidTemplateError( + "The releaseName field of the NF application configuration for helm " + f"chart {self.chartName} is empty after formatting and removing invalid" + "characters. Valid characters are alphanumeric, -.' and '-' and the " + "releaseName must start and end with an alphanumeric character. The " + "value of this field is taken from Chart.yaml within the helm package. " + "Please fix up the helm package. Before removing invalid characters" + f", the releaseName was {self.chartName}." + ) + + +@dataclass +class ImageInfo: + parameter: List[str] + name: str + version: str + + +class CnfNfdGenerator(NFDGenerator): # pylint: disable=too-many-instance-attributes + """ + CNF NFD Generator. + + This takes a config file, and outputs: + - A bicep file for the NFDV + - Parameters files that are used by the NFDV bicep file, these are the + deployParameters and the mapping profiles of those deploy parameters + - A bicep file for the Artifact manifests + """ + + def __init__(self, config: CNFConfiguration, interactive: bool = False): + """ + Create a new CNF NFD Generator. + + Interactive parameter is only used if the user wants to generate the values + mapping file from the values.yaml in the helm package, and also requires the + mapping file in config to be blank. + """ + self.config = config + self.nfd_jinja2_template_path = ( + Path(__file__).parent + / "templates" + / CNF_DEFINITION_JINJA2_SOURCE_TEMPLATE_FILENAME + ) + self.manifest_jinja2_template_path = ( + Path(__file__).parent + / "templates" + / CNF_MANIFEST_JINJA2_SOURCE_TEMPLATE_FILENAME + ) + self.output_directory: Path = self.config.output_directory_for_build + self._cnfd_bicep_path = ( + self.output_directory / CNF_DEFINITION_BICEP_TEMPLATE_FILENAME + ) + self._tmp_dir: Optional[Path] = None + + self.artifacts: List[Artifact] = [] + self.nf_application_configurations: List[NFApplicationConfiguration] = [] + self.deployment_parameter_schema: Dict[str, Any] = SCHEMA_PREFIX + self.interactive = interactive + + def generate_nfd(self) -> None: + """Generate a CNF NFD which comprises a group, an Artifact Manifest and an NFDV.""" + + # Create temporary directory. + with tempfile.TemporaryDirectory() as tmpdirname: + self._tmp_dir = Path(tmpdirname) + try: + for helm_package in self.config.helm_packages: + # Unpack the chart into the tmp directory + assert isinstance(helm_package, HelmPackageConfig) + + self._extract_chart(Path(helm_package.path_to_chart)) + + # TODO: Validate charts + + # Create a chart mapping schema if none has been passed in. + if not helm_package.path_to_mappings: + self._generate_chart_value_mappings(helm_package) + + # Get schema for each chart + # (extract mappings and relevant parts of the schema) + # + Add that schema to the big schema. + self.deployment_parameter_schema["properties"].update( + self._get_chart_mapping_schema(helm_package) + ) + + # Get all image line matches for files in the chart. + # Do this here so we don't have to do it multiple times. + image_line_matches = self._find_image_parameter_from_chart( + helm_package + ) + + # Creates a flattened list of image registry paths to prevent set error + image_registry_paths: List[str] = [] + for image_info in image_line_matches: + image_registry_paths += image_info.parameter + + # Generate the NF application configuration for the chart + # passed to jinja2 renderer to render bicep template + self.nf_application_configurations.append( + self._generate_nf_application_config( + helm_package, + image_registry_paths, + self._find_image_pull_secrets_parameter_from_chart( + helm_package + ), + ) + ) + # Workout the list of artifacts for the chart and + # update the list for the NFD with any unique artifacts. + chart_artifacts = self._get_artifact_list( + helm_package, image_line_matches + ) + self.artifacts += [ + a for a in chart_artifacts if a not in self.artifacts + ] + self._write_nfd_bicep_file() + self._write_schema_to_file() + self._write_manifest_bicep_file() + self._copy_to_output_directory() + print( + f"Generated NFD bicep template created in {self.output_directory}" + ) + print( + "Please review these templates. When you are happy with them run " + "`az aosm nfd publish` with the same arguments." + ) + except InvalidTemplateError as e: + raise e + + @property + def nfd_bicep_path(self) -> Optional[Path]: + """Returns the path to the bicep file for the NFD if it has been created.""" + if self._cnfd_bicep_path.exists(): + return self._cnfd_bicep_path + return None + + def _extract_chart(self, path: Path) -> None: + """ + Extract the chart into the tmp directory. + + :param path: The path to helm package + """ + assert self._tmp_dir + + logger.debug("Extracting helm package %s", path) + + file_extension = path.suffix + if file_extension in (".gz", ".tgz"): + with tarfile.open(path, "r:gz") as tar: + tar.extractall(path=self._tmp_dir) + + elif file_extension == ".tar": + with tarfile.open(path, "r:") as tar: + tar.extractall(path=self._tmp_dir) + + else: + raise InvalidTemplateError( + f"ERROR: The helm package '{path}' is not a .tgz, .tar or .tar.gz file." + " Please fix this and run the command again." + ) + + def _generate_chart_value_mappings(self, helm_package: HelmPackageConfig) -> None: + """ + Optional function to create a chart value mappings file with every value being a deployParameter. + + Expected use when a helm chart is very simple and user wants every value to be a + deployment parameter. + """ + assert self._tmp_dir + logger.debug( + "Creating chart value mappings file for %s", helm_package.path_to_chart + ) + print(f"Creating chart value mappings file for {helm_package.path_to_chart}.") + + # Get all the values files in the chart + top_level_values_yaml = self._read_top_level_values_yaml(helm_package) + + mapping_to_write = self._replace_values_with_deploy_params( + top_level_values_yaml, None + ) + + # Write the mapping to a file + mapping_directory: Path = self._tmp_dir / GENERATED_VALUES_MAPPINGS_DIR_NAME + mapping_directory.mkdir(exist_ok=True) + mapping_filepath = ( + mapping_directory / f"{helm_package.name}-generated-mapping.yaml" + ) + with open(mapping_filepath, "w", encoding="UTF-8") as mapping_file: + yaml.dump(mapping_to_write, mapping_file) + + # Update the config that points to the mapping file + helm_package.path_to_mappings = str(mapping_filepath) + + def _read_top_level_values_yaml( + self, helm_package: HelmPackageConfig + ) -> Dict[str, Any]: + """ + Return a dictionary of the values.yaml|yml read from the root of the helm package. + + :param helm_package: The helm package to look in + :type helm_package: HelmPackageConfig + :raises FileOperationError: if no values.yaml|yml found + :return: A dictionary of the yaml read from the file + :rtype: Dict[str, Any] + """ + assert self._tmp_dir + for file in Path(self._tmp_dir / helm_package.name).iterdir(): + if file.name in ("values.yaml", "values.yml"): + with file.open(encoding="UTF-8") as values_file: + values_yaml = yaml.safe_load(values_file) + return values_yaml + + raise FileOperationError( + "Cannot find top level values.yaml/.yml file in Helm package." + ) + + def _write_manifest_bicep_file(self) -> None: + """Write the bicep file for the Artifact Manifest to the temp directory.""" + assert self._tmp_dir + + with open(self.manifest_jinja2_template_path, "r", encoding="UTF-8") as f: + template: Template = Template( + f.read(), + undefined=StrictUndefined, + ) + + bicep_contents: str = template.render( + artifacts=self.artifacts, + ) + + path = self._tmp_dir / CNF_MANIFEST_BICEP_TEMPLATE_FILENAME + with open(path, "w", encoding="utf-8") as f: + f.write(bicep_contents) + + logger.info("Created artifact manifest bicep template: %s", path) + + def _write_nfd_bicep_file(self) -> None: + """Write the bicep file for the NFD to the temp directory.""" + assert self._tmp_dir + with open(self.nfd_jinja2_template_path, "r", encoding="UTF-8") as f: + template: Template = Template( + f.read(), + undefined=StrictUndefined, + ) + + bicep_contents: str = template.render( + nf_application_configurations=self.nf_application_configurations, + ) + + path = self._tmp_dir / CNF_DEFINITION_BICEP_TEMPLATE_FILENAME + with open(path, "w", encoding="utf-8") as f: + f.write(bicep_contents) + + logger.info("Created NFD bicep template: %s", path) + + def _write_schema_to_file(self) -> None: + """Write the schema to file deploymentParameters.json to the temp directory.""" + logger.debug("Create deploymentParameters.json") + assert self._tmp_dir + + full_schema = self._tmp_dir / DEPLOYMENT_PARAMETERS_FILENAME + with open(full_schema, "w", encoding="UTF-8") as f: + json.dump(self.deployment_parameter_schema, f, indent=4) + + logger.debug("%s created", full_schema) + + def _copy_to_output_directory(self) -> None: + """ + Copy files from the temp directory to the output directory. + + Files are the config mappings, schema and bicep templates (artifact manifest and + NFDV). + """ + assert self._tmp_dir + + logger.info("Create NFD bicep %s", self.output_directory) + + Path(self.output_directory / SCHEMAS_DIR_NAME).mkdir( + parents=True, exist_ok=True + ) + + # Copy the nfd and the manifest bicep files to the output directory + shutil.copy( + self._tmp_dir / CNF_DEFINITION_BICEP_TEMPLATE_FILENAME, + self.output_directory, + ) + shutil.copy( + self._tmp_dir / CNF_MANIFEST_BICEP_TEMPLATE_FILENAME, self.output_directory + ) + + # Copy any generated values mappings YAML files to the corresponding directory in + # the output directory so that the user can edit them and re-run the build if + # required + if Path(self._tmp_dir / GENERATED_VALUES_MAPPINGS_DIR_NAME).exists(): + shutil.copytree( + self._tmp_dir / GENERATED_VALUES_MAPPINGS_DIR_NAME, + self.output_directory / GENERATED_VALUES_MAPPINGS_DIR_NAME, + ) + + # Copy the JSON config mappings and deploymentParameters schema that are used + # for the NFD to the output directory + shutil.copytree( + self._tmp_dir / CONFIG_MAPPINGS_DIR_NAME, + self.output_directory / CONFIG_MAPPINGS_DIR_NAME, + dirs_exist_ok=True, + ) + shutil.copy( + self._tmp_dir / DEPLOYMENT_PARAMETERS_FILENAME, + self.output_directory / SCHEMAS_DIR_NAME / DEPLOYMENT_PARAMETERS_FILENAME, + ) + + logger.info("Copied files to %s", self.output_directory) + + def _generate_nf_application_config( + self, + helm_package: HelmPackageConfig, + image_registry_path: List[str], + image_pull_secret_line_matches: List[str], + ) -> NFApplicationConfiguration: + """Generate NF application config.""" + (name, version) = self._get_chart_name_and_version(helm_package) + + registry_values_paths = set(image_registry_path) + image_pull_secrets_values_paths = set(image_pull_secret_line_matches) + + return NFApplicationConfiguration( + name=helm_package.name, + chartName=name, + chartVersion=version, + releaseName=name, + dependsOnProfile=helm_package.depends_on, + registryValuesPaths=list(registry_values_paths), + imagePullSecretsValuesPaths=list(image_pull_secrets_values_paths), + valueMappingsFile=self._jsonify_value_mappings(helm_package), + ) + + @staticmethod + def _find_yaml_files(directory: Path) -> Iterator[Path]: + """ + Find all yaml files recursively in given directory. + + :param directory: The directory to search. + """ + yield from directory.glob("**/*.yaml") + yield from directory.glob("**/*.yml") + + def _find_image_parameter_from_chart( + self, helm_package_config: HelmPackageConfig + ) -> List[ImageInfo]: + """ + Find pattern matches in Helm chart for the names of the image parameters. + + :param helm_package: The helm package config. + + Returns list of tuples containing the list of image + paths and the name and version of the image. e.g. (Values.foo.bar.repoPath, foo, + 1.2.3) + """ + assert self._tmp_dir + chart_dir = self._tmp_dir / helm_package_config.name + matches = [] + path = [] + + for file in self._find_yaml_files(chart_dir): + with open(file, "r", encoding="UTF-8") as f: + logger.debug("Searching for %s in %s", IMAGE_START_STRING, file) + for line in f: + if IMAGE_START_STRING in line: + logger.debug("Found %s in %s", IMAGE_START_STRING, line) + path = re.findall(IMAGE_PATH_REGEX, line) + + # If "image:", search for chart name and version + name_and_version = re.search(IMAGE_NAME_AND_VERSION_REGEX, line) + logger.debug( + "Regex match for name and version is %s", + name_and_version, + ) + + if name_and_version and len(name_and_version.groups()) == 2: + logger.debug( + "Found image name and version %s %s", + name_and_version.group("name"), + name_and_version.group("version"), + ) + matches.append( + ImageInfo( + path, + name_and_version.group("name"), + name_and_version.group("version"), + ) + ) + else: + logger.debug("No image name and version found") + return matches + + def _find_image_pull_secrets_parameter_from_chart( + self, helm_package_config: HelmPackageConfig + ) -> List[str]: + """ + Find pattern matches in Helm chart for the ImagePullSecrets parameter. + + :param helm_package: The helm package config. + + Returns list of lists containing image pull + secrets paths, e.g. Values.foo.bar.imagePullSecret + """ + assert self._tmp_dir + chart_dir = self._tmp_dir / helm_package_config.name + matches = [] + path = [] + + for file in self._find_yaml_files(chart_dir): + with open(file, "r", encoding="UTF-8") as f: + logger.debug( + "Searching for %s in %s", IMAGE_PULL_SECRETS_START_STRING, file + ) + for line in f: + if IMAGE_PULL_SECRETS_START_STRING in line: + logger.debug( + "Found %s in %s", IMAGE_PULL_SECRETS_START_STRING, line + ) + path = re.findall(IMAGE_PATH_REGEX, line) + matches += path + return matches + + def _get_artifact_list( + self, + helm_package: HelmPackageConfig, + image_line_matches: List[ImageInfo], + ) -> List[Artifact]: + """ + Get the list of artifacts for the chart. + + :param helm_package: The helm package config. + :param image_line_matches: The list of image line matches. + """ + artifact_list = [] + (name, version) = self._get_chart_name_and_version(helm_package) + helm_artifact = Artifact(name, version) + + artifact_list.append(helm_artifact) + for image_info in image_line_matches: + artifact_list.append(Artifact(image_info.name, image_info.version)) + + return artifact_list + + def _get_chart_mapping_schema( + self, helm_package: HelmPackageConfig + ) -> Dict[Any, Any]: + """ + Get the schema for the non default values (those with {deploymentParameter...}). + Based on the user provided values schema. + + param helm_package: The helm package config. + """ + assert self._tmp_dir + logger.debug("Get chart mapping schema for %s", helm_package.name) + + mappings_path = helm_package.path_to_mappings + values_schema = self._tmp_dir / helm_package.name / CNF_VALUES_SCHEMA_FILENAME + if not Path(mappings_path).exists(): + raise InvalidTemplateError( + f"ERROR: The helm package '{helm_package.name}' does not have a valid values" + " mappings file. The file at '{helm_package.path_to_mappings}' does not exist." + "\nPlease fix this and run the command again." + ) + if not values_schema.exists(): + raise InvalidTemplateError( + f"ERROR: The helm package '{helm_package.name}' is missing {CNF_VALUES_SCHEMA_FILENAME}." + "\nPlease fix this and run the command again." + ) + + with open(mappings_path, "r", encoding="utf-8") as stream: + values_data = yaml.load(stream, Loader=yaml.SafeLoader) + + with open(values_schema, "r", encoding="utf-8") as f: + schema_data = json.load(f) + + try: + deploy_params_dict = self.traverse_dict( + values_data, DEPLOYMENT_PARAMETER_MAPPING_REGEX + ) + logger.debug("Deploy params dict is %s", deploy_params_dict) + new_schema = self.search_schema(deploy_params_dict, schema_data) + except KeyError as e: + raise InvalidTemplateError( + "ERROR: There is a problem with your schema or values for the helm" + f" package '{helm_package.name}'." + "\nPlease fix this and run the command again." + ) from e + + logger.debug("Generated chart mapping schema for %s", helm_package.name) + return new_schema + + @staticmethod + def traverse_dict( + dict_to_search: Dict[Any, Any], target_regex: str + ) -> Dict[str, List[str]]: + """ + Traverse the dictionary provided and return a dictionary of all the values that match the target regex, + with the key being the deploy parameter and the value being the path (as a list) to the value. + e.g. {"foo": ["global", "foo", "bar"]} + + :param d: The dictionary to traverse. + :param target: The regex to search for. + """ + + # pylint: disable=too-many-nested-blocks + @dataclass + class DictNode: + # The dictionary under this node + sub_dict: Dict[Any, Any] + + # The path to this node under the main dictionary + position_path: List[str] + + # Initialize the stack with the dictionary and an empty path + stack: List[DictNode] = [DictNode(dict_to_search, [])] + result = {} # Initialize empty dictionary to store the results + while stack: # While there are still items in the stack + # Pop the last item from the stack and unpack it into node (the dictionary) and path + node = stack.pop() + + # For each key-value pair in the popped item + for key, value in node.sub_dict.items(): + # If the value is a dictionary + if isinstance(value, dict): + # Add the dictionary to the stack with the path + stack.append(DictNode(value, node.position_path + [key])) + + # If the value is a string + matches target regex + elif isinstance(value, str): + # Take the match i.e, foo from {deployParameter.foo} + match = re.search(target_regex, value) + + # Add it to the result dictionary with its path as the value + if match: + result[match.group(1)] = node.position_path + [key] + + elif isinstance(value, list): + logger.debug("Found a list %s", value) + for item in value: + logger.debug("Found an item %s", item) + + if isinstance(item, str): + match = re.search(target_regex, item) + + if match: + result[match.group(1)] = node.position_path + [key] + + elif isinstance(item, dict): + stack.append(DictNode(item, node.position_path + [key])) + + elif isinstance(item, list): + # We should fix this but for now just log a warning and + # carry on + logger.warning( + "Values mapping file contains a list of lists " + "at path %s, which this tool cannot parse. " + "Please check the output configMappings and schemas " + "files and check that they are as required.", + node.position_path + [key], + ) + return result + + @staticmethod + def search_schema( + deployParams_paths: Dict[str, List[str]], full_schema + ) -> Dict[str, Dict[str, str]]: + """ + Search through the provided schema for the types of the deployment parameters. + This assumes that the type of the key will be the type of the deployment parameter. + e.g. if foo: {deployParameter.bar} and foo is type string, then bar is type string. + + Returns a dictionary of the deployment parameters in the format: + {"foo": {"type": "string"}, "bar": {"type": "string"}} + + param deployParams_paths: a dictionary of all the deploy parameters to search for, + with the key being the deploy parameter and the value being the + path to the value. + e.g. {"foo": ["global", "foo", "bar"]} + param full_schema: The schema to search through. + """ + new_schema = {} + no_schema_list = [] + for deploy_param, path_list in deployParams_paths.items(): + logger.debug( + "Searching for %s in schema at path %s", deploy_param, path_list + ) + node = full_schema + for path in path_list: + if "properties" in node.keys(): + logger.debug( + "Searching properties for %s in schema at path %s", + deploy_param, + path, + ) + node = node["properties"][path] + else: + logger.debug("No schema node found for %s", deploy_param) + no_schema_list.append(deploy_param) + new_schema.update({deploy_param: {"type": "string"}}) + if deploy_param not in new_schema: + param_type = node.get("type", None) + if param_type == "array": + # If the type is an array, we need to get the type of the items. + # (This currently only supports a single type, not a list of types. + # If a list is provided, we default to string.) + array_item_schema = node.get("items", {}) + if type(array_item_schema) is dict: + param_type = array_item_schema.get("type", None) + else: + logger.debug("Array item schema is not a dict (probably a list)") + param_type = None + if not param_type: + logger.debug("No type found for %s", deploy_param) + no_schema_list.append(deploy_param) + param_type = "string" + new_schema.update({deploy_param: {"type": param_type}}) + if no_schema_list: + logger.warning( + "No schema or type found for deployment parameter(s): %s", no_schema_list + ) + logger.warning( + "We default these parameters to type string. " + "Please edit schemas/%s in the output before publishing " + "if this is wrong", + DEPLOYMENT_PARAMETERS_FILENAME, + ) + return new_schema + + def _replace_values_with_deploy_params( + self, + values_yaml_dict, + param_prefix: Optional[str] = None, + ) -> Dict[Any, Any]: + """ + Given the yaml dictionary read from values.yaml, replace all the values with {deploymentParameter.keyname}. + + Thus creating a values mapping file if the user has not provided one in config. + """ + logger.debug("Replacing values with deploy parameters") + final_values_mapping_dict: Dict[Any, Any] = {} + for k, v in values_yaml_dict.items(): # pylint: disable=too-many-nested-blocks + # if value is a string and contains deployParameters. + logger.debug("Processing key %s", k) + param_name = k if param_prefix is None else f"{param_prefix}_{k}" + if isinstance(v, dict): + final_values_mapping_dict[k] = self._replace_values_with_deploy_params( + v, param_name + ) + elif isinstance(v, list): + final_values_mapping_dict[k] = [] + for index, item in enumerate(v): + param_name = ( + f"{param_prefix}_{k}_{index}" + if param_prefix + else f"{k}_{index}" + ) + if isinstance(item, dict): + final_values_mapping_dict[k].append( + self._replace_values_with_deploy_params(item, param_name) + ) + elif isinstance(item, (str, int, bool)) or not item: + if self.interactive: + if not input_ack( + "y", f"Expose parameter {param_name}? y/n " + ): + logger.debug("Excluding parameter %s", param_name) + final_values_mapping_dict[k].append(item) + continue + replacement_value = f"{{deployParameters.{param_name}}}" + final_values_mapping_dict[k].append(replacement_value) + else: + raise ValueError( + f"Found an unexpected type {type(item)} of key {k} in " + "values.yaml, cannot generate values mapping file." + ) + elif isinstance(v, (str, int, bool)) or not v: + # Replace the parameter with {deploymentParameter.keyname} + # If v is blank we don't know what type it is. Assuming it is an + # empty string (but do this after checking for dict and list) + if self.interactive: + # Interactive mode. Prompt user to include or exclude parameters + # This requires the enter key after the y/n input which isn't ideal + if not input_ack("y", f"Expose parameter {param_name}? y/n "): + logger.debug("Excluding parameter %s", param_name) + final_values_mapping_dict.update({k: v}) + continue + replacement_value = f"{{deployParameters.{param_name}}}" + + # add the schema for k (from the big schema) to the (smaller) schema + final_values_mapping_dict.update({k: replacement_value}) + else: + raise ValueError( + f"Found an unexpected type {type(v)} of key {k} in values.yaml, " + "cannot generate values mapping file." + ) + + return final_values_mapping_dict + + def _get_chart_name_and_version( + self, helm_package: HelmPackageConfig + ) -> Tuple[str, str]: + """Get the name and version of the chart.""" + assert self._tmp_dir + chart_path = self._tmp_dir / helm_package.name / "Chart.yaml" + + if not chart_path.exists(): + raise InvalidTemplateError( + f"There is no Chart.yaml file in the helm package '{helm_package.name}'. " + "\nPlease fix this and run the command again." + ) + + with open(chart_path, "r", encoding="utf-8") as f: + data = yaml.load(f, Loader=yaml.FullLoader) + if "name" in data and "version" in data: + chart_name = data["name"] + chart_version = data["version"] + else: + raise FileOperationError( + "A name or version is missing from Chart.yaml in the helm package" + f" '{helm_package.name}'." + "\nPlease fix this and run the command again." + ) + + return (chart_name, chart_version) + + def _jsonify_value_mappings(self, helm_package: HelmPackageConfig) -> str: + """Yaml->JSON values mapping file, then return the filename.""" + assert self._tmp_dir + mappings_yaml_file = helm_package.path_to_mappings + mappings_dir = self._tmp_dir / CONFIG_MAPPINGS_DIR_NAME + mappings_output_file = mappings_dir / f"{helm_package.name}-mappings.json" + + mappings_dir.mkdir(exist_ok=True) + + with open(mappings_yaml_file, "r", encoding="utf-8") as f: + data = yaml.load(f, Loader=yaml.FullLoader) + + with open(mappings_output_file, "w", encoding="utf-8") as file: + json.dump(data, file, indent=4) + + logger.debug("Generated parameter mappings for %s", helm_package.name) + return f"{helm_package.name}-mappings.json" diff --git a/src/aosm/azext_aosm/generate_nfd/nfd_generator_base.py b/src/aosm/azext_aosm/generate_nfd/nfd_generator_base.py new file mode 100644 index 00000000000..4141665dfdf --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/nfd_generator_base.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains a base class for generating NFDs.""" +from abc import ABC, abstractmethod +from pathlib import Path +from typing import Optional + +from knack.log import get_logger + +logger = get_logger(__name__) + + +class NFDGenerator(ABC): + """A class for generating an NFD from a config file.""" + + @abstractmethod + def generate_nfd(self) -> None: + ... + + @property + @abstractmethod + def nfd_bicep_path(self) -> Optional[Path]: + ... diff --git a/src/aosm/azext_aosm/generate_nfd/templates/cnfartifactmanifest.bicep.j2 b/src/aosm/azext_aosm/generate_nfd/templates/cnfartifactmanifest.bicep.j2 new file mode 100644 index 00000000000..0f0eeb99767 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/templates/cnfartifactmanifest.bicep.j2 @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an Artifact Manifest for a CNF +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestName string + +// Created by the az aosm definition publish command before the template is deployed +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// Created by the az aosm definition publish command before the template is deployed +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +resource acrArtifactManifest 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = { + parent: acrArtifactStore + name: acrManifestName + location: location + properties: { + artifacts: [ + {%- for artifact in artifacts %} + { + artifactName: '{{ artifact.name }}' + artifactType: 'OCIArtifact' + artifactVersion: '{{ artifact.version }}' + } + {%- endfor %} + ] + } +} diff --git a/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 b/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 new file mode 100644 index 00000000000..4eeadfe6338 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an NF definition for a CNF +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Network Function Definition Group') +param nfDefinitionGroup string +@description('The version of the NFDV you want to deploy, in format A.B.C') +param nfDefinitionVersion string + +// Created by the az aosm definition publish command before the template is deployed +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// Created by the az aosm definition publish command before the template is deployed +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created by the az aosm definition publish command before the template is deployed +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: nfDefinitionGroup +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' = { + parent: nfdg + name: nfDefinitionVersion + location: location + properties: { + // versionState should be changed to 'Active' once it is finalized. + versionState: 'Preview' + {#- Note that all paths in bicep must be specified using the forward slash #} + {#- (/) character even if running on Windows. #} + {#- See https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/modules#local-file #} + deployParameters: string(loadJsonContent('schemas/deploymentParameters.json')) + networkFunctionType: 'ContainerizedNetworkFunction' + networkFunctionTemplate: { + nfviType: 'AzureArcKubernetes' + networkFunctionApplications: [ + {%- for configuration in nf_application_configurations %} + { + artifactType: 'HelmPackage' + name: '{{ configuration.name }}' + dependsOnProfile: { + installDependsOn: {{ configuration.dependsOnProfile }} + } + artifactProfile: { + artifactStore: { + id: acrArtifactStore.id + } + helmArtifactProfile: { + helmPackageName: '{{ configuration.chartName }}' + helmPackageVersionRange: '{{ configuration.chartVersion }}' + registryValuesPaths: {{ configuration.registryValuesPaths }} + imagePullSecretsValuesPaths: {{ configuration.imagePullSecretsValuesPaths }} + } + } + deployParametersMappingRuleProfile: { + applicationEnablement: 'Enabled' + helmMappingRuleProfile: { + releaseNamespace: '{{ configuration.releaseName }}' + releaseName: '{{ configuration.releaseName }}' + helmPackageVersion: '{{ configuration.chartVersion }}' + values: string(loadJsonContent('configMappings/{{ configuration.valueMappingsFile }}')) + } + } + } + {%- endfor %} + ] + } + } +} diff --git a/src/aosm/azext_aosm/generate_nfd/templates/vnfartifactmanifests.bicep b/src/aosm/azext_aosm/generate_nfd/templates/vnfartifactmanifests.bicep new file mode 100644 index 00000000000..109cca9c766 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/templates/vnfartifactmanifests.bicep @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an NF definition for a VNF +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Storage Account-backed Artifact Store, deployed under the publisher.') +param saArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestName string +@description('Name of the manifest to deploy for the Storage Account-backed Artifact Store') +param saManifestName string +@description('Name of Network Function. Used predominantly as a prefix for other variable names') +param nfName string +@description('The version that you want to name the NFM VHD artifact, in format A-B-C. e.g. 6-13-0') +param vhdVersion string +@description('The name under which to store the ARM template') +param armTemplateVersion string + +// Created by the az aosm definition publish command before the template is deployed +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// Created by the az aosm definition publish command before the template is deployed +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created by the az aosm definition publish command before the template is deployed +resource saArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: saArtifactStoreName +} + +resource saArtifactManifest 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = { + parent: saArtifactStore + name: saManifestName + location: location + properties: { + artifacts: [ + { + artifactName: '${nfName}-vhd' + artifactType: 'VhdImageFile' + artifactVersion: vhdVersion + } + ] + } +} + +resource acrArtifactManifest 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = { + parent: acrArtifactStore + name: acrManifestName + location: location + properties: { + artifacts: [ + { + artifactName: '${nfName}-arm-template' + artifactType: 'ArmTemplate' + artifactVersion: armTemplateVersion + } + ] + } +} diff --git a/src/aosm/azext_aosm/generate_nfd/templates/vnfdefinition.bicep b/src/aosm/azext_aosm/generate_nfd/templates/vnfdefinition.bicep new file mode 100644 index 00000000000..9deaeffd182 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/templates/vnfdefinition.bicep @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an NF definition for a VNF +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Storage Account-backed Artifact Store, deployed under the publisher.') +param saArtifactStoreName string +@description('Name of Network Function. Used predominantly as a prefix for other variable names') +param nfName string +@description('Name of an existing Network Function Definition Group') +param nfDefinitionGroup string +@description('The version of the NFDV you want to deploy, in format A.B.C') +param nfDefinitionVersion string +@description('The version that you want to name the NFM VHD artifact, in format A-B-C. e.g. 6-13-0') +param vhdVersion string +@description('The version that you want to name the NFM template artifact, in format A.B.C. e.g. 6.13.0. If testing for development, you can use any numbers you like.') +param armTemplateVersion string + +// Created by the az aosm definition publish command before the template is deployed +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// Created by the az aosm definition publish command before the template is deployed +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created by the az aosm definition publish command before the template is deployed +resource saArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: saArtifactStoreName +} + +// Created by the az aosm definition publish command before the template is deployed +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: nfDefinitionGroup +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' = { + parent: nfdg + name: nfDefinitionVersion + location: location + properties: { + // versionState should be changed to 'Active' once it is finalized. + versionState: 'Preview' + deployParameters: string(loadJsonContent('schemas/deploymentParameters.json')) + networkFunctionType: 'VirtualNetworkFunction' + networkFunctionTemplate: { + nfviType: 'AzureCore' + networkFunctionApplications: [ + { + artifactType: 'VhdImageFile' + name: '${nfName}Image' + dependsOnProfile: null + artifactProfile: { + vhdArtifactProfile: { + vhdName: '${nfName}-vhd' + vhdVersion: vhdVersion + } + artifactStore: { + id: saArtifactStore.id + } + } + // mapping deploy param vals to vals required by this network function application object + deployParametersMappingRuleProfile: { + vhdImageMappingRuleProfile: { + userConfiguration: string(loadJsonContent('configMappings/vhdParameters.json')) + } + // ?? + applicationEnablement: 'Unknown' + } + } + { + artifactType: 'ArmTemplate' + name: nfName + dependsOnProfile: null + artifactProfile: { + templateArtifactProfile: { + templateName: '${nfName}-arm-template' + templateVersion: armTemplateVersion + } + artifactStore: { + id: acrArtifactStore.id + } + } + deployParametersMappingRuleProfile: { + templateMappingRuleProfile: { + templateParameters: string(loadJsonContent('configMappings/templateParameters.json')) + } + applicationEnablement: 'Unknown' + } + } + ] + } + } +} diff --git a/src/aosm/azext_aosm/generate_nfd/vnf_nfd_generator.py b/src/aosm/azext_aosm/generate_nfd/vnf_nfd_generator.py new file mode 100644 index 00000000000..e415817594e --- /dev/null +++ b/src/aosm/azext_aosm/generate_nfd/vnf_nfd_generator.py @@ -0,0 +1,340 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains a class for generating VNF NFDs and associated resources.""" + +import json +import shutil +import tempfile +from functools import cached_property +from pathlib import Path +from typing import Any, Dict, Optional + +from knack.log import get_logger + +from azext_aosm._configuration import ArtifactConfig, VNFConfiguration +from azext_aosm.generate_nfd.nfd_generator_base import NFDGenerator +from azext_aosm.util.constants import ( + CONFIG_MAPPINGS_DIR_NAME, + DEPLOYMENT_PARAMETERS_FILENAME, + EXTRA_VHD_PARAMETERS, + OPTIONAL_DEPLOYMENT_PARAMETERS_FILENAME, + OPTIONAL_DEPLOYMENT_PARAMETERS_HEADING, + SCHEMA_PREFIX, + SCHEMAS_DIR_NAME, + TEMPLATE_PARAMETERS_FILENAME, + VHD_PARAMETERS_FILENAME, + VNF_DEFINITION_BICEP_TEMPLATE_FILENAME, + VNF_MANIFEST_BICEP_TEMPLATE_FILENAME, +) +from azext_aosm.util.utils import input_ack, snake_case_to_camel_case + +logger = get_logger(__name__) + +# Different types are used in ARM templates and NFDs. The list accepted by NFDs is +# documented in the AOSM meta-schema. This will be published in the future but for now +# can be found in +# https://microsoft.sharepoint.com/:w:/t/NSODevTeam/Ec7ovdKroSRIv5tumQnWIE0BE-B2LykRcll2Qb9JwfVFMQ +ARM_TO_JSON_PARAM_TYPES: Dict[str, str] = { + "int": "integer", + "securestring": "string", + "bool": "boolean", +} + + +class VnfNfdGenerator(NFDGenerator): + # pylint: disable=too-many-instance-attributes + """ + VNF NFD Generator. + + This takes a source ARM template and a config file, and outputs: + - A bicep file for the NFDV + - Parameters files that are used by the NFDV bicep file, these are the + deployParameters and the mapping profiles of those deploy parameters + - A bicep file for the Artifact manifests + + @param order_params: whether to order the deployment and template output parameters + with those without a default first, then those with a default. + Those without a default will definitely be required to be + exposed, those with a default may not be. + @param interactive: whether to prompt the user to confirm the parameters to be + exposed. + """ + + def __init__( + self, config: VNFConfiguration, order_params: bool, interactive: bool + ): + self.config = config + + assert isinstance(self.config.arm_template, ArtifactConfig) + assert self.config.arm_template.file_path + + self.arm_template_path = Path(self.config.arm_template.file_path) + self.output_directory: Path = self.config.output_directory_for_build + + self._vnfd_bicep_path = Path( + self.output_directory, VNF_DEFINITION_BICEP_TEMPLATE_FILENAME + ) + self._manifest_bicep_path = Path( + self.output_directory, VNF_MANIFEST_BICEP_TEMPLATE_FILENAME + ) + self.order_params = order_params + self.interactive = interactive + self._tmp_dir: Optional[Path] = None + self.image_name = f"{self.config.nf_name}Image" + + def generate_nfd(self) -> None: + """ + Generate a VNF NFD which comprises an group, an Artifact Manifest and a NFDV. + + Create a bicep template for an NFD from the ARM template for the VNF. + """ + # Create temporary directory. + with tempfile.TemporaryDirectory() as tmpdirname: + self._tmp_dir = Path(tmpdirname) + + self._create_parameter_files() + self._copy_to_output_directory() + print( + f"Generated NFD bicep templates created in {self.output_directory}" + ) + print( + "Please review these templates. When you are happy with them run " + "`az aosm nfd publish` with the same arguments." + ) + + @property + def nfd_bicep_path(self) -> Optional[Path]: + """Returns the path to the bicep file for the NFD if it has been created.""" + if self._vnfd_bicep_path.exists(): + return self._vnfd_bicep_path + return None + + @property + def manifest_bicep_path(self) -> Optional[Path]: + """Returns the path to the bicep file for the NFD if it has been created.""" + if self._manifest_bicep_path.exists(): + return self._manifest_bicep_path + return None + + @cached_property + def vm_parameters(self) -> Dict[str, Any]: + """The parameters from the VM ARM template.""" + with open(self.arm_template_path, "r", encoding="utf-8") as _file: + data = json.load(_file) + if "parameters" in data: + parameters: Dict[str, Any] = data["parameters"] + else: + print( + "No parameters found in the template provided. " + "Your NFD will have no deployParameters" + ) + parameters = {} + + return parameters + + @property + def vm_parameters_ordered(self) -> Dict[str, Any]: + """The parameters from the VM ARM template, ordered as those without defaults then those with.""" + vm_parameters_no_default: Dict[str, Any] = {} + vm_parameters_with_default: Dict[str, Any] = {} + has_default_field: bool = False + has_default: bool = False + + for key in self.vm_parameters: + # Order parameters into those with and without defaults + has_default_field = "defaultValue" in self.vm_parameters[key] + has_default = ( + has_default_field + and not self.vm_parameters[key]["defaultValue"] == "" + ) + + if has_default: + vm_parameters_with_default[key] = self.vm_parameters[key] + else: + vm_parameters_no_default[key] = self.vm_parameters[key] + + return {**vm_parameters_no_default, **vm_parameters_with_default} + + def _create_parameter_files(self) -> None: + """Create the deployment, template and VHD parameter files.""" + assert self._tmp_dir + tmp_schemas_directory: Path = self._tmp_dir / SCHEMAS_DIR_NAME + tmp_schemas_directory.mkdir() + self.write_deployment_parameters(tmp_schemas_directory) + + tmp_mappings_directory: Path = self._tmp_dir / CONFIG_MAPPINGS_DIR_NAME + tmp_mappings_directory.mkdir() + self.write_template_parameters(tmp_mappings_directory) + self.write_vhd_parameters(tmp_mappings_directory) + + def write_deployment_parameters(self, directory: Path) -> None: + """ + Write out the NFD deploymentParameters.json file to `directory` + + :param directory: The directory to put this file in. + """ + logger.debug("Create deploymentParameters.json") + + nfd_parameters = {} + nfd_parameters_with_default = {} + vm_parameters_to_exclude = [] + + vm_parameters = ( + self.vm_parameters_ordered + if self.order_params + else self.vm_parameters + ) + + for key in vm_parameters: + if key == self.config.image_name_parameter: + # There is only one correct answer for the image name, so don't ask the + # user, instead it is hardcoded in config mappings. + continue + + # Order parameters into those without and then with defaults + has_default_field = "defaultValue" in self.vm_parameters[key] + has_default = ( + has_default_field + and not self.vm_parameters[key]["defaultValue"] == "" + ) + + if self.interactive and has_default: + # Interactive mode. Prompt user to include or exclude parameters + # This requires the enter key after the y/n input which isn't ideal + if not input_ack("y", f"Expose parameter {key}? y/n "): + logger.debug("Excluding parameter %s", key) + vm_parameters_to_exclude.append(key) + continue + + # Map ARM parameter types to JSON parameter types accepted by AOSM + arm_type = self.vm_parameters[key]["type"] + json_type = ARM_TO_JSON_PARAM_TYPES.get(arm_type.lower(), arm_type) + + if has_default: + nfd_parameters_with_default[key] = {"type": json_type} + + nfd_parameters[key] = {"type": json_type} + + # Now we are out of the vm_parameters loop, we can remove the excluded + # parameters so they don't get included in templateParameters.json + # Remove from both ordered and unordered dicts + for key in vm_parameters_to_exclude: + self.vm_parameters.pop(key, None) + + deployment_parameters_path = directory / DEPLOYMENT_PARAMETERS_FILENAME + + # Heading for the deployParameters schema + deploy_parameters_full: Dict[str, Any] = SCHEMA_PREFIX + deploy_parameters_full["properties"].update(nfd_parameters) + + with open(deployment_parameters_path, "w", encoding="utf-8") as _file: + _file.write(json.dumps(deploy_parameters_full, indent=4)) + + logger.debug("%s created", deployment_parameters_path) + if self.order_params: + print( + "Deployment parameters for the generated NFDV are ordered by those " + "without defaults first to make it easier to choose which to expose." + ) + + # Extra output file to help the user know which parameters are optional + if not self.interactive: + if nfd_parameters_with_default: + optional_deployment_parameters_path = ( + directory / OPTIONAL_DEPLOYMENT_PARAMETERS_FILENAME + ) + with open( + optional_deployment_parameters_path, "w", encoding="utf-8" + ) as _file: + _file.write(OPTIONAL_DEPLOYMENT_PARAMETERS_HEADING) + _file.write( + json.dumps(nfd_parameters_with_default, indent=4) + ) + print( + "Optional ARM parameters detected. Created " + f"{OPTIONAL_DEPLOYMENT_PARAMETERS_FILENAME} to help you choose which " + "to expose." + ) + + def write_template_parameters(self, directory: Path) -> None: + """ + Write out the NFD templateParameters.json file to `directory`. + + :param directory: The directory to put this file in. + """ + logger.debug("Create %s", TEMPLATE_PARAMETERS_FILENAME) + vm_parameters = ( + self.vm_parameters_ordered + if self.order_params + else self.vm_parameters + ) + + template_parameters = {} + + for key in vm_parameters: + if key == self.config.image_name_parameter: + template_parameters[key] = self.image_name + continue + + template_parameters[key] = f"{{deployParameters.{key}}}" + + template_parameters_path = directory / TEMPLATE_PARAMETERS_FILENAME + + with open(template_parameters_path, "w", encoding="utf-8") as _file: + _file.write(json.dumps(template_parameters, indent=4)) + + logger.debug("%s created", template_parameters_path) + + def write_vhd_parameters(self, directory: Path) -> None: + """ + Write out the NFD vhdParameters.json file to `directory`. + + :param directory: The directory to put this file in. + """ + vhd_config = self.config.vhd + # vhdImageMappingRuleProfile userConfiguration within the NFDV API accepts azureDeployLocation + # as the location where the image resource should be created from the VHD. The CLI does not + # expose this as it defaults to the NF deploy location, and we can't think of situations where + # it should be different. + vhd_parameters = { + "imageName": self.image_name, + **{ + snake_case_to_camel_case(key): value + for key, value in vhd_config.__dict__.items() + if key in EXTRA_VHD_PARAMETERS and value is not None + }, + } + + vhd_parameters_path = directory / VHD_PARAMETERS_FILENAME + with open(vhd_parameters_path, "w", encoding="utf-8") as _file: + _file.write(json.dumps(vhd_parameters, indent=4)) + + logger.debug("%s created", vhd_parameters_path) + + def _copy_to_output_directory(self) -> None: + """Copy the static bicep templates and generated config mappings and schema into the build output directory.""" + logger.info("Create NFD bicep %s", self.output_directory) + assert self._tmp_dir + Path(self.output_directory).mkdir(exist_ok=True) + + static_bicep_templates_dir = Path(__file__).parent / "templates" + + static_vnfd_bicep_path = ( + static_bicep_templates_dir / VNF_DEFINITION_BICEP_TEMPLATE_FILENAME + ) + shutil.copy(static_vnfd_bicep_path, self.output_directory) + + static_manifest_bicep_path = ( + static_bicep_templates_dir / VNF_MANIFEST_BICEP_TEMPLATE_FILENAME + ) + shutil.copy(static_manifest_bicep_path, self.output_directory) + # Copy everything in the temp directory to the output directory + shutil.copytree( + self._tmp_dir, + self.output_directory, + dirs_exist_ok=True, + ) + + logger.info("Copied files to %s", self.output_directory) diff --git a/src/aosm/azext_aosm/generate_nsd/__init__.py b/src/aosm/azext_aosm/generate_nsd/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/generate_nsd/nf_ret.py b/src/aosm/azext_aosm/generate_nsd/nf_ret.py new file mode 100644 index 00000000000..69589e69242 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/nf_ret.py @@ -0,0 +1,185 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Handles the creation of a resource element template for a network function.""" + +import json + +from typing import Dict, Any, List, Union +from knack.log import get_logger + +from azext_aosm._configuration import NFDRETConfiguration +from azext_aosm.util.constants import CNF, VNF +from azext_aosm.util.management_clients import ApiClients +from azext_aosm.vendored_sdks.models import NetworkFunctionDefinitionVersion, NFVIType + + +logger = get_logger(__name__) + + +class NFRETGenerator: + """Represents a single network function resource element template within an NSD.""" + + def __init__( + self, api_clients: ApiClients, config: NFDRETConfiguration, cg_schema_name: str + ) -> None: + self.config = config + self.cg_schema_name = cg_schema_name + nfdv = self._get_nfdv(config, api_clients) + print( + f"Finding the deploy parameters for {self.config.name}:{self.config.version}" + ) + + if not nfdv.properties.deploy_parameters: + raise NotImplementedError( + f"NFDV {self.config.name} has no deploy parameters, cannot generate NSD." + ) + self.deploy_parameters: Dict[str, Any] = json.loads( + nfdv.properties.deploy_parameters + ) + + self.nfd_group_name = self.config.name.replace("-", "_") + self.nfdv_parameter_name = f"{self.nfd_group_name}_nfd_version" + self.config_mapping_filename = f"{self.config.name}_config_mapping.json" + + @staticmethod + def _get_nfdv( + config: NFDRETConfiguration, api_clients: ApiClients + ) -> NetworkFunctionDefinitionVersion: + """Get the existing NFDV resource object.""" + print( + f"Reading existing NFDV resource object {config.version} from group {config.name}" + ) + nfdv_object = api_clients.aosm_client.network_function_definition_versions.get( + resource_group_name=config.publisher_resource_group, + publisher_name=config.publisher, + network_function_definition_group_name=config.name, + network_function_definition_version_name=config.version, + ) + return nfdv_object + + @property + def config_mappings(self) -> Dict[str, Any]: + """ + Return the contents of the config mapping file for this RET. + + Output will look something like: + { + "deploymentParametersObject": { + "deploymentParameters": [ + "{configurationparameters('foo_ConfigGroupSchema').bar.deploymentParameters}" + ] + }, + "nginx_nfdg_nfd_version": "{configurationparameters('foo_ConfigGroupSchema').bar.bar_nfd_version}", + "managedIdentity": "{configurationparameters('foo_ConfigGroupSchema').managedIdentity}", + "customLocationId": "{configurationparameters('foo_ConfigGroupSchema').bar.customLocationId}" + } + """ + nf = self.config.name + + logger.debug("Create %s", self.config_mapping_filename) + + deployment_parameters: Union[ + str, List[str] + ] = f"{{configurationparameters('{self.cg_schema_name}').{nf}.deploymentParameters}}" + + if not self.config.multiple_instances: + assert isinstance(deployment_parameters, str) + deployment_parameters = [deployment_parameters] + + deployment_parameters_object = {"deploymentParameters": deployment_parameters} + + version_parameter = ( + f"{{configurationparameters('{self.cg_schema_name}')." + f"{nf}.{self.nfdv_parameter_name}}}" + ) + + config_mappings = { + "deploymentParametersObject": deployment_parameters_object, + self.nfdv_parameter_name: version_parameter, + "managedIdentity": f"{{configurationparameters('{self.cg_schema_name}').managedIdentity}}", + } + + if self.config.type == CNF: + config_mappings[ + "customLocationId" + ] = f"{{configurationparameters('{self.cg_schema_name}').{nf}.customLocationId}}" + + return config_mappings + + @property + def nf_bicep_substitutions(self) -> Dict[str, Any]: + """Returns the jinja2 parameters for the NF bicep template template.""" + return { + "network_function_name": self.config.name, + "publisher_name": self.config.publisher, + "publisher_resource_group": self.config.publisher_resource_group, + "network_function_definition_group_name": (self.config.name), + "network_function_definition_version_parameter": (self.nfdv_parameter_name), + "network_function_definition_offering_location": ( + self.config.publisher_offering_location + ), + # Ideally we would use the network_function_type from reading the actual + # NF, as we do for deployParameters, but the SDK currently doesn't + # support this and needs to be rebuilt to do so. + "nfvi_type": ( + NFVIType.AZURE_CORE.value # type: ignore[attr-defined] # pylint: disable=no-member + if self.config.type == VNF + else NFVIType.AZURE_ARC_KUBERNETES.value # type: ignore[attr-defined] # pylint: disable=no-member + ), + "CNF": self.config.type == CNF, + } + + @property + def config_schema_snippet(self) -> Dict[str, Any]: + """Return the CGS snippet for this NF.""" + nfdv_version_description_string = ( + f"The version of the {self.config.name} " + "NFD to use. This version must be compatible with (have the same " + "parameters exposed as) " + f"{self.config.name}." + ) + + if self.config.multiple_instances: + deploy_parameters = { + "type": "array", + "items": { + "type": "object", + "properties": self.deploy_parameters["properties"], + }, + } + else: + deploy_parameters = { + "type": "object", + "properties": self.deploy_parameters["properties"], + } + + nf_schema: Dict[str, Any] = { + "type": "object", + "properties": { + "deploymentParameters": deploy_parameters, + self.nfdv_parameter_name: { + "type": "string", + "description": nfdv_version_description_string, + }, + }, + "required": ["deploymentParameters", self.nfdv_parameter_name], + } + + if self.config.type == CNF: + custom_location_description_string = ( + "The custom location ID of the ARC-Enabled AKS Cluster to deploy the CNF " + "to. Should be of the form " + "'/subscriptions/{subscriptionId}/resourcegroups" + "/{resourceGroupName}/providers/microsoft.extendedlocation/" + "customlocations/{customLocationName}'" + ) + + nf_schema["properties"]["customLocationId"] = { + "type": "string", + "description": custom_location_description_string, + } + nf_schema["required"].append("customLocationId") + + return nf_schema diff --git a/src/aosm/azext_aosm/generate_nsd/nsd_generator.py b/src/aosm/azext_aosm/generate_nsd/nsd_generator.py new file mode 100644 index 00000000000..adee03677e6 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/nsd_generator.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Contains a class for generating NSDs and associated resources.""" +import json +import os +import shutil +import tempfile +from functools import cached_property +from typing import Any, Dict + +from jinja2 import Template +from knack.log import get_logger + +from azext_aosm._configuration import NFDRETConfiguration, NSConfiguration +from azext_aosm.generate_nsd.nf_ret import NFRETGenerator +from azext_aosm.util.constants import ( + CONFIG_MAPPINGS_DIR_NAME, + NF_TEMPLATE_JINJA2_SOURCE_TEMPLATE, + NSD_ARTIFACT_MANIFEST_BICEP_FILENAME, + NSD_ARTIFACT_MANIFEST_SOURCE_TEMPLATE_FILENAME, + NSD_BICEP_FILENAME, + NSD_DEFINITION_JINJA2_SOURCE_TEMPLATE, + SCHEMAS_DIR_NAME, + TEMPLATES_DIR_NAME, +) +from azext_aosm.util.management_clients import ApiClients + +logger = get_logger(__name__) + +# Different types are used in Bicep templates and NFDs. The list accepted by NFDs is +# documented in the AOSM meta-schema. This will be published in the future but for now +# can be found in +# https://microsoft.sharepoint.com/:w:/t/NSODevTeam/Ec7ovdKroSRIv5tumQnWIE0BE-B2LykRcll2Qb9JwfVFMQ +NFV_TO_BICEP_PARAM_TYPES: Dict[str, str] = { + "integer": "int", + "boolean": "bool", +} + + +class NSDGenerator: # pylint: disable=too-few-public-methods + """ + NSD Generator. + + This takes a config file and a set of NFDV deploy_parameters and outputs: + - A bicep file for the NSDV + - Parameters files that are used by the NSDV bicep file, these are the + schemas and the mapping profiles of those schemas parameters + - A bicep file for the Artifact manifest + - A bicep and JSON file defining the Network Function that will + be deployed by the NSDV + """ + + def __init__(self, api_clients: ApiClients, config: NSConfiguration): + self.config = config + self.nsd_bicep_template_name = NSD_DEFINITION_JINJA2_SOURCE_TEMPLATE + self.nsd_bicep_output_name = NSD_BICEP_FILENAME + + self.nf_ret_generators = [] + + for nf_config in self.config.network_functions: + assert isinstance(nf_config, NFDRETConfiguration) + self.nf_ret_generators.append( + NFRETGenerator(api_clients, nf_config, self.config.cg_schema_name) + ) + + def generate_nsd(self) -> None: + """Generate a NSD templates which includes an Artifact Manifest, NFDV and NF templates.""" + logger.info("Generate NSD bicep templates") + + # Create temporary folder. + with tempfile.TemporaryDirectory() as tmpdirname: + self._write_config_group_schema_json(tmpdirname) + self._write_config_mapping_files(tmpdirname) + self._write_nsd_manifest(tmpdirname) + self._write_nf_bicep_files(tmpdirname) + self._write_nsd_bicep(tmpdirname) + + self._copy_to_output_folder(tmpdirname) + print( + "Generated NSD bicep templates created in" + f" {self.config.output_directory_for_build}" + ) + print( + "Please review these templates. When you are happy with them run " + "`az aosm nsd publish` with the same arguments." + ) + + @cached_property + def _config_group_schema_dict(self) -> Dict[str, Any]: + """ + :return: The Config Group Schema as a dictionary. + + See src/aosm/azext_aosm/tests/latest/nsd_output/*/schemas for examples of the + output from this function. + """ + managed_identity_description_string = ( + "The managed identity to use to deploy NFs within this SNS. This should " + "be of the form '/subscriptions/{subscriptionId}/resourceGroups/" + "{resourceGroupName}/providers/Microsoft.ManagedIdentity/" + "userAssignedIdentities/{identityName}. " + "If you wish to use a system assigned identity, set this to a blank string." + ) + + properties = { + nf.config.name: nf.config_schema_snippet for nf in self.nf_ret_generators + } + + properties.update( + { + "managedIdentity": { + "type": "string", + "description": managed_identity_description_string, + } + } + ) + + required = [nf.config.name for nf in self.nf_ret_generators] + required.append("managedIdentity") + + cgs_dict: Dict[str, Any] = { + "$schema": "https://json-schema.org/draft-07/schema#", + "title": self.config.cg_schema_name, + "type": "object", + "properties": properties, + "required": required, + } + + return cgs_dict + + def _write_config_group_schema_json(self, output_directory) -> None: + """Create a file containing the json schema for the CGS.""" + temp_schemas_folder_path = os.path.join(output_directory, SCHEMAS_DIR_NAME) + os.mkdir(temp_schemas_folder_path) + + logger.debug("Create %s.json", self.config.cg_schema_name) + + schema_path = os.path.join( + temp_schemas_folder_path, f"{self.config.cg_schema_name}.json" + ) + + with open(schema_path, "w", encoding="utf-8") as _file: + _file.write(json.dumps(self._config_group_schema_dict, indent=4)) + + logger.debug("%s created", schema_path) + + def _write_config_mapping_files(self, output_directory) -> None: + """Write out a config mapping file for each NF.""" + temp_mappings_folder_path = os.path.join( + output_directory, CONFIG_MAPPINGS_DIR_NAME + ) + + os.mkdir(temp_mappings_folder_path) + + for nf in self.nf_ret_generators: + config_mappings_path = os.path.join( + temp_mappings_folder_path, nf.config_mapping_filename + ) + + with open(config_mappings_path, "w", encoding="utf-8") as _file: + _file.write(json.dumps(nf.config_mappings, indent=4)) + + logger.debug("%s created", config_mappings_path) + + def _write_nf_bicep_files(self, output_directory) -> None: + """ + Write bicep files for deploying NFs. + + In the publish step these bicep files will be uploaded to the publisher storage + account as artifacts. + """ + for nf in self.nf_ret_generators: + substitutions = {"location": self.config.location} + substitutions.update(nf.nf_bicep_substitutions) + + self._generate_bicep( + NF_TEMPLATE_JINJA2_SOURCE_TEMPLATE, + os.path.join(output_directory, nf.config.nf_bicep_filename), + substitutions, + ) + + def _write_nsd_bicep(self, output_directory) -> None: + """Write out the NSD bicep file.""" + ret_names = [nf.config.resource_element_name for nf in self.nf_ret_generators] + arm_template_names = [ + nf.config.arm_template.artifact_name for nf in self.nf_ret_generators + ] + config_mapping_files = [ + nf.config_mapping_filename for nf in self.nf_ret_generators + ] + + # We want the armTemplateVersion to be the same as the NSD Version. That means + # that if we create a new NSDV then the existing artifacts won't be overwritten. + params = { + "nfvi_site_name": self.config.nfvi_site_name, + "armTemplateNames": arm_template_names, + "armTemplateVersion": self.config.nsd_version, + "cg_schema_name": self.config.cg_schema_name, + "nsdv_description": self.config.nsdv_description, + "ResourceElementName": ret_names, + "configMappingFiles": config_mapping_files, + "nf_count": len(self.nf_ret_generators), + } + + self._generate_bicep( + self.nsd_bicep_template_name, + os.path.join(output_directory, self.nsd_bicep_output_name), + params, + ) + + def _write_nsd_manifest(self, output_directory) -> None: + """Write out the NSD manifest bicep file.""" + logger.debug("Create NSD manifest") + + self._generate_bicep( + NSD_ARTIFACT_MANIFEST_SOURCE_TEMPLATE_FILENAME, + os.path.join(output_directory, NSD_ARTIFACT_MANIFEST_BICEP_FILENAME), + {}, + ) + + @staticmethod + def _generate_bicep( + template_name: str, output_file_name: str, params: Dict[Any, Any] + ) -> None: + """ + Render the bicep templates with the correct parameters and copy them into the build output folder. + + :param template_name: The name of the template to render + :param output_file_name: The name of the output file + :param params: The parameters to render the template with + """ + + code_dir = os.path.dirname(__file__) + + bicep_template_path = os.path.join(code_dir, TEMPLATES_DIR_NAME, template_name) + + with open(bicep_template_path, "r", encoding="utf-8") as file: + bicep_contents = file.read() + + bicep_template = Template(bicep_contents) + + # Render all the relevant parameters in the bicep template + rendered_template = bicep_template.render(**params) + + with open(output_file_name, "w", encoding="utf-8") as file: + file.write(rendered_template) + + def _copy_to_output_folder(self, temp_dir) -> None: + """Copy the bicep templates, config mappings and schema into the build output folder.""" + + logger.info("Create NSD bicep %s", self.config.output_directory_for_build) + os.mkdir(self.config.output_directory_for_build) + + shutil.copytree( + temp_dir, + self.config.output_directory_for_build, + dirs_exist_ok=True, + ) + + logger.info("Copied files to %s", self.config.output_directory_for_build) diff --git a/src/aosm/azext_aosm/generate_nsd/templates/artifact_manifest_template.bicep b/src/aosm/azext_aosm/generate_nsd/templates/artifact_manifest_template.bicep new file mode 100644 index 00000000000..34ac9ca3fdb --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/templates/artifact_manifest_template.bicep @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an Artifact Manifest for a NSD +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestNames array +@description('The name under which to store the ARM template') +param armTemplateNames array +@description('The version that you want to name the NFM template artifact, in format A.B.C. e.g. 6.13.0. If testing for development, you can use any numbers you like.') +param armTemplateVersion string + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +resource acrArtifactManifests 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = [for (values, i) in armTemplateNames: { + parent: acrArtifactStore + name: acrManifestNames[i] + location: location + properties: { + artifacts: [ + { + artifactName: armTemplateNames[i] + artifactType: 'ArmTemplate' + artifactVersion: armTemplateVersion + } + ] + } +}] diff --git a/src/aosm/azext_aosm/generate_nsd/templates/nf_template.bicep.j2 b/src/aosm/azext_aosm/generate_nsd/templates/nf_template.bicep.j2 new file mode 100644 index 00000000000..8a53daa9edf --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/templates/nf_template.bicep.j2 @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// The template that the NSD invokes to create the Network Function from a published NFDV. + +@description('Publisher where the NFD is published') +param publisherName string = '{{publisher_name}}' + +@description('Resource group where the NFD publisher exists') +param publisherResourceGroup string = '{{publisher_resource_group}}' + +@description('NFD Group name for the Network Function') +param networkFunctionDefinitionGroupName string = '{{network_function_definition_group_name}}' + +@description('NFD version') +param {{network_function_definition_version_parameter}} string + +@description('The managed identity that should be used to create the NF.') +param managedIdentity string + +{%- if CNF %} +@description('The custom location of the ARC-enabled AKS cluster to create the NF.') +param customLocationId string +{%- endif %} + +param location string = '{{location}}' + +param nfviType string = '{{nfvi_type}}' + +param resourceGroupId string = resourceGroup().id + +@secure() +param deploymentParametersObject object + +var deploymentParameters = deploymentParametersObject.deploymentParameters + +var identityObject = (managedIdentity == '') ? { + type: 'SystemAssigned' +} : { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity}': {} + } +} + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup(publisherResourceGroup) +} + +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: networkFunctionDefinitionGroupName +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' existing = { + parent: nfdg + name: {{network_function_definition_version_parameter}} + +} + +resource nf_resource 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = [for (values, i) in deploymentParameters: { + name: '{{network_function_name}}${i}' + location: location + identity: identityObject + properties: { + networkFunctionDefinitionVersionResourceReference: { + id: nfdv.id + idType: 'Open' + } + nfviType: nfviType +{%- if CNF %} + nfviId: customLocationId +{%- else %} + nfviId: resourceGroupId +{%- endif %} + allowSoftwareUpdate: true + configurationType: 'Secret' + secretDeploymentValues: string(values) + } +}] diff --git a/src/aosm/azext_aosm/generate_nsd/templates/nsd_template.bicep.j2 b/src/aosm/azext_aosm/generate_nsd/templates/nsd_template.bicep.j2 new file mode 100644 index 00000000000..57d787c4803 --- /dev/null +++ b/src/aosm/azext_aosm/generate_nsd/templates/nsd_template.bicep.j2 @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// Bicep template to create an Artifact Manifest, Config Group Schema and NSDV. +// +// Requires an existing NFDV from which the values will be populated. + +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Network Service Design Group') +param nsDesignGroup string +@description('The version of the NSDV you want to create, in format A.B.C') +param nsDesignVersion string +@description('Name of the nfvi site') +param nfviSiteName string = '{{nfvi_site_name}}' + +// The publisher resource is the top level AOSM resource under which all other designer resources +// are created. +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// The artifact store is the resource in which all the artifacts required to deploy the NF are stored. +// The artifact store is created by the az aosm CLI before this template is deployed. +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created up-front, the NSD Group is the parent resource under which all NSD versions will be created. +resource nsdGroup 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups@2023-09-01' existing = { + parent: publisher + name: nsDesignGroup +} + +// The configuration group schema defines the configuration required to deploy the NSD. The NSD references this object in the +// `configurationgroupsSchemaReferences` and references the values in the schema in the `parameterValues`. +// The operator will create a config group values object that will satisfy this schema. +resource cgSchema 'Microsoft.Hybridnetwork/publishers/configurationGroupSchemas@2023-09-01' = { + parent: publisher + name: '{{cg_schema_name}}' + location: location + properties: { + schemaDefinition: string(loadJsonContent('schemas/{{cg_schema_name}}.json')) + } +} + +// The NSD version +resource nsdVersion 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions@2023-09-01' = { + parent: nsdGroup + name: nsDesignVersion + location: location + properties: { + description: '{{nsdv_description}}' + // The version state can be Preview, Active or Deprecated. + // Once in an Active state, the NSDV becomes immutable. + versionState: 'Preview' + // The `configurationgroupsSchemaReferences` field contains references to the schemas required to + // be filled out to configure this NSD. + configurationGroupSchemaReferences: { + {{cg_schema_name}}: { + id: cgSchema.id + } + } + // This details the NFVIs that should be available in the Site object created by the operator. + nfvisFromSite: { + nfvi1: { + name: nfviSiteName + type: 'AzureCore' + } + } + // This field lists the templates that will be deployed by AOSM and the config mappings + // to the values in the CG schemas. + resourceElementTemplates: [ +{%- for index in range(nf_count) %} + { + name: '{{ResourceElementName[index]}}' + // The type of resource element can be ArmResourceDefinition, ConfigurationDefinition or NetworkFunctionDefinition. + type: 'NetworkFunctionDefinition' + // The configuration object may be different for different types of resource element. + configuration: { + // This field points AOSM at the artifact in the artifact store. + artifactProfile: { + artifactStoreReference: { + id: acrArtifactStore.id + } + artifactName: '{{armTemplateNames[index]}}' + artifactVersion: '{{armTemplateVersion}}' + } + templateType: 'ArmTemplate' + // The parameter values map values from the CG schema, to values required by the template + // deployed by this resource element. + parameterValues: string(loadJsonContent('configMappings/{{configMappingFiles[index]}}')) + } + dependsOnProfile: { + installDependsOn: [] + uninstallDependsOn: [] + updateDependsOn: [] + } + } +{%- endfor %} + ] + } +} diff --git a/src/aosm/azext_aosm/tests/__init__.py b/src/aosm/azext_aosm/tests/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/tests/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/tests/latest/__init__.py b/src/aosm/azext_aosm/tests/latest/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/tests/latest/metaschema.json b/src/aosm/azext_aosm/tests/latest/metaschema.json new file mode 100644 index 00000000000..cd1bf635864 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/metaschema.json @@ -0,0 +1,420 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "version": "2023-09-01", + "$ref": "#/definitions/schemaObjectRoot", + "definitions": { + "schemaArray": { + "type": "object", + "properties": { + "type": { + "const": "array" + }, + "items": { + "$ref": "#/definitions/schemaAllOf" + }, + "minItems": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxItems": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "default": { + "type": "array" + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaArrayMultiType": { + "type": "object", + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/schemaAllOf" + } + }, + "minItems": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "maxItems": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "additionalItems": { + "const": false + }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "default": { + "type": "array" + } + }, + "required": [ + "type", + "additionalItems" + ], + "additionalProperties": false + }, + "schemaObjectRoot": { + "type": "object", + "properties": { + "format": { + "type": "string" + }, + "type": { + "const": "object" + }, + "$schema": { + "type": "string", + "format": "uri", + "not": { + "const": "https://json-schema.org/draft/2020-12/schema" + } + }, + "$id": { + "type": "string", + "format": "uri-reference" + }, + "version": { + "type": "string" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "required": { + "type": "array" + }, + "additionalProperties": { + "type": "boolean" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "maxProperties": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "minProperties": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/schemaAllOf" + } + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaObject": { + "type": "object", + "properties": { + "format": { + "type": "string" + }, + "type": { + "const": "object" + }, + "version": { + "type": "string" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "required": { + "type": "array" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "additionalProperties": { + "type": "boolean" + }, + "maxProperties": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "minProperties": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/schemaAllOf" + } + }, + "default": { + "type": "object" + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaAllOf": { + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "object" + } + }, + "required": [ + "type" + ] + }, + "then": { + "$ref": "#/definitions/schemaObject" + } + }, + { + "if": { + "properties": { + "type": { + "enum": [ + "string", + "integer", + "boolean", + "number" + ] + } + } + }, + "then": { + "$ref": "#/definitions/schemaPrimitive" + } + }, + { + "if": { + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "array" + } + }, + "required": [ + "type", + "items" + ] + }, + "then": { + "$ref": "#/definitions/schemaArrayMultiType" + } + }, + { + "if": { + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "object" + } + }, + "required": [ + "type" + ] + }, + "then": { + "anyOf": [ + { + "$ref": "#/definitions/schemaArray" + } + ] + } + } + ] + }, + "schemaPrimitive": { + "type": "object", + "properties": { + "type": { + "enum": [ + "number", + "integer", + "string", + "boolean", + "null" + ] + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + } + }, + "required": [ + "type" + ], + "allOf": [ + { + "$ref": "#/definitions/defaultPrimitiveCondition" + } + ], + "additionalProperties": true + }, + "nonNegativeInteger": { + "type": "integer", + "minimum": 0 + }, + "nonNegativeIntegerDefault0": { + "allOf": [ + { + "$ref": "#/definitions/nonNegativeInteger" + }, + { + "default": 0 + } + ] + }, + "defaultPrimitiveCondition": { + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "integer" + } + } + }, + "then": { + "properties": { + "default": { + "type": "integer" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "number" + } + } + }, + "then": { + "properties": { + "default": { + "type": "number" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "default": { + "type": "string" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "default": { + "type": "boolean" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "null" + } + } + }, + "then": { + "properties": { + "default": { + "type": "null" + } + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/metaschema_modified.json b/src/aosm/azext_aosm/tests/latest/metaschema_modified.json new file mode 100644 index 00000000000..dcd692ddc62 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/metaschema_modified.json @@ -0,0 +1,416 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "version": "2023-09-01", + "$ref": "#/definitions/schemaObjectRoot", + "definitions": { + "schemaArray": { + "type": "object", + "properties": { + "type": { + "const": "array" + }, + "items": { + "$ref": "#/definitions/schemaAllOf" + }, + "minItems": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxItems": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "default": { + "type": "array" + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaArrayMultiType": { + "type": "object", + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/schemaAllOf" + } + }, + "minItems": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "maxItems": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "additionalItems": { + "const": false + }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "default": { + "type": "array" + } + }, + "required": [ + "type", + "additionalItems" + ], + "additionalProperties": false + }, + "schemaObjectRoot": { + "type": "object", + "properties": { + "format": { + "type": "string" + }, + "type": { + "const": "object" + }, + "$schema": { + "type": "string", + "format": "uri", + "not": { + "const": "https://json-schema.org/draft/2020-12/schema" + } + }, + "version": { + "type": "string" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "required": { + "type": "array" + }, + "additionalProperties": { + "type": "boolean" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "maxProperties": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "minProperties": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/schemaAllOf" + } + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaObject": { + "type": "object", + "properties": { + "format": { + "type": "string" + }, + "type": { + "const": "object" + }, + "version": { + "type": "string" + }, + "$comment": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "required": { + "type": "array" + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + }, + "additionalProperties": { + "type": "boolean" + }, + "maxProperties": { + "$ref": "#/definitions/nonNegativeInteger" + }, + "minProperties": { + "$ref": "#/definitions/nonNegativeIntegerDefault0" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/schemaAllOf" + } + }, + "default": { + "type": "object" + } + }, + "required": [ + "type" + ], + "additionalProperties": false + }, + "schemaAllOf": { + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "object" + } + }, + "required": [ + "type" + ] + }, + "then": { + "$ref": "#/definitions/schemaObject" + } + }, + { + "if": { + "properties": { + "type": { + "enum": [ + "string", + "integer", + "boolean", + "number" + ] + } + } + }, + "then": { + "$ref": "#/definitions/schemaPrimitive" + } + }, + { + "if": { + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "array" + } + }, + "required": [ + "type", + "items" + ] + }, + "then": { + "$ref": "#/definitions/schemaArrayMultiType" + } + }, + { + "if": { + "properties": { + "type": { + "const": "array" + }, + "items": { + "type": "object" + } + }, + "required": [ + "type" + ] + }, + "then": { + "anyOf": [ + { + "$ref": "#/definitions/schemaArray" + } + ] + } + } + ] + }, + "schemaPrimitive": { + "type": "object", + "properties": { + "type": { + "enum": [ + "number", + "integer", + "string", + "boolean", + "null" + ] + }, + "enum": { + "type": "array", + "items": true, + "minItems": 1, + "uniqueItems": true + } + }, + "required": [ + "type" + ], + "allOf": [ + { + "$ref": "#/definitions/defaultPrimitiveCondition" + } + ], + "additionalProperties": true + }, + "nonNegativeInteger": { + "type": "integer", + "minimum": 0 + }, + "nonNegativeIntegerDefault0": { + "allOf": [ + { + "$ref": "#/definitions/nonNegativeInteger" + }, + { + "default": 0 + } + ] + }, + "defaultPrimitiveCondition": { + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "integer" + } + } + }, + "then": { + "properties": { + "default": { + "type": "integer" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "number" + } + } + }, + "then": { + "properties": { + "default": { + "type": "number" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "default": { + "type": "string" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "boolean" + } + } + }, + "then": { + "properties": { + "default": { + "type": "boolean" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "null" + } + } + }, + "then": { + "properties": { + "default": { + "type": "null" + } + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf-0.1.0.tgz b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..679c20fddcf4562cdc8396fe0d6f3c5be2092d4d GIT binary patch literal 5234 zcmV-&6pia2iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PH<~bK5ws`?o#?p3|GQd$lYlZratGzMEXq+s(T+%{1M;x!Kw2 z&=PF3kw_g$IrVz;KKmPz`fVw86E|(|%s&!a0s#;tK@bFJHtCZoGSv^*WNJQQW(O7MyLT!Fo=jim=i(C zI6?`E!x$kUQep^{DGm#s3Q!m)5m6{z#}R1M!ZA;o@?q#WG$vE@9RPs|msD}F@Ij`G zErN(9>DYW^6T=z_#C{k)JtP?JA0E2o_f%jYT*@7QB#okT9?@Xo!|CLVt8;-8nQ{R3 z;LRL`prK}QhG0m7B2&1UafuLS!l3rG)pMm%bRE#ZKJ=bH`{8hZ)XSJYPowAp1A$8V z@au0z73PF|==GdQ8bvD)9f@L213U@>BLl<7$J%jp8&ClsDvpp6q;j5C1q2CIG0T^I2-`GmS`CzJUnV}r=MM5 zkP506$DAqrs0ywp@<+kb#D{&)^R$H9!2*(yF^#CAD6QN9Lcx>#b03agy)vH#lJE_S z7H>IMf1?q~g;W?<*=EPsUGF2MB!RZN+QXD zGCfNqO3f+@?0=!89yq`mAe&RcnU;`*E2?G?QKh16aOJE#0htCfP5w1yRClMVC*y*r z5OTO8tk#lBwUpV`Dmw*v6!9y{rUrXNnFb-@hg6#Pu_nMUKq-k>JTdJT7<1Elgdi2s z0>*+E*-R7)cvy=1p_?I%Y1v0XlA3uDXWwItjkX`|KYvZLCjKi$xoHiDq>9UcM3hZi zCr(V+Tf5#!z19H41rwWWBZm7krgzy9VpWHOt!#d#{$xS|^g)jMDZiS3n9zB$Ncoim zKtp88RP#o|aJ-M>{=p%7{n369_DL{2=z9kQpW_cdJPShIR>cz<_#kPVM5YP3UQc*f zV1vFH__dcZf$j62551XEi9ZgKy%nfN>rAD}Dz+XoWeTS#HpE;mm|Mnt^D=uEV$Kbu zHyRAhZQAOH$gxNz^oVK2Vzz{zbug7X-1XvWa@rvuQ>WZ`Zx^p3tCMSUgm>=N<{o{u zZ>Yk!L)L^X-b{MgmSjC2L>fr1NHLr`L3HUxP$K%|POMd5Gmu*A=+~FE4Yoj;nUbz z-#@L@HtVyt@@a%hf_LiMR+P8s?{+*y&F+K&ZaXg8%7$a5m51CH^%b?|RyA)agSEsHr}#(Uw-L?Q(i&i|+15dgg8W ztj1XGTHCH=Q#c2=Y@_pp24B)juR2V>uv4IZ==9~8X`FU_VTP&)x80L(Wt(0{ksS|w z;iky1O0d}x;pcT7aM5kU-_oITlM!_filcsvzS~~c>e#dREpLO_-L~s@?(xb=+I{+R zoC@#?pV!~yVOZ__r-;rOoV|JX^1@Xg)i!9XiT^q{7&YU+o(@O*yYrv>C_@*1L>mN9 z3Dbn1-@bzJ0z}GK7N#Q+0v^YNh0=GH%RbNvxWCu~!#u(y^SQzGwSf?XO%Wcm(qxA^d*UP$5W&B@F6=WpJ=d-34WWje+{MKDDL z{eEGkgJ$F{Mo1*OXT{U&Yv^wK_2UMAr{@jsG;Vn-9*u6*>`6sbDqRwWxvJ*=xJ;q*L< zOeAwcBRyK(s_OqIPaz--u80a|HtNl^6ZoV$9UgviSIc<-{i{to@L}137cbxba(dj- zhX&&&q&K7q{eG_gp|@Q2mdk8LKB6qdkC69xR1s%B9l?8SCY)<#ot;~~>y~j)w#L`| zHoDg|xN}w(;c^>H%kwuU@6V22zih}X;o+vkK7t-e61N^8rz^hblxHc+C#zK{lS<3% zMU$i!Rp%^=QIU`+VsK~jv@JY-bN24&^z7x^Htmz}aI!o?L4VTFB7!+%g0 zN>$N+>1Fn-EgkmX`x!V0ZODSfWrgxk;WJ4WI{heuitCf zXpUj=*oKsof`VSX7Vxi>M07$i)JnxL?>hfLi`&2}O+hzA!WaXhb&%vSR`Ql?lP46T zPy!KXBULermZuUPjTc57CubKLRvQ3XJwA4w(+LQxq%4wRv9fssHt1c!6^$ZobEH!9 zDYc!FMp4G?&C)H`=v=}Tv%49sk_)c${U$=!>u&b>foXvMV)I@tc`QU>ku;Y)%V+K3 zCo-1^%G3mUf0F$_$zB7OCA#?-YyVgqd6h2Jb0y1T)7@#hH5(%qDk5Wy)^)7`E&H|E zo~o$r=PU;W{s4hVq}RjVpL@`I-~05*#N(JV%cfkzrUkNm&M=ByIU5+({cg)LYnp3` zcL2%E)&D9Z;8sRY*5acg@kYN}HL8kaLTxUrRQUt`m2!m*39Mp?2_sVs`{RXQvpX)b zgqJo6=I0cf$*|efek&g~=Vb%)vZZcrUivGR(@kT#sqouVeAYIu>U}-yQdV^^H%k#} zEE|v3?o=LkA!OCIR`f)Ux|e-e**&x(SkVPvdY%4UrNjOUF^TvhMz)P~@OAm0`_J~9 z_TST|2Rr-kK1wzJn}q|E~~k=%O%9ARPXq? zK&2M{D>;Kl3I!u#0goao6_hJRvpPJ|BmGoDkFq(5XxQrnef+p=?COGd!+dC49o;If zdVXqaua={t5eLxT8Kv8%nu}S?+p1-GT|J8Hp_CQ_wyvUJioeu@N*c$6HTPDHO4CnSua^j}c)%kc z-W{J;-t9p|=g3gXbHT^x*IwB}jvrAqA45y>>|W8D6~=9zGX2a{%B0S9W24NK?H(0# z9;Gq9*7KsHce26I4>+69Y2Q|8h&|Tz&uuGE1%rI{4QwT2zBH=HbZjfEf>;tQ6K5SO z_W5g))LYV4xl8L;6&s=|;0jDusd^_tSEUjrtAt9>pemyF z?z}neGFP$v>~fN~*#hp=SN>90TY&^gT0F4?j^-%H6e~nJo3a^4jRj_H3valX;g*fG zS54ftog47=1zb-Z`ah4e*~%KQ_WrM@!t`jM*aW4?#4xRM^ti2OS)R_In7EzrB+Hl`GE`SwTx#ug`P`nh3~O;YZRAEZ5SFY`<}M$H;^lCypDa(XvI(2@P@9LGIyITmUxEtxV(3)>ULS7x$0Q$P%t)t zGrR7q5JDCM+69|mLe|(aX0>o&@+8czOqS~4M68jn%f`uRGzQoVXy*~-<~ z20Ub-g~M_Uxu(2ZEbRZB1JM8Q(qaFXkFCEmCduvh0&DF5eXn``yYCIX(a!$Ak5aq; zJ9p$9=g#aF%c&%JD%8+-HW4( zcl;9Bj~wMsDDXvowb5BI$v_IC!szeVX-|8pnJefa;pr_Wa7{||Qlzk4aI>wgyc`ZXNfsA3D*ne$Z% z@91Z73u}WmtV{m98RXCw!%+(qsfUT(E^cb{HEpMEp8r`O@Ez5_+W9|h#(zH3|912L z9?C{h+D+eUQ&D8#pQ0~rh>P34C$`b5Ejnbsc?U_y{8uQI{i`>649#}rwrXJA{6B2Y z|9$Upw2S|~m(n_|&w1D~mwOv7{{61|_9uT0Tio{Ti({IchRCR$hx%@Ei;itlQQ zsv1k|!#I_TG5=VE&YBx8eE9XD27Q=c6GOyQ>W3Rj;D+ROgHoU#bSe*IJ;OPQFQh+e z^WW7nwfnqn(pbCxA3R<8{jc5q|Mye&;G8Ih!up!BJ^s}U8H`gJg(ftg1eaurviK!1 znI^{O206nhf@#FZHe{&IW)Ar;bbr&JBhU(3GZj(-;e^EZDmn-27! z{HvU^L5XNgg3B~9PD$x}@5-yh`Q9CqOXqu6#riWBbn1Nnf6gBKLImZhgwvCk(s2{P zKVYC7mxf3N7F_TTjysnD4{`7Z< s*r9zzBzveJCSm1%Ju?J%KRmcAyRs|0^0k%!4*&rF|D$UPvjBtu0FxAJdjJ3c literal 0 HcmV?d00001 diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/.helmignore b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/.helmignore new file mode 100644 index 00000000000..0e8a0eb36f4 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/Chart.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/Chart.yaml new file mode 100644 index 00000000000..275ab10e2e2 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: nf-agent-cnf +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/NOTES.txt b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/NOTES.txt new file mode 100644 index 00000000000..238eb9aa2f6 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "nf-agent-cnf.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "nf-agent-cnf.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nf-agent-cnf.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nf-agent-cnf.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/_helpers.tpl b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/_helpers.tpl new file mode 100644 index 00000000000..1a8d7653757 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "nf-agent-cnf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "nf-agent-cnf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "nf-agent-cnf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "nf-agent-cnf.labels" -}} +helm.sh/chart: {{ include "nf-agent-cnf.chart" . }} +{{ include "nf-agent-cnf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "nf-agent-cnf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nf-agent-cnf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "nf-agent-cnf.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "nf-agent-cnf.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/deployment.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/deployment.yaml new file mode 100644 index 00000000000..90bae35f548 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nf-agent-cnf.fullname" . }} + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "nf-agent-cnf.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "nf-agent-cnf.selectorLabels" . | nindent 8 }} + #aadpodidbinding: {{ .Values.nfagent.podIdentity }} - not using podidentity any more + spec: + # Copied imagePullSecrets from how afosas-aosm repo does it + imagePullSecrets: {{ mustToPrettyJson (ternary (list ) .Values.imagePullSecrets (kindIs "invalid" .Values.imagePullSecrets)) }} + serviceAccountName: {{ include "nf-agent-cnf.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + # Edited the image to point to the nf-agent image in the Artifact Store ACR + image: "{{ .Values.image.repository }}/pez-nfagent:879624" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + # Commented out otherwise kubernetes keeps restarting the pod thinking the probes have failed + # livenessProbe: + # httpGet: + # path: / + # port: http + # readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + # Gets the NF Agent config from the configMap - see nf-agent-config-map.yaml + volumeMounts: + - name: nfagent-config-volume + mountPath: /etc/nf-agent/config.yaml + subPath: config.yaml + volumes: + - name: nfagent-config-volume + configMap: + name: nfagent-config + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/hpa.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/hpa.yaml new file mode 100644 index 00000000000..ae24cfc1704 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "nf-agent-cnf.fullname" . }} + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "nf-agent-cnf.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/ingress.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/ingress.yaml new file mode 100644 index 00000000000..9fc4d315aed --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "nf-agent-cnf.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/nf-agent-config-map.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/nf-agent-config-map.yaml new file mode 100644 index 00000000000..8c2f5e6f823 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/nf-agent-config-map.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nfagent-config +data: + config.yaml: | + # Example NF Agent config file. + # Config is read from /etc/nf-agent/config.yaml. + log_level: debug + service_bus: + # Using a namespace and Managed Identity (specified by client ID) for auth. + namespace: {{ .Values.nfagent.namespace }} + # Helm uses sprig for templating, so we can use sprig functions to find just the UID from the full Managed Identity ID path. + identity: {{ (splitList "/" .Values.nfagent.identity) | last }} + # Alternatively can use a connstring instead of namespace + managed identity: + # connstring: "Endpoint=sb://contoso.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=TopSecretSASTokenGoesHere=" + subscriptions: + - topic: {{ .Values.nfagent.topic }} + subscription: {{ .Values.nfagent.topic }}-subscription + # Handler-specific config + handler_config: + simpl: + # The endpoint is constructed from the namespace and service name of the receiving thing. + # We couldn't get AOSM to install the service to listen on anything but port 80 + # Doh - that was because we changed values.yaml in the chart but didn't change values.mappings.yaml in the NFDV + # Changing values.mappings.yaml should make this work on port 5222 as expected. + endpoint: http://nfconfigchart.nfconfigchart.svc.cluster.local:80 # DevSkim: ignore DS162092 diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/service.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/service.yaml new file mode 100644 index 00000000000..ed537a4e61c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nf-agent-cnf.fullname" . }} + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "nf-agent-cnf.selectorLabels" . | nindent 4 }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/serviceaccount.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/serviceaccount.yaml new file mode 100644 index 00000000000..e19c3c09fbc --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "nf-agent-cnf.serviceAccountName" . }} + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/tests/test-connection.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/tests/test-connection.yaml new file mode 100644 index 00000000000..309ea5078a2 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "nf-agent-cnf.fullname" . }}-test-connection" + labels: + {{- include "nf-agent-cnf.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "nf-agent-cnf.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.mappings.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.mappings.yaml new file mode 100644 index 00000000000..eef4e074f8b --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.mappings.yaml @@ -0,0 +1,89 @@ +# Default values for nf-agent-cnf. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: sunnyclipubsunnynfagentacre00abc1832.azurecr.io + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "879624" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +nfagent: + namespace: "{deployParameters.nfAgentServiceBusNamespace}" + identity: "{deployParameters.nfAgentUserAssignedIdentityResourceId}" + topic: "{deployParameters.nfagent_topic}" # ??? This wasn't made available to simpl + # name of pod identity - not using this any more + # podIdentity: mypeapod diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.schema.json b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.schema.json new file mode 100644 index 00000000000..5207b19a8df --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.schema.json @@ -0,0 +1,193 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "additionalProperties": true, + "properties": { + "affinity": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "autoscaling": { + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "maxReplicas": { + "type": "integer" + }, + "minReplicas": { + "type": "integer" + }, + "targetCPUUtilizationPercentage": { + "type": "integer" + } + }, + "type": "object" + }, + "fullnameOverride": { + "type": "string" + }, + "image": { + "additionalProperties": false, + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "type": "object" + }, + "imagePullSecrets": { + "items": { + "anyOf": [] + }, + "type": "array" + }, + "ingress": { + "additionalProperties": false, + "properties": { + "annotations": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "className": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "hosts": { + "items": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "host": { + "type": "string" + }, + "paths": { + "items": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "path": { + "type": "string" + }, + "pathType": { + "type": "string" + } + }, + "type": "object" + } + ] + }, + "type": "array" + } + }, + "type": "object" + } + ] + }, + "type": "array" + }, + "tls": { + "items": { + "anyOf": [] + }, + "type": "array" + } + }, + "type": "object" + }, + "nameOverride": { + "type": "string" + }, + "nfagent": { + "additionalProperties": false, + "properties": { + "identity": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "topic": { + "type": "string" + } + }, + "type": "object" + }, + "nodeSelector": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "podAnnotations": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "podSecurityContext": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "securityContext": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "service": { + "additionalProperties": false, + "properties": { + "port": { + "type": "integer" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "serviceAccount": { + "additionalProperties": false, + "properties": { + "annotations": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "tolerations": { + "items": { + "anyOf": [] + }, + "type": "array" + } + }, + "type": "object" +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.yaml new file mode 100644 index 00000000000..3d9aeb6c9cb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nf-agent-cnf/values.yaml @@ -0,0 +1,92 @@ +# Default values for nf-agent-cnf. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + # NFDV defines that AOSM overwrites image.repository with the Articfact Store ACR + repository: sunnyclipubsunnynfagentacr2dd56aed266.azurecr.io + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "879624" + +# NFDV defines that AOSM overwrites imagePullSecrets with whatever is needed for the Artifact Store ACR +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + # I forgot to change values.mappings.yaml in NFDV to match the service port in the Helm chart when testing this + port: 8123 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +nfagent: + namespace: sb-uowvjfivpyuow + identity: 041db2eb-36e0-42cd-ac13-03ae8e997cd1 + topic: simpl + # name of pod identity - not using this any more + # podIdentity: mypeapod diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart-0.1.0.tgz b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..db24d31925a98013991b078915dafa0910d8faff GIT binary patch literal 4630 zcmV+x66x(9iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PK8ibK5$u@cFD?fk(+ceYv$PJ1_01(>v3fcF*nIHqD%LyR*|d zlc6QpW9brBZQ17g$You1pt? zd>zM@d=Fp;PBV<@n4*G%=O)QaUOgt!_A{Y~<&|>;DMKFDW z7=xbT8Wt@eR~T5>cVpl}gF+32Cj~MiEiH3=2E-wv3MR-=nl2$%lus<;a&Sw*cwpfp z&&xz|ig7Nfo*xOW@lr>yxUyZ2)vr?ISp>r{3=J>Z!D5n;5oJ_URE|Rci4BkM{5K)=pD9B%R~pmE4#5HB{Ixn3+yFFR|5c%kU{H`^8D)CV^9&<6V!6^N z-<_D5Af%4qU^pCl9_15>%94fL%#>usf5N%Y#4LHL7>nuaJRhOtXyz^z{i1ykGon-k zd_wtUE1+hoM`E-1`G#!Y1DFb>ZO?`U=11gK&>mirG-DVr5ff(X0WzYeZf2S>G52Ws z*8^qe?Xg{2YZ!W(se;L?-gX?qUTbHbL?v<=qgsmZZwR@{31f4!jEgiyp4h3T1t>e! z=a3ZEW7*oyK`nqGnIULnIEXPEvEVAEB6noPQ(>mFF*arv<_cxttPEjF0Oe*DD^!M5 z9=rciD6T4lv5*>z$nXH%m9D1+Gp4}J za5J^YcuYCfb6fqh7o~@CZ>81$Q}Gm25`0yH-$frA{J-aWd&7qRcW^K~c<}%3qb%$y zV3CB7Z6$X z{i0aZOv}RJ)ZSi))2`0X>Y#PxSB+ZZ0hl3)(N~PMzpSjl`AzR`otzSj(vtE?I~MCn z-r-1Ub*_Ht#kSU8OKA(m%Qh=l`)=`SGPwmp?;7-5iM8q4ugivNOgnf@`26G8FC4AS zbPy@Yyn_tqCH~NvQSny0Ilg^=9sRb*7_JjW2h(hu!r|ULKSn|@Bz!xp*3a$6*)8uS z$Wrc|Af|L9SRuMGw`RyCapmTS{-ee%#(AsBXG`vX8TVlJk=Zs-FCH zbC+_B6O>&jiaqpC9*X*xVr+5z^X?T2gUKZCu8 z^Pl@Dg8+U-cg{^RyC@qyhQI#y9!7JJIp;;BNFl@`O$kp__7Eu_~V0o?!WQyiXbgzB_46u~a8!n>0qDotjDGBZ_!>Pqu>kwZ*4To4^kUDVZ%6U4Zx3y*FrYc-3Zcd@ku zAFU*K`u4Za?~Yo8Xi;v{_qLrvuU8s>@D~ezu_zSsG35zfLMd}rVQ8t15I(W`7FeZo z>g8Xx%!Ji&B13RPz;?u)in)yAZlRecAK#oEzy9#H!L&>y+fIB2KFPA69?3NgUv)Ed z#mr~xZ7EmUFzr>dPs6KDMN3hWglJ-MR~YJlri$v4uY=+9APmA_5WNUrghg(EOSh=l zbmKXd+%R0~jfK1*GJ)NaU0|9=FT$#o{MqZ%L;10#%l|u@BFj*!Kxem31>5BR?HxRC z_vTj(3mnb*7Q|s*b+}Mf~S3JlKW4+x0jjC?P#PX6-i9*^dhBX5pR4Xkk%j9>R8@ZOC6(V^hWbKO{Yb&=XEoy zX@%PpL^sK(e(rhPWj^X)L6KqFD>h?`#Zu=VZ{BM>>B7n@l2|Hk1HWH9tnC3>k+f*% z&t7i-z5T+=G7NeRXAx1s}Xo7Bz_N(041-%X0RWL%(%*9DN;~G z74O%tODq;(b_$=wiA1gE|Dyzl#~LLkat@CfRT@_IzS$fen~C;Lflv92Fq-(CpiiEx z#<#v^SvppySDTl(po*=2bz#XwvubGZcapLtRqJ7N_y)X~u`gCQ3vU)>MXy8R3|ZmVIA`h{LN;&n_Y?)fHT5!>qQ74v9u>*l^ZmDdzm3}7ii$IkVTF> zjY|*qNey=*;&YUs$pmUGH=%ArlI3c8lZNif5cn0#U|$8RyhgaXs1VrF|MI2F|1Sfr zcX1VXga1Da*Y5ux?hhaQ|9dGLBKgbHJ>%9N7bkpMc>c?FY8IO%uNwca#rrC!4GPm4 z$|I3xL?ZbA`Dzdh_IsfZ!BOQNY4DePgvFL6_?7DN(8V1ytu`|p^@Wh3~(71#g)@~ibfY?d7E`|E&*t=IYK;lHJA;*cAUA9yIQM4#VN$!}@uC_TTtEwBL2)@Jn1i>=r3pyCadz&qi~N>P#70 zmfe{O@OO=EKa)5{iPG=trT{bap4pF(_+`t>vm%=Y6Z7Ohdg+yh8D%B+nNg*Y7e8Kv zFWV~)hQr}{)t4yxJ*u{G*w1Xt1MJw%y7kgq9R$WPDs{%h1fV}7vd_e%*!9{>Nmn1( zdMBewV}sD8 zSHm!b-CWX_m2B_j<4y${_QU5(>RXDhEkx)ei=k?sAi+p@MTh5 z&d)NUR7>L8V7O-n;?&g)M55{L=F_BnYGqX>jDeX_K4}PG2Xrnui1FC4XJP=RDBS_+ zOwa@pk&hUbm9@4N){61?78AQus0lLE*d+PiN~90o>5nO0{$IICzlZam@UZFs4G#AQ z`w#x#eUw)JuSh`o*>PX@0k4)!@m0ciB?{9k!VuSFmOF!@iJYK5X~rztLNK*>PCdSS z>qzZQqqILp{u}haNGH0T8Q7%%dwYA${Ez2{58wZ}m$G%H*L8-X0B^S!-w~Mqe$(-g z>vhA@rT-e0c7Kf@$}u*M>35oejqCrgasP8T7(RUe>wZeBTAzrdMVI|;7yn*k+W5DO zg{(z5{4ynYD#W=Tf$dM_cJH(F9-3J=Wnlhdg1VZ}6u~H0^O3k*X7AWrt`U5BWI!L4 zm(z)ys0iT8qixx6%^f$3RHB)By39N|#u>_cH(GW54-8}JgbRsx*vBUQKNudaegAp* z;Q!xC*?|+HHA-&J!JO#fVu~C_Ib{ju6Uaz>P9~_9AA(kSX8mqZQ)CP#OpIK*CFPT6 zAdwMGXJ{i{mG^`v-VSh_xHFE&nZz-@#KeU;|KF1UK5{k(!EH-J5@aat_f`WhcyoGo zs)a;v2Z~z=pN~!&W+l(LZJ1{w-fjCw=p${HbQVzd|%3@p+!vyHCn{ z8mNoRdm4<$x%V{CY34osUvCFK6G=s`;N6?I$_p|nzGAGsfF?-#4o-@%UNBR!NU;A0 zay{z$@19eV)zYDE+s6j|9}Wgh|Nn4r`0)Mrdnxx6rMZU)&CQ}Swa83sRHilTa&5@v zyTdK5p_c7p0$YVxu0LcgPM~iVR=H(J#f4LD6iV3;M%m1+D{l=?CX}Anf+aUSRlmy< z^=nSkE0K$r;H{3uTSv4O;rQO@MptA5(@f9LCUpD~N@5;9xb#pS%0qc5f2{I<0RRC1 M|BT)1UI1=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "nfconfigchart.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/nginx_config_map.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/nginx_config_map.yaml new file mode 100644 index 00000000000..3174b9eef3c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/nginx_config_map.yaml @@ -0,0 +1,56 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config +# This writes the nginx config file to the ConfigMap and deployment.yaml mounts it as a volume +# to the right place. +data: + default.conf: | + log_format client '$remote_addr - $remote_user $request_time $upstream_response_time ' + '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + server { + listen 80; + listen 5222; + listen [::]:80; + server_name localhost; + + access_log /var/log/nginx/host.access.log client; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + error_page 405 =200 $uri; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location = /nf-config/v1/config { + #access_log logs/uaa_access.log client; + # add the proper port or IP address if Nginx is not on 127.0.0.1:80 + # This results in a Bad Gateway. We could pass it back to the nf-agent + # but haven't worked out how to put a body in it here. + proxy_pass http://127.0.0.1:8123/nf-status/v1/report; + error_page 405 =200 $uri; + } + + location = /post_thing { + # turn off logging here to avoid double logging + access_log off; + error_page 405 =200 $uri; + } + + location = /nf-config/v1/delete { + #access_log logs/uaa_access.log client; + # add the proper port or IP address if Nginx is not on 127.0.0.1:80 + proxy_pass http://127.0.0.1:8123/nf-status/v1/report; + error_page 405 =200 $uri; + } + } diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/service.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/service.yaml new file mode 100644 index 00000000000..a9f1a14e49c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nfconfigchart.fullname" . }} + labels: +{{ include "nfconfigchart.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "nfconfigchart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/serviceaccount.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/serviceaccount.yaml new file mode 100644 index 00000000000..cab132a5c75 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "nfconfigchart.serviceAccountName" . }} + labels: +{{ include "nfconfigchart.labels" . | indent 4 }} +{{- end -}} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/tests/test-connection.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/tests/test-connection.yaml new file mode 100644 index 00000000000..db6b909125f --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "nfconfigchart.fullname" . }}-test-connection" + labels: +{{ include "nfconfigchart.labels" . | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "nfconfigchart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.schema.json b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.schema.json new file mode 100644 index 00000000000..4972d65822b --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.schema.json @@ -0,0 +1,134 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "additionalProperties": true, + "properties": { + "affinity": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "fullnameOverride": { + "type": "string" + }, + "image": { + "additionalProperties": false, + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "type": "object" + }, + "imagePullSecrets": { + "items": { + "anyOf": [] + }, + "type": "array" + }, + "ingress": { + "additionalProperties": false, + "properties": { + "annotations": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "enabled": { + "type": "boolean" + }, + "hosts": { + "items": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "host": { + "type": "string" + }, + "paths": { + "items": { + "anyOf": [] + }, + "type": "array" + } + }, + "type": "object" + } + ] + }, + "type": "array" + }, + "tls": { + "items": { + "anyOf": [] + }, + "type": "array" + } + }, + "type": "object" + }, + "nameOverride": { + "type": "string" + }, + "nodeSelector": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "podSecurityContext": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "securityContext": { + "additionalProperties": false, + "properties": {}, + "type": "object" + }, + "service": { + "additionalProperties": false, + "properties": { + "port": { + "type": "integer" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "serviceAccount": { + "additionalProperties": false, + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "null" + } + }, + "type": "object" + }, + "tolerations": { + "items": { + "anyOf": [] + }, + "type": "array" + } + }, + "type": "object" +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.yaml new file mode 100644 index 00000000000..de470d42f3c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/helm-charts/nfconfigchart/values.yaml @@ -0,0 +1,70 @@ +# Default values for nfconfigchart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + # Repository gets overwritten by AOSM to the Artifact Store ACR, however we've hard-coded the image name and tag in deployment.yaml + repository: sunnyclipubsunnynfagentacr2dd56aed266.azurecr.io + tag: stable + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + # I forgot to change values.mappings.yaml in NFDV to match the service port in the Helm chart when testing this + port: 5222 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nf-agent-cnf.json b/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nf-agent-cnf.json new file mode 100644 index 00000000000..33d35093cfc --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nf-agent-cnf.json @@ -0,0 +1,19 @@ +{ + "publisher_name": "sunnyclipub", + "publisher_resource_group_name": "sunny-uksouth", + "nf_name": "nf-agent-cnf", + "version": "0.1.0", + "acr_artifact_store_name": "sunny-nfagent-acr-2", + "location": "uksouth", + "images": { + "source_registry": "--this was copied here and renamed from https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/4a0479c0-b795-4d0f-96fd-c7edd2a2928f/resourceGroups/pez-nfagent-pipelines/providers/Microsoft.ContainerRegistry/registries/peznfagenttemp/overview new one was /subscriptions/c7bd9d96-70dd-4f61-af56-6e0abd8d80b5/resourceGroups/sunny-nfagent-acr-HostedResources-4CDE264A/providers/Microsoft.ContainerRegistry/registries/SunnyclipubSunnyNfagentAcre00abc1832" + }, + "helm_packages": [ + { + "name": "nf-agent-cnf", + "path_to_chart": "helm-charts/nf-agent-cnf-0.1.0.tgz", + "path_to_mappings": "", + "depends_on": [] + } + ] +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nfconfigchart.json b/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nfconfigchart.json new file mode 100644 index 00000000000..f6a97949291 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/input-nfconfigchart.json @@ -0,0 +1,21 @@ +{ + "publisher_name": "sunnyclipub", + "publisher_resource_group_name": "sunny-uksouth", + "nf_name": "nginx-basic-test", + "version": "0.1.0", + "acr_artifact_store_name": "sunny-nfagent-acr-2", + "location": "uksouth", + "images": + { + "source_registry": "this was nonsense just put something in to stop CLI complaining. The image was manually uploaded. /subscriptions/c7bd9d96-70dd-4f61-af56-6e0abd8d80b5/resourceGroups/SIMPLVM-team-CI/providers/Microsoft.ContainerRegistry/registries/a4oSIMPL" + }, + "helm_packages": [ + { + "name": "nfconfigchart", + "path_to_chart": "helm-charts/nfconfigchart-0.1.0.tgz", + "path_to_mappings": "helm-charts/nfconfigchart/nfconfigchartvalues.mappings.yaml", + "depends_on": [ + ] + } + ] +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_chart.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_chart.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_config_file.json b/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_config_file.json new file mode 100644 index 00000000000..6f2372284bc --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_config_file.json @@ -0,0 +1,16 @@ +{ + "publisher_name": "test_cnf_publisher", + "publisher_resource_group_name": "test_cnf_publisher_rg", + "nf_name": "test_cnf_nf", + "version": "1.0.0", + "acr_artifact_store_name": "test_cnf_acr", + "location": "uksouth", + "helm_packages": [ + { + "name": "invalid-package", + "path_to_chart": "src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_chart.yaml", + "path_to_mappings":"src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_mappings.yaml", + "depends_on": [] + } + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_mappings.yaml b/src/aosm/azext_aosm/tests/latest/mock_cnf/invalid_mappings.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/aosm/azext_aosm/tests/latest/mock_cnf/valid_chart.tgz b/src/aosm/azext_aosm/tests/latest/mock_cnf/valid_chart.tgz new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/aosm/azext_aosm/tests/latest/mock_nsd/input.json b/src/aosm/azext_aosm/tests/latest/mock_nsd/input.json new file mode 100644 index 00000000000..c609de96eae --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_nsd/input.json @@ -0,0 +1,20 @@ +{ + "location": "eastus", + "publisher_name": "jamie-mobile-publisher", + "publisher_resource_group_name": "Jamie-publisher", + "acr_artifact_store_name": "ubuntu-acr", + "network_functions": [ + { + "name": "ubuntu-vm-nfdg", + "version": "1.0.0", + "publisher_offering_location": "eastus", + "type": "vnf", + "multiple_instances": false, + "publisher": "jamie-mobile-publisher", + "publisher_resource_group": "Jamie-publisher" + } + ], + "nsd_name": "ubuntu", + "nsd_version": "1.0.0", + "nsdv_description": "Plain ubuntu VM" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multi_nf_nsd.json b/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multi_nf_nsd.json new file mode 100644 index 00000000000..5820cb367ba --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multi_nf_nsd.json @@ -0,0 +1,29 @@ +{ + "publisher_name": "jamie-publisher", + "publisher_resource_group_name": "Jamie-multi-NF", + "acr_artifact_store_name": "acr", + "location": "eastus", + "network_functions": [ + { + "publisher": "reference-publisher", + "publisher_resource_group": "Reference-publisher", + "name": "nginx-nfdg", + "version": "1.0.0", + "publisher_offering_location": "eastus", + "type": "cnf", + "multiple_instances": "False" + }, + { + "publisher": "reference-publisher", + "publisher_resource_group": "Reference-publisher", + "name": "ubuntu-nfdg", + "version": "1.0.0", + "publisher_offering_location": "eastus", + "type": "vnf", + "multiple_instances": false + } + ], + "nsd_name": "multinf", + "nsd_version": "1.0.1", + "nsdv_description": "Test deploying multiple NFs" +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multiple_instances.json b/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multiple_instances.json new file mode 100644 index 00000000000..0d8049734c4 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_nsd/input_multiple_instances.json @@ -0,0 +1,20 @@ +{ + "location": "eastus", + "publisher_name": "jamie-mobile-publisher", + "publisher_resource_group_name": "Jamie-publisher", + "acr_artifact_store_name": "ubuntu-acr", + "network_functions": [ + { + "name": "ubuntu-vm-nfdg", + "version": "1.0.0", + "publisher_offering_location": "eastus", + "type": "vnf", + "multiple_instances": "True", + "publisher": "jamie-mobile-publisher", + "publisher_resource_group": "Jamie-publisher" + } + ], + "nsd_name": "ubuntu", + "nsd_version": "1.0.0", + "nsdv_description": "Plain ubuntu VM" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json new file mode 100644 index 00000000000..b3a3b991a1d --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json @@ -0,0 +1,18 @@ +{ + "publisher_name": "jamie-mobile-publisher", + "publisher_resource_group_name": "Jamie-publisher", + "nf_name": "ubuntu-vm", + "version": "1.0.0", + "acr_artifact_store_name": "ubuntu-acr", + "location": "eastus", + "blob_artifact_store_name": "ubuntu-blob-store", + "image_name_parameter": "imageName", + "arm_template": { + "file_path": "ubuntu-template.json", + "version": "1.0.0" + }, + "vhd": { + "file_path": "livecd.ubuntu-cpc.azure.vhd", + "version": "1-0-0" + } +} diff --git a/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json new file mode 100644 index 00000000000..5222d940186 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json @@ -0,0 +1,21 @@ +{ + "publisher_name": "jamie-mobile-publisher", + "publisher_resource_group_name": "Jamie-publisher", + "nf_name": "ubuntu-vm", + "version": "1.0.0", + "acr_artifact_store_name": "ubuntu-acr", + "location": "eastus", + "blob_artifact_store_name": "ubuntu-blob-store", + "image_name_parameter": "imageName", + "arm_template": { + "file_path": "ubuntu-template.json", + "version": "1.0.0" + }, + "vhd": { + "blob_sas_url": "https://a/dummy/sas-url", + "version": "1-0-0", + "image_disk_size_GB": 30, + "image_hyper_v_generation": "V1", + "image_api_version": "2023-03-01" + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/mock_vnf/ubuntu-template.json b/src/aosm/azext_aosm/tests/latest/mock_vnf/ubuntu-template.json new file mode 100644 index 00000000000..378927a3fe5 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_vnf/ubuntu-template.json @@ -0,0 +1,118 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.15.31.15270", + "templateHash": "1656082395923655778" + } + }, + "parameters": { + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + }, + "subnetName": { + "type": "string" + }, + "ubuntuVmName": { + "type": "string", + "defaultValue": "ubuntu-vm" + }, + "virtualNetworkId": { + "type": "string" + }, + "sshPublicKeyAdmin": { + "type": "string" + }, + "imageName": { + "type": "string" + } + }, + "variables": { + "imageResourceGroup": "[resourceGroup().name]", + "subscriptionId": "[subscription().subscriptionId]", + "vmSizeSku": "Standard_D2s_v3" + }, + "resources": [ + { + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2021-05-01", + "name": "[format('{0}_nic', parameters('ubuntuVmName'))]", + "location": "[parameters('location')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig1", + "properties": { + "subnet": { + "id": "[format('{0}/subnets/{1}', parameters('virtualNetworkId'), parameters('subnetName'))]" + }, + "primary": true, + "privateIPAddressVersion": "IPv4" + } + } + ] + } + }, + { + "type": "Microsoft.Compute/virtualMachines", + "apiVersion": "2021-07-01", + "name": "[parameters('ubuntuVmName')]", + "location": "[parameters('location')]", + "properties": { + "hardwareProfile": { + "vmSize": "[variables('vmSizeSku')]" + }, + "storageProfile": { + "imageReference": { + "id": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', variables('subscriptionId'), variables('imageResourceGroup')), 'Microsoft.Compute/images', parameters('imageName'))]" + }, + "osDisk": { + "osType": "Linux", + "name": "[format('{0}_disk', parameters('ubuntuVmName'))]", + "createOption": "FromImage", + "caching": "ReadWrite", + "writeAcceleratorEnabled": false, + "managedDisk": "[json('{\"storageAccountType\": \"Premium_LRS\"}')]", + "deleteOption": "Delete", + "diskSizeGB": 30 + } + }, + "osProfile": { + "computerName": "[parameters('ubuntuVmName')]", + "adminUsername": "azureuser", + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "ssh": { + "publicKeys": [ + { + "path": "/home/azureuser/.ssh/authorized_keys", + "keyData": "[parameters('sshPublicKeyAdmin')]" + } + ] + }, + "provisionVMAgent": true, + "patchSettings": { + "patchMode": "ImageDefault", + "assessmentMode": "ImageDefault" + } + }, + "secrets": [], + "allowExtensionOperations": true + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]" + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]" + ] + } + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/artifact_manifest.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/artifact_manifest.bicep new file mode 100644 index 00000000000..1dddde744eb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/artifact_manifest.bicep @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an Artifact Manifest for a NSD +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestNames array +@description('The name under which to store the ARM template') +param armTemplateNames array +@description('The version that you want to name the NFM template artifact, in format A.B.C. e.g. 6.13.0. If testing for development, you can use any numbers you like.') +param armTemplateVersion string + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +resource acrArtifactManifests 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = [for (values, i) in armTemplateNames: { + parent: acrArtifactStore + name: acrManifestNames[i] + location: location + properties: { + artifacts: [ + { + artifactName: armTemplateNames[i] + artifactType: 'ArmTemplate' + artifactVersion: armTemplateVersion + } + ] + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/configMappings/ubuntu-vm-nfdg_config_mapping.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/configMappings/ubuntu-vm-nfdg_config_mapping.json new file mode 100644 index 00000000000..1d6fcf2b8f5 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/configMappings/ubuntu-vm-nfdg_config_mapping.json @@ -0,0 +1,9 @@ +{ + "deploymentParametersObject": { + "deploymentParameters": [ + "{configurationparameters('ubuntu_ConfigGroupSchema').ubuntu-vm-nfdg.deploymentParameters}" + ] + }, + "ubuntu_vm_nfdg_nfd_version": "{configurationparameters('ubuntu_ConfigGroupSchema').ubuntu-vm-nfdg.ubuntu_vm_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters('ubuntu_ConfigGroupSchema').managedIdentity}" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/nsd_definition.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/nsd_definition.bicep new file mode 100644 index 00000000000..fc8fc21b958 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/nsd_definition.bicep @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// Bicep template to create an Artifact Manifest, Config Group Schema and NSDV. +// +// Requires an existing NFDV from which the values will be populated. + +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Network Service Design Group') +param nsDesignGroup string +@description('The version of the NSDV you want to create, in format A.B.C') +param nsDesignVersion string +@description('Name of the nfvi site') +param nfviSiteName string = 'ubuntu_NFVI' + +// The publisher resource is the top level AOSM resource under which all other designer resources +// are created. +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// The artifact store is the resource in which all the artifacts required to deploy the NF are stored. +// The artifact store is created by the az aosm CLI before this template is deployed. +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created up-front, the NSD Group is the parent resource under which all NSD versions will be created. +resource nsdGroup 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups@2023-09-01' existing = { + parent: publisher + name: nsDesignGroup +} + +// The configuration group schema defines the configuration required to deploy the NSD. The NSD references this object in the +// `configurationgroupsSchemaReferences` and references the values in the schema in the `parameterValues`. +// The operator will create a config group values object that will satisfy this schema. +resource cgSchema 'Microsoft.Hybridnetwork/publishers/configurationGroupSchemas@2023-09-01' = { + parent: publisher + name: 'ubuntu_ConfigGroupSchema' + location: location + properties: { + schemaDefinition: string(loadJsonContent('schemas/ubuntu_ConfigGroupSchema.json')) + } +} + +// The NSD version +resource nsdVersion 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions@2023-09-01' = { + parent: nsdGroup + name: nsDesignVersion + location: location + properties: { + description: 'Plain ubuntu VM' + // The version state can be Preview, Active or Deprecated. + // Once in an Active state, the NSDV becomes immutable. + versionState: 'Preview' + // The `configurationgroupsSchemaReferences` field contains references to the schemas required to + // be filled out to configure this NSD. + configurationGroupSchemaReferences: { + ubuntu_ConfigGroupSchema: { + id: cgSchema.id + } + } + // This details the NFVIs that should be available in the Site object created by the operator. + nfvisFromSite: { + nfvi1: { + name: nfviSiteName + type: 'AzureCore' + } + } + // This field lists the templates that will be deployed by AOSM and the config mappings + // to the values in the CG schemas. + resourceElementTemplates: [ + { + name: 'ubuntu-vm-nfdg_nf_artifact_resource_element' + // The type of resource element can be ArmResourceDefinition, ConfigurationDefinition or NetworkFunctionDefinition. + type: 'NetworkFunctionDefinition' + // The configuration object may be different for different types of resource element. + configuration: { + // This field points AOSM at the artifact in the artifact store. + artifactProfile: { + artifactStoreReference: { + id: acrArtifactStore.id + } + artifactName: 'ubuntu-vm-nfdg_nf_artifact' + artifactVersion: '1.0.0' + } + templateType: 'ArmTemplate' + // The parameter values map values from the CG schema, to values required by the template + // deployed by this resource element. + parameterValues: string(loadJsonContent('configMappings/ubuntu-vm-nfdg_config_mapping.json')) + } + dependsOnProfile: { + installDependsOn: [] + uninstallDependsOn: [] + updateDependsOn: [] + } + } + ] + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/schemas/ubuntu_ConfigGroupSchema.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/schemas/ubuntu_ConfigGroupSchema.json new file mode 100644 index 00000000000..287fa0a6106 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/schemas/ubuntu_ConfigGroupSchema.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "ubuntu_ConfigGroupSchema", + "type": "object", + "properties": { + "ubuntu-vm-nfdg": { + "type": "object", + "properties": { + "deploymentParameters": { + "type": "object", + "properties": { + "location": { + "type": "string" + }, + "subnetName": { + "type": "string" + }, + "virtualNetworkId": { + "type": "string" + }, + "sshPublicKeyAdmin": { + "type": "string" + } + } + }, + "ubuntu_vm_nfdg_nfd_version": { + "type": "string", + "description": "The version of the ubuntu-vm-nfdg NFD to use. This version must be compatible with (have the same parameters exposed as) ubuntu-vm-nfdg." + } + }, + "required": [ + "deploymentParameters", + "ubuntu_vm_nfdg_nfd_version" + ] + }, + "managedIdentity": { + "type": "string", + "description": "The managed identity to use to deploy NFs within this SNS. This should be of the form '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. If you wish to use a system assigned identity, set this to a blank string." + } + }, + "required": [ + "ubuntu-vm-nfdg", + "managedIdentity" + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/ubuntu-vm-nfdg_nf.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/ubuntu-vm-nfdg_nf.bicep new file mode 100644 index 00000000000..4158f8c6ccb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build/ubuntu-vm-nfdg_nf.bicep @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// The template that the NSD invokes to create the Network Function from a published NFDV. + +@description('Publisher where the NFD is published') +param publisherName string = 'jamie-mobile-publisher' + +@description('Resource group where the NFD publisher exists') +param publisherResourceGroup string = 'Jamie-publisher' + +@description('NFD Group name for the Network Function') +param networkFunctionDefinitionGroupName string = 'ubuntu-vm-nfdg' + +@description('NFD version') +param ubuntu_vm_nfdg_nfd_version string + +@description('The managed identity that should be used to create the NF.') +param managedIdentity string + +param location string = 'eastus' + +param nfviType string = 'AzureCore' + +param resourceGroupId string = resourceGroup().id + +@secure() +param deploymentParametersObject object + +var deploymentParameters = deploymentParametersObject.deploymentParameters + +var identityObject = (managedIdentity == '') ? { + type: 'SystemAssigned' +} : { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity}': {} + } +} + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup(publisherResourceGroup) +} + +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: networkFunctionDefinitionGroupName +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' existing = { + parent: nfdg + name: ubuntu_vm_nfdg_nfd_version + +} + +resource nf_resource 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = [for (values, i) in deploymentParameters: { + name: 'ubuntu-vm-nfdg${i}' + location: location + identity: identityObject + properties: { + networkFunctionDefinitionVersionResourceReference: { + id: nfdv.id + idType: 'Open' + } + nfviType: nfviType + nfviId: resourceGroupId + allowSoftwareUpdate: true + configurationType: 'Secret' + secretDeploymentValues: string(values) + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/artifact_manifest.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/artifact_manifest.bicep new file mode 100644 index 00000000000..1dddde744eb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/artifact_manifest.bicep @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an Artifact Manifest for a NSD +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestNames array +@description('The name under which to store the ARM template') +param armTemplateNames array +@description('The version that you want to name the NFM template artifact, in format A.B.C. e.g. 6.13.0. If testing for development, you can use any numbers you like.') +param armTemplateVersion string + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +resource acrArtifactManifests 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = [for (values, i) in armTemplateNames: { + parent: acrArtifactStore + name: acrManifestNames[i] + location: location + properties: { + artifacts: [ + { + artifactName: armTemplateNames[i] + artifactType: 'ArmTemplate' + artifactVersion: armTemplateVersion + } + ] + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/configMappings/ubuntu-vm-nfdg_config_mapping.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/configMappings/ubuntu-vm-nfdg_config_mapping.json new file mode 100644 index 00000000000..c903aa85a35 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/configMappings/ubuntu-vm-nfdg_config_mapping.json @@ -0,0 +1,7 @@ +{ + "deploymentParametersObject": { + "deploymentParameters": "{configurationparameters('ubuntu_ConfigGroupSchema').ubuntu-vm-nfdg.deploymentParameters}" + }, + "ubuntu_vm_nfdg_nfd_version": "{configurationparameters('ubuntu_ConfigGroupSchema').ubuntu-vm-nfdg.ubuntu_vm_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters('ubuntu_ConfigGroupSchema').managedIdentity}" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/nsd_definition.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/nsd_definition.bicep new file mode 100644 index 00000000000..fc8fc21b958 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/nsd_definition.bicep @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// Bicep template to create an Artifact Manifest, Config Group Schema and NSDV. +// +// Requires an existing NFDV from which the values will be populated. + +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Network Service Design Group') +param nsDesignGroup string +@description('The version of the NSDV you want to create, in format A.B.C') +param nsDesignVersion string +@description('Name of the nfvi site') +param nfviSiteName string = 'ubuntu_NFVI' + +// The publisher resource is the top level AOSM resource under which all other designer resources +// are created. +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// The artifact store is the resource in which all the artifacts required to deploy the NF are stored. +// The artifact store is created by the az aosm CLI before this template is deployed. +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created up-front, the NSD Group is the parent resource under which all NSD versions will be created. +resource nsdGroup 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups@2023-09-01' existing = { + parent: publisher + name: nsDesignGroup +} + +// The configuration group schema defines the configuration required to deploy the NSD. The NSD references this object in the +// `configurationgroupsSchemaReferences` and references the values in the schema in the `parameterValues`. +// The operator will create a config group values object that will satisfy this schema. +resource cgSchema 'Microsoft.Hybridnetwork/publishers/configurationGroupSchemas@2023-09-01' = { + parent: publisher + name: 'ubuntu_ConfigGroupSchema' + location: location + properties: { + schemaDefinition: string(loadJsonContent('schemas/ubuntu_ConfigGroupSchema.json')) + } +} + +// The NSD version +resource nsdVersion 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions@2023-09-01' = { + parent: nsdGroup + name: nsDesignVersion + location: location + properties: { + description: 'Plain ubuntu VM' + // The version state can be Preview, Active or Deprecated. + // Once in an Active state, the NSDV becomes immutable. + versionState: 'Preview' + // The `configurationgroupsSchemaReferences` field contains references to the schemas required to + // be filled out to configure this NSD. + configurationGroupSchemaReferences: { + ubuntu_ConfigGroupSchema: { + id: cgSchema.id + } + } + // This details the NFVIs that should be available in the Site object created by the operator. + nfvisFromSite: { + nfvi1: { + name: nfviSiteName + type: 'AzureCore' + } + } + // This field lists the templates that will be deployed by AOSM and the config mappings + // to the values in the CG schemas. + resourceElementTemplates: [ + { + name: 'ubuntu-vm-nfdg_nf_artifact_resource_element' + // The type of resource element can be ArmResourceDefinition, ConfigurationDefinition or NetworkFunctionDefinition. + type: 'NetworkFunctionDefinition' + // The configuration object may be different for different types of resource element. + configuration: { + // This field points AOSM at the artifact in the artifact store. + artifactProfile: { + artifactStoreReference: { + id: acrArtifactStore.id + } + artifactName: 'ubuntu-vm-nfdg_nf_artifact' + artifactVersion: '1.0.0' + } + templateType: 'ArmTemplate' + // The parameter values map values from the CG schema, to values required by the template + // deployed by this resource element. + parameterValues: string(loadJsonContent('configMappings/ubuntu-vm-nfdg_config_mapping.json')) + } + dependsOnProfile: { + installDependsOn: [] + uninstallDependsOn: [] + updateDependsOn: [] + } + } + ] + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/schemas/ubuntu_ConfigGroupSchema.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/schemas/ubuntu_ConfigGroupSchema.json new file mode 100644 index 00000000000..5393c2ba01f --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/schemas/ubuntu_ConfigGroupSchema.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "ubuntu_ConfigGroupSchema", + "type": "object", + "properties": { + "ubuntu-vm-nfdg": { + "type": "object", + "properties": { + "deploymentParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "location": { + "type": "string" + }, + "subnetName": { + "type": "string" + }, + "virtualNetworkId": { + "type": "string" + }, + "sshPublicKeyAdmin": { + "type": "string" + } + } + } + }, + "ubuntu_vm_nfdg_nfd_version": { + "type": "string", + "description": "The version of the ubuntu-vm-nfdg NFD to use. This version must be compatible with (have the same parameters exposed as) ubuntu-vm-nfdg." + } + }, + "required": [ + "deploymentParameters", + "ubuntu_vm_nfdg_nfd_version" + ] + }, + "managedIdentity": { + "type": "string", + "description": "The managed identity to use to deploy NFs within this SNS. This should be of the form '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. If you wish to use a system assigned identity, set this to a blank string." + } + }, + "required": [ + "ubuntu-vm-nfdg", + "managedIdentity" + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/ubuntu-vm-nfdg_nf.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/ubuntu-vm-nfdg_nf.bicep new file mode 100644 index 00000000000..4158f8c6ccb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_instances/ubuntu-vm-nfdg_nf.bicep @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// The template that the NSD invokes to create the Network Function from a published NFDV. + +@description('Publisher where the NFD is published') +param publisherName string = 'jamie-mobile-publisher' + +@description('Resource group where the NFD publisher exists') +param publisherResourceGroup string = 'Jamie-publisher' + +@description('NFD Group name for the Network Function') +param networkFunctionDefinitionGroupName string = 'ubuntu-vm-nfdg' + +@description('NFD version') +param ubuntu_vm_nfdg_nfd_version string + +@description('The managed identity that should be used to create the NF.') +param managedIdentity string + +param location string = 'eastus' + +param nfviType string = 'AzureCore' + +param resourceGroupId string = resourceGroup().id + +@secure() +param deploymentParametersObject object + +var deploymentParameters = deploymentParametersObject.deploymentParameters + +var identityObject = (managedIdentity == '') ? { + type: 'SystemAssigned' +} : { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity}': {} + } +} + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup(publisherResourceGroup) +} + +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: networkFunctionDefinitionGroupName +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' existing = { + parent: nfdg + name: ubuntu_vm_nfdg_nfd_version + +} + +resource nf_resource 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = [for (values, i) in deploymentParameters: { + name: 'ubuntu-vm-nfdg${i}' + location: location + identity: identityObject + properties: { + networkFunctionDefinitionVersionResourceReference: { + id: nfdv.id + idType: 'Open' + } + nfviType: nfviType + nfviId: resourceGroupId + allowSoftwareUpdate: true + configurationType: 'Secret' + secretDeploymentValues: string(values) + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/artifact_manifest.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/artifact_manifest.bicep new file mode 100644 index 00000000000..1dddde744eb --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/artifact_manifest.bicep @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. + +// This file creates an Artifact Manifest for a NSD +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of the manifest to deploy for the ACR-backed Artifact Store') +param acrManifestNames array +@description('The name under which to store the ARM template') +param armTemplateNames array +@description('The version that you want to name the NFM template artifact, in format A.B.C. e.g. 6.13.0. If testing for development, you can use any numbers you like.') +param armTemplateVersion string + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +resource acrArtifactManifests 'Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests@2023-09-01' = [for (values, i) in armTemplateNames: { + parent: acrArtifactStore + name: acrManifestNames[i] + location: location + properties: { + artifacts: [ + { + artifactName: armTemplateNames[i] + artifactType: 'ArmTemplate' + artifactVersion: armTemplateVersion + } + ] + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/nginx-nfdg_config_mapping.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/nginx-nfdg_config_mapping.json new file mode 100644 index 00000000000..82ca9cac7d8 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/nginx-nfdg_config_mapping.json @@ -0,0 +1,10 @@ +{ + "deploymentParametersObject": { + "deploymentParameters": [ + "{configurationparameters('multinf_ConfigGroupSchema').nginx-nfdg.deploymentParameters}" + ] + }, + "nginx_nfdg_nfd_version": "{configurationparameters('multinf_ConfigGroupSchema').nginx-nfdg.nginx_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters('multinf_ConfigGroupSchema').managedIdentity}", + "customLocationId": "{configurationparameters('multinf_ConfigGroupSchema').nginx-nfdg.customLocationId}" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/ubuntu-nfdg_config_mapping.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/ubuntu-nfdg_config_mapping.json new file mode 100644 index 00000000000..af03596e75b --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/configMappings/ubuntu-nfdg_config_mapping.json @@ -0,0 +1,9 @@ +{ + "deploymentParametersObject": { + "deploymentParameters": [ + "{configurationparameters('multinf_ConfigGroupSchema').ubuntu-nfdg.deploymentParameters}" + ] + }, + "ubuntu_nfdg_nfd_version": "{configurationparameters('multinf_ConfigGroupSchema').ubuntu-nfdg.ubuntu_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters('multinf_ConfigGroupSchema').managedIdentity}" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nginx-nfdg_nf.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nginx-nfdg_nf.bicep new file mode 100644 index 00000000000..0656ec5263a --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nginx-nfdg_nf.bicep @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// The template that the NSD invokes to create the Network Function from a published NFDV. + +@description('Publisher where the NFD is published') +param publisherName string = 'reference-publisher' + +@description('Resource group where the NFD publisher exists') +param publisherResourceGroup string = 'Reference-publisher' + +@description('NFD Group name for the Network Function') +param networkFunctionDefinitionGroupName string = 'nginx-nfdg' + +@description('NFD version') +param nginx_nfdg_nfd_version string + +@description('The managed identity that should be used to create the NF.') +param managedIdentity string +@description('The custom location of the ARC-enabled AKS cluster to create the NF.') +param customLocationId string + +param location string = 'eastus' + +param nfviType string = 'AzureArcKubernetes' + +param resourceGroupId string = resourceGroup().id + +@secure() +param deploymentParametersObject object + +var deploymentParameters = deploymentParametersObject.deploymentParameters + +var identityObject = (managedIdentity == '') ? { + type: 'SystemAssigned' +} : { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity}': {} + } +} + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup(publisherResourceGroup) +} + +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: networkFunctionDefinitionGroupName +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' existing = { + parent: nfdg + name: nginx_nfdg_nfd_version + +} + +resource nf_resource 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = [for (values, i) in deploymentParameters: { + name: 'nginx-nfdg${i}' + location: location + identity: identityObject + properties: { + networkFunctionDefinitionVersionResourceReference: { + id: nfdv.id + idType: 'Open' + } + nfviType: nfviType + nfviId: customLocationId + allowSoftwareUpdate: true + configurationType: 'Secret' + secretDeploymentValues: string(values) + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nsd_definition.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nsd_definition.bicep new file mode 100644 index 00000000000..520ee5d1b60 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/nsd_definition.bicep @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// Bicep template to create an Artifact Manifest, Config Group Schema and NSDV. +// +// Requires an existing NFDV from which the values will be populated. + +param location string +@description('Name of an existing publisher, expected to be in the resource group where you deploy the template') +param publisherName string +@description('Name of an existing ACR-backed Artifact Store, deployed under the publisher.') +param acrArtifactStoreName string +@description('Name of an existing Network Service Design Group') +param nsDesignGroup string +@description('The version of the NSDV you want to create, in format A.B.C') +param nsDesignVersion string +@description('Name of the nfvi site') +param nfviSiteName string = 'multinf_NFVI' + +// The publisher resource is the top level AOSM resource under which all other designer resources +// are created. +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup() +} + +// The artifact store is the resource in which all the artifacts required to deploy the NF are stored. +// The artifact store is created by the az aosm CLI before this template is deployed. +resource acrArtifactStore 'Microsoft.HybridNetwork/publishers/artifactStores@2023-09-01' existing = { + parent: publisher + name: acrArtifactStoreName +} + +// Created up-front, the NSD Group is the parent resource under which all NSD versions will be created. +resource nsdGroup 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups@2023-09-01' existing = { + parent: publisher + name: nsDesignGroup +} + +// The configuration group schema defines the configuration required to deploy the NSD. The NSD references this object in the +// `configurationgroupsSchemaReferences` and references the values in the schema in the `parameterValues`. +// The operator will create a config group values object that will satisfy this schema. +resource cgSchema 'Microsoft.Hybridnetwork/publishers/configurationGroupSchemas@2023-09-01' = { + parent: publisher + name: 'multinf_ConfigGroupSchema' + location: location + properties: { + schemaDefinition: string(loadJsonContent('schemas/multinf_ConfigGroupSchema.json')) + } +} + +// The NSD version +resource nsdVersion 'Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions@2023-09-01' = { + parent: nsdGroup + name: nsDesignVersion + location: location + properties: { + description: 'Test deploying multiple NFs' + // The version state can be Preview, Active or Deprecated. + // Once in an Active state, the NSDV becomes immutable. + versionState: 'Preview' + // The `configurationgroupsSchemaReferences` field contains references to the schemas required to + // be filled out to configure this NSD. + configurationGroupSchemaReferences: { + multinf_ConfigGroupSchema: { + id: cgSchema.id + } + } + // This details the NFVIs that should be available in the Site object created by the operator. + nfvisFromSite: { + nfvi1: { + name: nfviSiteName + type: 'AzureCore' + } + } + // This field lists the templates that will be deployed by AOSM and the config mappings + // to the values in the CG schemas. + resourceElementTemplates: [ + { + name: 'nginx-nfdg_nf_artifact_resource_element' + // The type of resource element can be ArmResourceDefinition, ConfigurationDefinition or NetworkFunctionDefinition. + type: 'NetworkFunctionDefinition' + // The configuration object may be different for different types of resource element. + configuration: { + // This field points AOSM at the artifact in the artifact store. + artifactProfile: { + artifactStoreReference: { + id: acrArtifactStore.id + } + artifactName: 'nginx-nfdg_nf_artifact' + artifactVersion: '1.0.1' + } + templateType: 'ArmTemplate' + // The parameter values map values from the CG schema, to values required by the template + // deployed by this resource element. + parameterValues: string(loadJsonContent('configMappings/nginx-nfdg_config_mapping.json')) + } + dependsOnProfile: { + installDependsOn: [] + uninstallDependsOn: [] + updateDependsOn: [] + } + } + { + name: 'ubuntu-nfdg_nf_artifact_resource_element' + // The type of resource element can be ArmResourceDefinition, ConfigurationDefinition or NetworkFunctionDefinition. + type: 'NetworkFunctionDefinition' + // The configuration object may be different for different types of resource element. + configuration: { + // This field points AOSM at the artifact in the artifact store. + artifactProfile: { + artifactStoreReference: { + id: acrArtifactStore.id + } + artifactName: 'ubuntu-nfdg_nf_artifact' + artifactVersion: '1.0.1' + } + templateType: 'ArmTemplate' + // The parameter values map values from the CG schema, to values required by the template + // deployed by this resource element. + parameterValues: string(loadJsonContent('configMappings/ubuntu-nfdg_config_mapping.json')) + } + dependsOnProfile: { + installDependsOn: [] + uninstallDependsOn: [] + updateDependsOn: [] + } + } + ] + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/schemas/multinf_ConfigGroupSchema.json b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/schemas/multinf_ConfigGroupSchema.json new file mode 100644 index 00000000000..1d120f6c538 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/schemas/multinf_ConfigGroupSchema.json @@ -0,0 +1,75 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "multinf_ConfigGroupSchema", + "type": "object", + "properties": { + "nginx-nfdg": { + "type": "object", + "properties": { + "deploymentParameters": { + "type": "object", + "properties": { + "serviceAccount_create": { + "type": "boolean" + }, + "service_port": { + "type": "integer" + } + } + }, + "nginx_nfdg_nfd_version": { + "type": "string", + "description": "The version of the nginx-nfdg NFD to use. This version must be compatible with (have the same parameters exposed as) nginx-nfdg." + }, + "customLocationId": { + "type": "string", + "description": "The custom location ID of the ARC-Enabled AKS Cluster to deploy the CNF to. Should be of the form '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.extendedlocation/customlocations/{customLocationName}'" + } + }, + "required": [ + "deploymentParameters", + "nginx_nfdg_nfd_version", + "customLocationId" + ] + }, + "ubuntu-nfdg": { + "type": "object", + "properties": { + "deploymentParameters": { + "type": "object", + "properties": { + "location": { + "type": "string" + }, + "subnetName": { + "type": "string" + }, + "virtualNetworkId": { + "type": "string" + }, + "sshPublicKeyAdmin": { + "type": "string" + } + } + }, + "ubuntu_nfdg_nfd_version": { + "type": "string", + "description": "The version of the ubuntu-nfdg NFD to use. This version must be compatible with (have the same parameters exposed as) ubuntu-nfdg." + } + }, + "required": [ + "deploymentParameters", + "ubuntu_nfdg_nfd_version" + ] + }, + "managedIdentity": { + "type": "string", + "description": "The managed identity to use to deploy NFs within this SNS. This should be of the form '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. If you wish to use a system assigned identity, set this to a blank string." + } + }, + "required": [ + "nginx-nfdg", + "ubuntu-nfdg", + "managedIdentity" + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/ubuntu-nfdg_nf.bicep b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/ubuntu-nfdg_nf.bicep new file mode 100644 index 00000000000..8d85ac699e2 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/nsd_output/test_build_multiple_nfs/ubuntu-nfdg_nf.bicep @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Highly Confidential Material +// +// The template that the NSD invokes to create the Network Function from a published NFDV. + +@description('Publisher where the NFD is published') +param publisherName string = 'reference-publisher' + +@description('Resource group where the NFD publisher exists') +param publisherResourceGroup string = 'Reference-publisher' + +@description('NFD Group name for the Network Function') +param networkFunctionDefinitionGroupName string = 'ubuntu-nfdg' + +@description('NFD version') +param ubuntu_nfdg_nfd_version string + +@description('The managed identity that should be used to create the NF.') +param managedIdentity string + +param location string = 'eastus' + +param nfviType string = 'AzureCore' + +param resourceGroupId string = resourceGroup().id + +@secure() +param deploymentParametersObject object + +var deploymentParameters = deploymentParametersObject.deploymentParameters + +var identityObject = (managedIdentity == '') ? { + type: 'SystemAssigned' +} : { + type: 'UserAssigned' + userAssignedIdentities: { + '${managedIdentity}': {} + } +} + +resource publisher 'Microsoft.HybridNetwork/publishers@2023-09-01' existing = { + name: publisherName + scope: resourceGroup(publisherResourceGroup) +} + +resource nfdg 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups@2023-09-01' existing = { + parent: publisher + name: networkFunctionDefinitionGroupName +} + +resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions@2023-09-01' existing = { + parent: nfdg + name: ubuntu_nfdg_nfd_version + +} + +resource nf_resource 'Microsoft.HybridNetwork/networkFunctions@2023-09-01' = [for (values, i) in deploymentParameters: { + name: 'ubuntu-nfdg${i}' + location: location + identity: identityObject + properties: { + networkFunctionDefinitionVersionResourceReference: { + id: nfdv.id + idType: 'Open' + } + nfviType: nfviType + nfviId: resourceGroupId + allowSoftwareUpdate: true + configurationType: 'Secret' + secretDeploymentValues: string(values) + } +}] \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/recording_processors.py b/src/aosm/azext_aosm/tests/latest/recording_processors.py new file mode 100644 index 00000000000..ae7b36b061f --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/recording_processors.py @@ -0,0 +1,87 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# This file contains recording processors which are used to modify the testing recordings +# before they are saved to file. This is useful for removing sensitive information from +# the recordings so that we can avoid checking in secrets to the repo. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk.scenario_tests import RecordingProcessor +from azure.cli.testsdk.scenario_tests.utilities import is_text_payload +import json +import re + +MOCK_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +MOCK_SAS_URI = "https://xxxxxxxxxxxxxxx.blob.core.windows.net" +MOCK_STORAGE_ACCOUNT_SR = "&si=StorageAccountAccessPolicy&sr=xxxxxxxxxxxxxxxxxxxx" +BLOB_STORE_URI_REGEX = r"https:\/\/[a-zA-Z0-9]+\.blob\.core\.windows\.net" +STORAGE_ACCOUNT_SR_REGEX = r"&si=StorageAccountAccessPolicy&sr=.*" + + +class TokenReplacer(RecordingProcessor): + def process_response(self, response): + ACR_TOKEN = "acrToken" + ACCESS_TOKEN = "access_token" + if is_text_payload(response) and response["body"]["string"]: + try: + response_body = json.loads(response["body"]["string"]) + if ACR_TOKEN in response_body: + response_body[ACR_TOKEN] = MOCK_TOKEN + if ACCESS_TOKEN in response_body: + response_body[ACCESS_TOKEN] = MOCK_TOKEN + response["body"]["string"] = json.dumps(response_body) + except TypeError: + pass + return response + + +class SasUriReplacer(RecordingProcessor): + def process_response(self, response): + CONTAINER_CREDENTIALS = "containerCredentials" + CONTAINER_SAS_URI = "containerSasUri" + if not (is_text_payload(response) and response["body"]["string"]): + return response + + response_body = json.loads(response["body"]["string"]) + try: + if CONTAINER_CREDENTIALS not in response_body: + return response + + credentials_list = response_body[CONTAINER_CREDENTIALS] + new_credentials_list = [] + + for credential in credentials_list: + if CONTAINER_SAS_URI in credential: + credential[CONTAINER_SAS_URI] = re.sub( + BLOB_STORE_URI_REGEX, + MOCK_SAS_URI, + credential[CONTAINER_SAS_URI], + ) + credential[CONTAINER_SAS_URI] = re.sub( + STORAGE_ACCOUNT_SR_REGEX, + MOCK_STORAGE_ACCOUNT_SR, + credential[CONTAINER_SAS_URI], + ) + new_credentials_list.append(credential) + + response_body[CONTAINER_CREDENTIALS] = new_credentials_list + response["body"]["string"] = json.dumps(response_body) + except TypeError: + pass + + return response + + +class BlobStoreUriReplacer(RecordingProcessor): + def process_request(self, request): + try: + request.uri = re.sub(BLOB_STORE_URI_REGEX, MOCK_SAS_URI, request.uri) + request.uri = re.sub( + STORAGE_ACCOUNT_SR_REGEX, MOCK_STORAGE_ACCOUNT_SR, request.uri + ) + + except TypeError: + pass + + return request diff --git a/src/aosm/azext_aosm/tests/latest/recordings/test_vnf_nsd_publish_and_delete.yaml b/src/aosm/azext_aosm/tests/latest/recordings/test_vnf_nsd_publish_and_delete.yaml new file mode 100644 index 00000000000..97d2f8024d6 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/recordings/test_vnf_nsd_publish_and_delete.yaml @@ -0,0 +1,8781 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-2023-09-01"}' + headers: + cache-control: + - no-cache + content-length: + - '290' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-Publisher"}' + headers: + cache-control: + - no-cache + content-length: + - '288' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: HEAD + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001?api-version=2022-09-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Wed, 18 Oct 2023 13:38:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001", + "name": "cli_test_vnf_nsd_000001", "type": "Microsoft.Resources/resourceGroups", + "location": "uaenorth", "tags": {"product": "azurecli", "cause": "automation", + "test": "test_vnf_nsd_publish_and_delete", "date": "2023-10-18T13:38:28Z", + "module": "aosm", "autoDelete": "true", "expiresOn": "2023-11-17T13:38:28.5214058Z"}, + "properties": {"provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '471' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '265' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"location": "uaenorth", "properties": {"scope": "Private"}, "identity": + {"type": "SystemAssigned"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '100' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "name": "automated-tests-ubuntuPublisher", "type": "microsoft.hybridnetwork/publishers", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:38:32.2024151Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T13:38:32.2024151Z"}, "identity": {"principalId": "a5b8c784-46ee-4a43-b5ec-4d3a1db603af", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", "type": "SystemAssigned"}, + "properties": {"scope": "Private", "provisioningState": "Accepted"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '759' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:41 GMT + etag: + - '"0700b034-0000-3200-0000-652fdfe10000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Accepted", "startTime": "2023-10-18T13:38:40.6052037Z"}' + headers: + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:38:41 GMT + etag: + - '"0000ff14-0000-3200-0000-652fdfe00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Accepted", "startTime": "2023-10-18T13:38:40.6052037Z"}' + headers: + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:39:10 GMT + etag: + - '"0000ff14-0000-3200-0000-652fdfe00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Accepted", "startTime": "2023-10-18T13:38:40.6052037Z"}' + headers: + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:39:41 GMT + etag: + - '"0000ff14-0000-3200-0000-652fdfe00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "bf3e8c2d-86c9-48fd-a7a9-43002fa705fc*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Succeeded", "startTime": "2023-10-18T13:38:40.6052037Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '569' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:40:10 GMT + etag: + - '"00000915-0000-3200-0000-652fe02c0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "name": "automated-tests-ubuntuPublisher", "type": "microsoft.hybridnetwork/publishers", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:38:32.2024151Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T13:38:32.2024151Z"}, "identity": {"principalId": "a5b8c784-46ee-4a43-b5ec-4d3a1db603af", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", "type": "SystemAssigned"}, + "properties": {"scope": "Private", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '760' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:40:10 GMT + etag: + - '"0700c334-0000-3200-0000-652fdffa0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '291' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:40:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"location": "uaenorth", "properties": {"storeType": "AzureContainerRegistry"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '79' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "name": "ubuntu-acr", "type": "microsoft.hybridnetwork/publishers/artifactstores", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:40:13.0005011Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T13:40:13.0005011Z"}, "properties": {"storeType": "AzureContainerRegistry", + "managedResourceGroupConfiguration": {"location": "uaenorth", "name": "ubuntu-acr-HostedResources-50EFD041"}, + "provisioningState": "Accepted"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '761' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:40:17 GMT + etag: + - '"0000cdec-0000-3200-0000-652fe0400000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Accepted", "startTime": "2023-10-18T13:40:16.4028064Z"}' + headers: + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 13:40:17 GMT + etag: + - '"00000a15-0000-3200-0000-652fe0400000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "7177d2d4-da9a-4ad8-b3d4-6f5cb8a5d7d1*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Succeeded", "startTime": "2023-10-18T13:40:16.4028064Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '595' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:03:48 GMT + etag: + - '"00000f15-0000-3200-0000-652fe0c80000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "name": "ubuntu-acr", "type": "microsoft.hybridnetwork/publishers/artifactstores", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:40:13.0005011Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T13:40:13.0005011Z"}, "properties": {"storeType": "AzureContainerRegistry", + "replicationStrategy": "SingleReplication", "managedResourceGroupConfiguration": + {"name": "ubuntu-acr-HostedResources-50EFD041", "location": "uaenorth"}, "provisioningState": + "Succeeded", "storageResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ubuntu-acr-HostedResources-50EFD041/providers/Microsoft.ContainerRegistry/registries/AutomatedTestsUbuntupublisherUbuntuAcrc4f3741041"}}' + headers: + cache-control: + - no-cache + content-length: + - '1031' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:03:49 GMT + etag: + - '"000019ed-0000-3200-0000-652fe0c00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '298' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:03:49 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"location": "uaenorth", "properties": {"storeType": "AzureStorageAccount"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '76' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "name": "ubuntu-blob-store", "type": "microsoft.hybridnetwork/publishers/artifactstores", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:03:51.0828185Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:03:51.0828185Z"}, "properties": {"storeType": "AzureStorageAccount", + "managedResourceGroupConfiguration": {"location": "uaenorth", "name": "ubuntu-blob-store-HostedResources-1F1BBDBE"}, + "provisioningState": "Accepted"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '779' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:03:56 GMT + etag: + - '"000086ef-0000-3200-0000-652fe5cd0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Accepted", "startTime": "2023-10-18T14:03:56.2828932Z"}' + headers: + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:03:57 GMT + etag: + - '"00003015-0000-3200-0000-652fe5cc0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Accepted", "startTime": "2023-10-18T14:03:56.2828932Z"}' + headers: + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:04:26 GMT + etag: + - '"00003015-0000-3200-0000-652fe5cc0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Accepted", "startTime": "2023-10-18T14:03:56.2828932Z"}' + headers: + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:04:56 GMT + etag: + - '"00003015-0000-3200-0000-652fe5cc0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Accepted", "startTime": "2023-10-18T14:03:56.2828932Z"}' + headers: + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:05:26 GMT + etag: + - '"00003015-0000-3200-0000-652fe5cc0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Accepted", "startTime": "2023-10-18T14:03:56.2828932Z"}' + headers: + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:05:56 GMT + etag: + - '"00003015-0000-3200-0000-652fe5cc0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "b961b1b4-7bc7-41cc-813a-449b5145cd14*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Succeeded", "startTime": "2023-10-18T14:03:56.2828932Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:06:25 GMT + etag: + - '"00003315-0000-3200-0000-652fe65a0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "name": "ubuntu-blob-store", "type": "microsoft.hybridnetwork/publishers/artifactstores", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:03:51.0828185Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:03:51.0828185Z"}, "properties": {"storeType": "AzureStorageAccount", + "replicationStrategy": "SingleReplication", "managedResourceGroupConfiguration": + {"name": "ubuntu-blob-store-HostedResources-1F1BBDBE", "location": "uaenorth"}, + "provisioningState": "Succeeded", "storageResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ubuntu-blob-store-HostedResources-1F1BBDBE/providers/Microsoft.Storage/storageAccounts/1f1bbdbeubuntublobstore1"}}' + headers: + cache-control: + - no-cache + content-length: + - '1027' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:06:26 GMT + etag: + - '"0000caef-0000-3200-0000-652fe6460000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '312' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:06:26 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"location": "uaenorth"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '24' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "name": "ubuntu-vm-nfdg", "type": "microsoft.hybridnetwork/publishers/networkfunctiondefinitiongroups", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:06:27.8813669Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:06:27.8813669Z"}, "properties": {"provisioningState": "Accepted"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '654' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:06:34 GMT + etag: + - '"01006b8d-0000-3200-0000-652fe66b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Accepted", "startTime": "2023-10-18T14:06:34.291379Z"}' + headers: + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:06:34 GMT + etag: + - '"00003415-0000-3200-0000-652fe66a0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Accepted", "startTime": "2023-10-18T14:06:34.291379Z"}' + headers: + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:07:04 GMT + etag: + - '"00003415-0000-3200-0000-652fe66a0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Accepted", "startTime": "2023-10-18T14:06:34.291379Z"}' + headers: + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:07:34 GMT + etag: + - '"00003415-0000-3200-0000-652fe66a0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "ea40cf1b-1f7e-4ff5-ba63-dc5351eac8a8*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Succeeded", "startTime": "2023-10-18T14:06:34.291379Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '615' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:04 GMT + etag: + - '"00003715-0000-3200-0000-652fe6b70000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "name": "ubuntu-vm-nfdg", "type": "microsoft.hybridnetwork/publishers/networkfunctiondefinitiongroups", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:06:27.8813669Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:06:27.8813669Z"}, "properties": {"description": null, "provisioningState": + "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '676' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:05 GMT + etag: + - '"01007d8d-0000-3200-0000-652fe6810000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '338' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:05 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '344' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:05 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "17482952888473992305"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "saArtifactStoreName": {"type": "string", "metadata": {"description": + "Name of an existing Storage Account-backed Artifact Store, deployed under the + publisher."}}, "acrManifestName": {"type": "string", "metadata": {"description": + "Name of the manifest to deploy for the ACR-backed Artifact Store"}}, "saManifestName": + {"type": "string", "metadata": {"description": "Name of the manifest to deploy + for the Storage Account-backed Artifact Store"}}, "nfName": {"type": "string", + "metadata": {"description": "Name of Network Function. Used predominantly as + a prefix for other variable names"}}, "vhdVersion": {"type": "string", "metadata": + {"description": "The version that you want to name the NFM VHD artifact, in + format A-B-C. e.g. 6-13-0"}}, "armTemplateVersion": {"type": "string", "metadata": + {"description": "The name under which to store the ARM template"}}}, "resources": + [{"type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''saArtifactStoreName''), parameters(''saManifestName''))]", "location": + "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[format(''{0}-vhd'', parameters(''nfName''))]", "artifactType": "VhdImageFile", + "artifactVersion": "[parameters(''vhdVersion'')]"}]}}, {"type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''), parameters(''acrManifestName''))]", "location": + "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[format(''{0}-arm-template'', parameters(''nfName''))]", "artifactType": "ArmTemplate", + "artifactVersion": "[parameters(''armTemplateVersion'')]"}]}}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "saArtifactStoreName": {"value": + "ubuntu-blob-store"}, "acrManifestName": {"value": "ubuntu-vm-acr-manifest-1-0-0"}, + "saManifestName": {"value": "ubuntu-vm-sa-manifest-1-0-0"}, "nfName": {"value": + "ubuntu-vm"}, "vhdVersion": {"value": "1-0-0"}, "armTemplateVersion": {"value": + "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '2911' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/validate?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638089", + "name": "AOSM_CLI_deployment_1697638089", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "17482952888473992305", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "acrManifestName": {"type": "String", "value": + "ubuntu-vm-acr-manifest-1-0-0"}, "saManifestName": {"type": "String", "value": + "ubuntu-vm-sa-manifest-1-0-0"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "vhdVersion": {"type": "String", "value": "1-0-0"}, "armTemplateVersion": + {"type": "String", "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": + "Succeeded", "timestamp": "0001-01-01T00:00:00Z", "duration": "PT0S", "correlationId": + "bd5cc5c0-be32-4f09-bbaf-ea812660522e", "providers": [{"namespace": "Microsoft.Hybridnetwork", + "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": [], "validatedResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0"}, + {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1819' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:13 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "17482952888473992305"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "saArtifactStoreName": {"type": "string", "metadata": {"description": + "Name of an existing Storage Account-backed Artifact Store, deployed under the + publisher."}}, "acrManifestName": {"type": "string", "metadata": {"description": + "Name of the manifest to deploy for the ACR-backed Artifact Store"}}, "saManifestName": + {"type": "string", "metadata": {"description": "Name of the manifest to deploy + for the Storage Account-backed Artifact Store"}}, "nfName": {"type": "string", + "metadata": {"description": "Name of Network Function. Used predominantly as + a prefix for other variable names"}}, "vhdVersion": {"type": "string", "metadata": + {"description": "The version that you want to name the NFM VHD artifact, in + format A-B-C. e.g. 6-13-0"}}, "armTemplateVersion": {"type": "string", "metadata": + {"description": "The name under which to store the ARM template"}}}, "resources": + [{"type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''saArtifactStoreName''), parameters(''saManifestName''))]", "location": + "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[format(''{0}-vhd'', parameters(''nfName''))]", "artifactType": "VhdImageFile", + "artifactVersion": "[parameters(''vhdVersion'')]"}]}}, {"type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''), parameters(''acrManifestName''))]", "location": + "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[format(''{0}-arm-template'', parameters(''nfName''))]", "artifactType": "ArmTemplate", + "artifactVersion": "[parameters(''armTemplateVersion'')]"}]}}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "saArtifactStoreName": {"value": + "ubuntu-blob-store"}, "acrManifestName": {"value": "ubuntu-vm-acr-manifest-1-0-0"}, + "saManifestName": {"value": "ubuntu-vm-sa-manifest-1-0-0"}, "nfName": {"value": + "ubuntu-vm"}, "vhdVersion": {"value": "1-0-0"}, "armTemplateVersion": {"value": + "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '2911' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638089", + "name": "AOSM_CLI_deployment_1697638089", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "17482952888473992305", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "acrManifestName": {"type": "String", "value": + "ubuntu-vm-acr-manifest-1-0-0"}, "saManifestName": {"type": "String", "value": + "ubuntu-vm-sa-manifest-1-0-0"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "vhdVersion": {"type": "String", "value": "1-0-0"}, "armTemplateVersion": + {"type": "String", "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": + "Accepted", "timestamp": "2023-10-18T14:08:15.8809095Z", "duration": "PT0.0007626S", + "correlationId": "0139416a-834d-4cd9-b2e4-e71df7112069", "providers": [{"namespace": + "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": []}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638089/operationStatuses/08585039687912940387?api-version=2022-09-01 + cache-control: + - no-cache + content-length: + - '1300' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:16 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687912940387?api-version=2022-09-01 + response: + body: + string: '{"status": "Accepted"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:17 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687912940387?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:08:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687912940387?api-version=2022-09-01 + response: + body: + string: '{"status": "Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:16 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638089", + "name": "AOSM_CLI_deployment_1697638089", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "17482952888473992305", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "acrManifestName": {"type": "String", "value": + "ubuntu-vm-acr-manifest-1-0-0"}, "saManifestName": {"type": "String", "value": + "ubuntu-vm-sa-manifest-1-0-0"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "vhdVersion": {"type": "String", "value": "1-0-0"}, "armTemplateVersion": + {"type": "String", "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": + "Succeeded", "timestamp": "2023-10-18T14:08:53.1761725Z", "duration": "PT37.2960256S", + "correlationId": "0139416a-834d-4cd9-b2e4-e71df7112069", "providers": [{"namespace": + "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": [], "outputResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0"}, + {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1833' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:16 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0", + "name": "ubuntu-vm-sa-manifest-1-0-0", "type": "microsoft.hybridnetwork/publishers/artifactstores/artifactmanifests", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:08:21.1556817Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:08:21.1556817Z"}, "properties": {"artifacts": [{"artifactName": + "ubuntu-vm-vhd", "artifactType": "VhdImageFile", "artifactVersion": "1-0-0"}], + "artifactManifestState": "Uploading", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '849' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:17 GMT + etag: + - '"0400dd9a-0000-3200-0000-652fe6ec0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0/listCredential?api-version=2023-09-01 + response: + body: + string: '{"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ubuntu-blob-store-HostedResources-1F1BBDBE/providers/Microsoft.Storage/storageAccounts/1f1bbdbeubuntublobstore1", + "containerCredentials": [{"containerName": "ubuntuvmvhd-1-0-0", "containerSasUri": + "https://xxxxxxxxxxxxxxx.blob.core.windows.net/ubuntuvmvhd-1-0-0?sv=2021-08-06&si=StorageAccountAccessPolicy&sr=xxxxxxxxxxxxxxxxxxxx"}], + "expiry": "2023-10-19T14:09:21.0578536+00:00", "credentialType": "AzureStorageAccountToken"}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0", + "name": "ubuntu-vm-acr-manifest-1-0-0", "type": "microsoft.hybridnetwork/publishers/artifactstores/artifactmanifests", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:08:21.1244353Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:08:21.1244353Z"}, "properties": {"artifacts": [{"artifactName": + "ubuntu-vm-arm-template", "artifactType": "ArmTemplate", "artifactVersion": + "1.0.0"}], "artifactManifestState": "Uploading", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '852' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:21 GMT + etag: + - '"0400de9a-0000-3200-0000-652fe6ee0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0/listCredential?api-version=2023-09-01 + response: + body: + string: '{"username": "ubuntu-vm-acr-manifest-1-0-0", "acrToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "acrServerUrl": "https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io", + "repositories": ["ubuntu-vm-arm-template"], "expiry": "2023-10-19T14:09:24.2646249+00:00", + "credentialType": "AzureContainerRegistryScopedToken"}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:25 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-blob/12.16.0 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + x-ms-blob-content-length: + - '512' + x-ms-blob-type: + - PageBlob + x-ms-date: + - Wed, 18 Oct 2023 14:09:26 GMT + x-ms-version: + - '2022-11-02' + method: PUT + uri: https://xxxxxxxxxxxxxxx.blob.core.windows.net/ubuntuvmvhd-1-0-0/ubuntuvm-1-0-0.vhd?sv=2021-08-06&si=StorageAccountAccessPolicy&sr=xxxxxxxxxxxxxxxxxxxx + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:26 GMT + etag: + - '"0x8DBCFE3D6A6B00E"' + last-modified: + - Wed, 18 Oct 2023 14:09:26 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2022-11-02' + status: + code: 201 + message: Created +- request: + body: "61 38 6b 92 16 4b cc ac 6f d4 02 5c 6f 62 79 b9 \n8e 62 ae 07 02 1c dc + 73 5b 7a 51 e7 56 4e 4a b0 \n54 4a 93 2e 6b dd 3c b5 8b 60 fa 80 b1 80 1b 89 + \n1e 4d 7d 86 8e 25 76 58 24 8d 21 87 83 06 88 d6 \na4 fd 94 9c 66 b6 db ee + 92 46 f0 25 fc 84 bb f5 \n3f d9 49 28 ea 54 6a 2a 33 fa e0 47 eb 22 af 91 \nd4 + 34 a6 d9 fe 58 cb 54 03 35 d6 45 40 96 4e f3 \n31 ea 78 20 45 e9 f2 3a de cb + 38 53 c0 9c b2 b7 \n12 9e 57 d9 f6 1b cb 20 23 8c 86 d3 40 da 84 c3 \n22 5b + 48 61 63 e2 5f 5f 43 6d 8f 41 fc ce c1 87 \n33 e1 e2 61 63 e2 5f 5" + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '512' + Content-Type: + - application/octet-stream + If-Match: + - '"0x8DBCFE3D6A6B00E"' + User-Agent: + - azsdk-python-storage-blob/12.16.0 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + x-ms-date: + - Wed, 18 Oct 2023 14:09:27 GMT + x-ms-page-write: + - update + x-ms-range: + - bytes=0-511 + x-ms-version: + - '2022-11-02' + method: PUT + uri: https://xxxxxxxxxxxxxxx.blob.core.windows.net/ubuntuvmvhd-1-0-0/ubuntuvm-1-0-0.vhd?comp=page&sv=2021-08-06&si=StorageAccountAccessPolicy&sr=xxxxxxxxxxxxxxxxxxxx + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:26 GMT + etag: + - '"0x8DBCFE3D6BE5302"' + last-modified: + - Wed, 18 Oct 2023 14:09:27 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-blob-sequence-number: + - '0' + x-ms-content-crc64: + - iWvWqElPrJg= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2022-11-02' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/ + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '302' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:27 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-arm-template:pull,push" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-arm-template%3Apull%2Cpush + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:27 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.316667' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/ + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:27 GMT + docker-distribution-api-version: + - registry/2.0 + docker-upload-uuid: + - d7f4991b-9178-478e-91e7-b1cc43e2a9cb + location: + - /v2/ubuntu-vm-arm-template/blobs/uploads/d7f4991b-9178-478e-91e7-b1cc43e2a9cb?_nouploadcache=false&_state=d_6r7IkzYO_5Y42pShNHfyVVvDaoi77zDk-uG5xJ1-R7Ik5hbWUiOiJ1YnVudHUtdm0tYXJtLXRlbXBsYXRlIiwiVVVJRCI6ImQ3ZjQ5OTFiLTkxNzgtNDc4ZS05MWU3LWIxY2M0M2UyYTljYiIsIk9mZnNldCI6MCwiU3RhcnRlZEF0IjoiMjAyMy0xMC0xOFQxNDowOToyNy45NTI4NTkxMloifQ%3D%3D + range: + - 0-0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: "{\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n + \ \"contentVersion\": \"1.0.0.0\",\n \"metadata\": {\n \"_generator\": {\n + \ \"name\": \"bicep\",\n \"version\": \"0.8.9.13224\",\n \"templateHash\": + \"14979664264804385741\"\n }\n },\n \"parameters\": {\n \"location\": + {\n \"type\": \"string\",\n \"defaultValue\": \"[resourceGroup().location]\"\n + \ },\n \"subnetName\": {\n \"type\": \"string\"\n },\n \"ubuntuVmName\": + {\n \"type\": \"string\",\n \"defaultValue\": \"ubuntu-vm\"\n },\n + \ \"virtualNetworkId\": {\n \"type\": \"string\"\n },\n \"sshPublicKeyAdmin\": + {\n \"type\": \"string\"\n },\n \"imageName\": {\n \"type\": + \"string\"\n }\n },\n \"variables\": {\n \"imageResourceGroup\": \"[resourceGroup().name]\",\n + \ \"subscriptionId\": \"[subscription().subscriptionId]\",\n \"vmSizeSku\": + \"Standard_D2s_v3\"\n },\n \"resources\": [\n {\n \"type\": \"Microsoft.Network/networkInterfaces\",\n + \ \"apiVersion\": \"2021-05-01\",\n \"name\": \"[format('{0}_nic', + parameters('ubuntuVmName'))]\",\n \"location\": \"[parameters('location')]\",\n + \ \"properties\": {\n \"ipConfigurations\": [\n {\n \"name\": + \"ipconfig1\",\n \"properties\": {\n \"subnet\": {\n + \ \"id\": \"[format('{0}/subnets/{1}', parameters('virtualNetworkId'), + parameters('subnetName'))]\"\n },\n \"primary\": true,\n + \ \"privateIPAddressVersion\": \"IPv4\"\n }\n }\n + \ ]\n }\n },\n {\n \"type\": \"Microsoft.Compute/virtualMachines\",\n + \ \"apiVersion\": \"2021-07-01\",\n \"name\": \"[parameters('ubuntuVmName')]\",\n + \ \"location\": \"[parameters('location')]\",\n \"properties\": {\n + \ \"hardwareProfile\": {\n \"vmSize\": \"[variables('vmSizeSku')]\"\n + \ },\n \"storageProfile\": {\n \"imageReference\": {\n + \ \"id\": \"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', + variables('subscriptionId'), variables('imageResourceGroup')), 'Microsoft.Compute/images', + parameters('imageName'))]\"\n },\n \"osDisk\": {\n \"osType\": + \"Linux\",\n \"name\": \"[format('{0}_disk', parameters('ubuntuVmName'))]\",\n + \ \"createOption\": \"FromImage\",\n \"caching\": \"ReadWrite\",\n + \ \"writeAcceleratorEnabled\": false,\n \"managedDisk\": + \"[json('{\\\"storageAccountType\\\": \\\"Premium_LRS\\\"}')]\",\n \"deleteOption\": + \"Delete\",\n \"diskSizeGB\": 30\n }\n },\n \"osProfile\": + {\n \"computerName\": \"[parameters('ubuntuVmName')]\",\n \"adminUsername\": + \"azureuser\",\n \"linuxConfiguration\": {\n \"disablePasswordAuthentication\": + true,\n \"ssh\": {\n \"publicKeys\": [\n {\n + \ \"path\": \"/home/azureuser/.ssh/authorized_keys\",\n \"keyData\": + \"[parameters('sshPublicKeyAdmin')]\"\n }\n ]\n + \ },\n \"provisionVMAgent\": true,\n \"patchSettings\": + {\n \"patchMode\": \"ImageDefault\",\n \"assessmentMode\": + \"ImageDefault\"\n }\n },\n \"secrets\": [],\n + \ \"allowExtensionOperations\": true\n },\n \"networkProfile\": + {\n \"networkInterfaces\": [\n {\n \"id\": + \"[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]\"\n + \ }\n ]\n }\n },\n \"dependsOn\": [\n \"[resourceId('Microsoft.Network/networkInterfaces', + format('{0}_nic', parameters('ubuntuVmName')))]\"\n ]\n }\n ]\n}" + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '3591' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/d7f4991b-9178-478e-91e7-b1cc43e2a9cb?_nouploadcache=false&_state=d_6r7IkzYO_5Y42pShNHfyVVvDaoi77zDk-uG5xJ1-R7Ik5hbWUiOiJ1YnVudHUtdm0tYXJtLXRlbXBsYXRlIiwiVVVJRCI6ImQ3ZjQ5OTFiLTkxNzgtNDc4ZS05MWU3LWIxY2M0M2UyYTljYiIsIk9mZnNldCI6MCwiU3RhcnRlZEF0IjoiMjAyMy0xMC0xOFQxNDowOToyNy45NTI4NTkxMloifQ%3D%3D&digest=sha256%3Ae71bf56543dc33dc8e550a0c574efe9a4875754a4ddf74347e448dec2462798b + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:28 GMT + docker-content-digest: + - sha256:e71bf56543dc33dc8e550a0c574efe9a4875754a4ddf74347e448dec2462798b + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-arm-template/blobs/sha256:e71bf56543dc33dc8e550a0c574efe9a4875754a4ddf74347e448dec2462798b + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/ + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '302' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:28 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-arm-template:pull,push" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-arm-template%3Apull%2Cpush + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:28 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.3' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/ + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:28 GMT + docker-distribution-api-version: + - registry/2.0 + docker-upload-uuid: + - 6ebeb5c8-ee46-40b1-9883-7df57d243785 + location: + - /v2/ubuntu-vm-arm-template/blobs/uploads/6ebeb5c8-ee46-40b1-9883-7df57d243785?_nouploadcache=false&_state=7fG-NeCYbsCo1LSSZDDPAY7uvIypztBHBQYKaQ19a3t7Ik5hbWUiOiJ1YnVudHUtdm0tYXJtLXRlbXBsYXRlIiwiVVVJRCI6IjZlYmViNWM4LWVlNDYtNDBiMS05ODgzLTdkZjU3ZDI0Mzc4NSIsIk9mZnNldCI6MCwiU3RhcnRlZEF0IjoiMjAyMy0xMC0xOFQxNDowOToyOC42NjIxOTIxNzlaIn0%3D + range: + - 0-0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/blobs/uploads/6ebeb5c8-ee46-40b1-9883-7df57d243785?_nouploadcache=false&_state=7fG-NeCYbsCo1LSSZDDPAY7uvIypztBHBQYKaQ19a3t7Ik5hbWUiOiJ1YnVudHUtdm0tYXJtLXRlbXBsYXRlIiwiVVVJRCI6IjZlYmViNWM4LWVlNDYtNDBiMS05ODgzLTdkZjU3ZDI0Mzc4NSIsIk9mZnNldCI6MCwiU3RhcnRlZEF0IjoiMjAyMy0xMC0xOFQxNDowOToyOC42NjIxOTIxNzlaIn0%3D&digest=sha256%3Ae3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:28 GMT + docker-content-digest: + - sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-arm-template/blobs/sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: '{"schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": {"mediaType": "application/vnd.unknown.config.v1+json", "size": 0, + "digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + "layers": [{"mediaType": "application/vnd.oci.image.layer.v1.tar", "size": 3591, + "digest": "sha256:e71bf56543dc33dc8e550a0c574efe9a4875754a4ddf74347e448dec2462798b", + "annotations": {"org.opencontainers.image.title": "ubuntu_template.json"}}], + "annotations": {}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '504' + Content-Type: + - application/vnd.oci.image.manifest.v1+json + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/manifests/1.0.0 + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-arm-template", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '302' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:29 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-arm-template:pull,push" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-arm-template%3Apull%2Cpush + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:29 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.283333' + status: + code: 200 + message: OK +- request: + body: '{"schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": {"mediaType": "application/vnd.unknown.config.v1+json", "size": 0, + "digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + "layers": [{"mediaType": "application/vnd.oci.image.layer.v1.tar", "size": 3591, + "digest": "sha256:e71bf56543dc33dc8e550a0c574efe9a4875754a4ddf74347e448dec2462798b", + "annotations": {"org.opencontainers.image.title": "ubuntu_template.json"}}], + "annotations": {}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '504' + Content-Type: + - application/vnd.oci.image.manifest.v1+json + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-arm-template/manifests/1.0.0 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:09:29 GMT + docker-content-digest: + - sha256:8923fa544da97914212bc9173ec512741d331940e4a2c7b6fbad979657a5c507 + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-arm-template/manifests/sha256:8923fa544da97914212bc9173ec512741d331940e4a2c7b6fbad979657a5c507 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "162926653163819683"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "saArtifactStoreName": {"type": "string", "metadata": {"description": + "Name of an existing Storage Account-backed Artifact Store, deployed under the + publisher."}}, "nfName": {"type": "string", "metadata": {"description": "Name + of Network Function. Used predominantly as a prefix for other variable names"}}, + "nfDefinitionGroup": {"type": "string", "metadata": {"description": "Name of + an existing Network Function Definition Group"}}, "nfDefinitionVersion": {"type": + "string", "metadata": {"description": "The version of the NFDV you want to deploy, + in format A.B.C"}}, "vhdVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM VHD artifact, in format A-B-C. e.g. + 6-13-0"}}, "armTemplateVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM template artifact, in format A.B.C. + e.g. 6.13.0. If testing for development, you can use any numbers you like."}}}, + "variables": {"$fxv#0": {"$schema": "https://json-schema.org/draft-07/schema#", + "title": "DeployParametersSchema", "type": "object", "properties": {"location": + {"type": "string"}, "subnetName": {"type": "string"}, "ubuntuVmName": {"type": + "string"}, "virtualNetworkId": {"type": "string"}, "sshPublicKeyAdmin": {"type": + "string"}}}, "$fxv#1": {"imageName": "ubuntu-vmImage", "azureDeployLocation": + "{deployParameters.location}"}, "$fxv#2": {"location": "{deployParameters.location}", + "subnetName": "{deployParameters.subnetName}", "ubuntuVmName": "{deployParameters.ubuntuVmName}", + "virtualNetworkId": "{deployParameters.virtualNetworkId}", "sshPublicKeyAdmin": + "{deployParameters.sshPublicKeyAdmin}", "imageName": "ubuntu-vmImage"}}, "resources": + [{"type": "Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''nfDefinitionGroup''), parameters(''nfDefinitionVersion''))]", "location": + "[parameters(''location'')]", "properties": {"versionState": "Preview", "deployParameters": + "[string(variables(''$fxv#0''))]", "networkFunctionType": "VirtualNetworkFunction", + "networkFunctionTemplate": {"nfviType": "AzureCore", "networkFunctionApplications": + [{"artifactType": "VhdImageFile", "name": "[format(''{0}Image'', parameters(''nfName''))]", + "dependsOnProfile": null, "artifactProfile": {"vhdArtifactProfile": {"vhdName": + "[format(''{0}-vhd'', parameters(''nfName''))]", "vhdVersion": "[parameters(''vhdVersion'')]"}, + "artifactStore": {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', + parameters(''publisherName''), parameters(''saArtifactStoreName''))]"}}, "deployParametersMappingRuleProfile": + {"vhdImageMappingRuleProfile": {"userConfiguration": "[string(variables(''$fxv#1''))]"}, + "applicationEnablement": "Unknown"}}, {"artifactType": "ArmTemplate", "name": + "[parameters(''nfName'')]", "dependsOnProfile": null, "artifactProfile": {"templateArtifactProfile": + {"templateName": "[format(''{0}-arm-template'', parameters(''nfName''))]", "templateVersion": + "[parameters(''armTemplateVersion'')]"}, "artifactStore": {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', + parameters(''publisherName''), parameters(''acrArtifactStoreName''))]"}}, "deployParametersMappingRuleProfile": + {"templateMappingRuleProfile": {"templateParameters": "[string(variables(''$fxv#2''))]"}, + "applicationEnablement": "Unknown"}}]}}}]}, "parameters": {"location": {"value": + "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "saArtifactStoreName": {"value": + "ubuntu-blob-store"}, "nfName": {"value": "ubuntu-vm"}, "nfDefinitionGroup": + {"value": "ubuntu-vm-nfdg"}, "nfDefinitionVersion": {"value": "1.0.0"}, "vhdVersion": + {"value": "1-0-0"}, "armTemplateVersion": {"value": "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '4493' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/validate?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638172", + "name": "AOSM_CLI_deployment_1697638172", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "162926653163819683", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "nfDefinitionGroup": {"type": "String", "value": "ubuntu-vm-nfdg"}, "nfDefinitionVersion": + {"type": "String", "value": "1.0.0"}, "vhdVersion": {"type": "String", "value": + "1-0-0"}, "armTemplateVersion": {"type": "String", "value": "1.0.0"}}, "mode": + "Incremental", "provisioningState": "Succeeded", "timestamp": "0001-01-01T00:00:00Z", + "duration": "PT0S", "correlationId": "20c9e46c-3cb0-44a7-957e-bbfbbad3c1a2", + "providers": [{"namespace": "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": + "publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "locations": ["uaenorth"]}]}], "dependencies": [], "validatedResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkfunctiondefinitiongroups/ubuntu-vm-nfdg/networkfunctiondefinitionversions/1.0.0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1577' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:34 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "162926653163819683"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "saArtifactStoreName": {"type": "string", "metadata": {"description": + "Name of an existing Storage Account-backed Artifact Store, deployed under the + publisher."}}, "nfName": {"type": "string", "metadata": {"description": "Name + of Network Function. Used predominantly as a prefix for other variable names"}}, + "nfDefinitionGroup": {"type": "string", "metadata": {"description": "Name of + an existing Network Function Definition Group"}}, "nfDefinitionVersion": {"type": + "string", "metadata": {"description": "The version of the NFDV you want to deploy, + in format A.B.C"}}, "vhdVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM VHD artifact, in format A-B-C. e.g. + 6-13-0"}}, "armTemplateVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM template artifact, in format A.B.C. + e.g. 6.13.0. If testing for development, you can use any numbers you like."}}}, + "variables": {"$fxv#0": {"$schema": "https://json-schema.org/draft-07/schema#", + "title": "DeployParametersSchema", "type": "object", "properties": {"location": + {"type": "string"}, "subnetName": {"type": "string"}, "ubuntuVmName": {"type": + "string"}, "virtualNetworkId": {"type": "string"}, "sshPublicKeyAdmin": {"type": + "string"}}}, "$fxv#1": {"imageName": "ubuntu-vmImage", "azureDeployLocation": + "{deployParameters.location}"}, "$fxv#2": {"location": "{deployParameters.location}", + "subnetName": "{deployParameters.subnetName}", "ubuntuVmName": "{deployParameters.ubuntuVmName}", + "virtualNetworkId": "{deployParameters.virtualNetworkId}", "sshPublicKeyAdmin": + "{deployParameters.sshPublicKeyAdmin}", "imageName": "ubuntu-vmImage"}}, "resources": + [{"type": "Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''nfDefinitionGroup''), parameters(''nfDefinitionVersion''))]", "location": + "[parameters(''location'')]", "properties": {"versionState": "Preview", "deployParameters": + "[string(variables(''$fxv#0''))]", "networkFunctionType": "VirtualNetworkFunction", + "networkFunctionTemplate": {"nfviType": "AzureCore", "networkFunctionApplications": + [{"artifactType": "VhdImageFile", "name": "[format(''{0}Image'', parameters(''nfName''))]", + "dependsOnProfile": null, "artifactProfile": {"vhdArtifactProfile": {"vhdName": + "[format(''{0}-vhd'', parameters(''nfName''))]", "vhdVersion": "[parameters(''vhdVersion'')]"}, + "artifactStore": {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', + parameters(''publisherName''), parameters(''saArtifactStoreName''))]"}}, "deployParametersMappingRuleProfile": + {"vhdImageMappingRuleProfile": {"userConfiguration": "[string(variables(''$fxv#1''))]"}, + "applicationEnablement": "Unknown"}}, {"artifactType": "ArmTemplate", "name": + "[parameters(''nfName'')]", "dependsOnProfile": null, "artifactProfile": {"templateArtifactProfile": + {"templateName": "[format(''{0}-arm-template'', parameters(''nfName''))]", "templateVersion": + "[parameters(''armTemplateVersion'')]"}, "artifactStore": {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', + parameters(''publisherName''), parameters(''acrArtifactStoreName''))]"}}, "deployParametersMappingRuleProfile": + {"templateMappingRuleProfile": {"templateParameters": "[string(variables(''$fxv#2''))]"}, + "applicationEnablement": "Unknown"}}]}}}]}, "parameters": {"location": {"value": + "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "saArtifactStoreName": {"value": + "ubuntu-blob-store"}, "nfName": {"value": "ubuntu-vm"}, "nfDefinitionGroup": + {"value": "ubuntu-vm-nfdg"}, "nfDefinitionVersion": {"value": "1.0.0"}, "vhdVersion": + {"value": "1-0-0"}, "armTemplateVersion": {"value": "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + Content-Length: + - '4493' + Content-Type: + - application/json + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638172", + "name": "AOSM_CLI_deployment_1697638172", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "162926653163819683", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "nfDefinitionGroup": {"type": "String", "value": "ubuntu-vm-nfdg"}, "nfDefinitionVersion": + {"type": "String", "value": "1.0.0"}, "vhdVersion": {"type": "String", "value": + "1-0-0"}, "armTemplateVersion": {"type": "String", "value": "1.0.0"}}, "mode": + "Incremental", "provisioningState": "Accepted", "timestamp": "2023-10-18T14:09:36.7230807Z", + "duration": "PT0.0004793S", "correlationId": "50e1db5b-ce5e-452b-9ebf-c2cde5d771ae", + "providers": [{"namespace": "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": + "publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "locations": ["uaenorth"]}]}], "dependencies": []}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638172/operationStatuses/08585039687102911025?api-version=2022-09-01 + cache-control: + - no-cache + content-length: + - '1302' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687102911025?api-version=2022-09-01 + response: + body: + string: '{"status": "Accepted"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:09:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687102911025?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:10:06 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687102911025?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:10:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687102911025?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:06 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039687102911025?api-version=2022-09-01 + response: + body: + string: '{"status": "Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd publish + Connection: + - keep-alive + ParameterSetName: + - -f --definition-type + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638172", + "name": "AOSM_CLI_deployment_1697638172", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "162926653163819683", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "saArtifactStoreName": {"type": "String", + "value": "ubuntu-blob-store"}, "nfName": {"type": "String", "value": "ubuntu-vm"}, + "nfDefinitionGroup": {"type": "String", "value": "ubuntu-vm-nfdg"}, "nfDefinitionVersion": + {"type": "String", "value": "1.0.0"}, "vhdVersion": {"type": "String", "value": + "1-0-0"}, "armTemplateVersion": {"type": "String", "value": "1.0.0"}}, "mode": + "Incremental", "provisioningState": "Succeeded", "timestamp": "2023-10-18T14:11:20.2791579Z", + "duration": "PT1M43.5565565S", "correlationId": "50e1db5b-ce5e-452b-9ebf-c2cde5d771ae", + "providers": [{"namespace": "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": + "publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "locations": ["uaenorth"]}]}], "dependencies": [], "outputResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkfunctiondefinitiongroups/ubuntu-vm-nfdg/networkfunctiondefinitionversions/1.0.0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1593' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd build + Connection: + - keep-alive + ParameterSetName: + - -f --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkfunctiondefinitiongroups/ubuntu-vm-nfdg/networkfunctiondefinitionversions/1.0.0", + "name": "1.0.0", "type": "microsoft.hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:09:42.3859631Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:09:42.3859631Z"}, "properties": {"networkFunctionTemplate": + {"networkFunctionApplications": [{"artifactProfile": {"vhdArtifactProfile": + {"vhdName": "ubuntu-vm-vhd", "vhdVersion": "1-0-0"}, "artifactStore": {"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store"}}, + "deployParametersMappingRuleProfile": {"vhdImageMappingRuleProfile": {"userConfiguration": + "{\"imageName\":\"ubuntu-vmImage\",\"azureDeployLocation\":\"{deployParameters.location}\"}"}, + "applicationEnablement": "Unknown"}, "artifactType": "VhdImageFile", "dependsOnProfile": + null, "name": "ubuntu-vmImage"}, {"artifactProfile": {"templateArtifactProfile": + {"templateName": "ubuntu-vm-arm-template", "templateVersion": "1.0.0"}, "artifactStore": + {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr"}}, + "deployParametersMappingRuleProfile": {"templateMappingRuleProfile": {"templateParameters": + "{\"location\":\"{deployParameters.location}\",\"subnetName\":\"{deployParameters.subnetName}\",\"ubuntuVmName\":\"{deployParameters.ubuntuVmName}\",\"virtualNetworkId\":\"{deployParameters.virtualNetworkId}\",\"sshPublicKeyAdmin\":\"{deployParameters.sshPublicKeyAdmin}\",\"imageName\":\"ubuntu-vmImage\"}"}, + "applicationEnablement": "Unknown"}, "artifactType": "ArmTemplate", "dependsOnProfile": + null, "name": "ubuntu-vm"}], "nfviType": "AzureCore"}, "versionState": "Preview", + "description": null, "deployParameters": "{\"$schema\":\"https://json-schema.org/draft-07/schema#\",\"title\":\"DeployParametersSchema\",\"type\":\"object\",\"properties\":{\"location\":{\"type\":\"string\"},\"subnetName\":{\"type\":\"string\"},\"ubuntuVmName\":{\"type\":\"string\"},\"virtualNetworkId\":{\"type\":\"string\"},\"sshPublicKeyAdmin\":{\"type\":\"string\"}},\"required\":[\"location\",\"subnetName\",\"ubuntuVmName\",\"virtualNetworkId\",\"sshPublicKeyAdmin\"]}", + "networkFunctionType": "VirtualNetworkFunction", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '2856' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:40 GMT + etag: + - '"1c00f218-0000-3200-0000-652fe7560000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-2023-09-01"}' + headers: + cache-control: + - no-cache + content-length: + - '290' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-Publisher"}' + headers: + cache-control: + - no-cache + content-length: + - '288' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: HEAD + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001?api-version=2022-09-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:11:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001", + "name": "cli_test_vnf_nsd_000001", "type": "Microsoft.Resources/resourceGroups", + "location": "uaenorth", "tags": {"product": "azurecli", "cause": "automation", + "test": "test_vnf_nsd_publish_and_delete", "date": "2023-10-18T13:38:28Z", + "module": "aosm", "autoDelete": "true", "expiresOn": "2023-11-17T13:38:28.5214058Z"}, + "properties": {"provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '471' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "name": "automated-tests-ubuntuPublisher", "type": "microsoft.hybridnetwork/publishers", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:38:32.2024151Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T13:38:32.2024151Z"}, "identity": {"principalId": "a5b8c784-46ee-4a43-b5ec-4d3a1db603af", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", "type": "SystemAssigned"}, + "properties": {"scope": "Private", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '760' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:40 GMT + etag: + - '"0700c334-0000-3200-0000-652fdffa0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "name": "ubuntu-acr", "type": "microsoft.hybridnetwork/publishers/artifactstores", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T13:40:13.0005011Z", "lastModifiedBy": + "b8ed041c-aa91-418e-8f47-20c70abc2de1", "lastModifiedByType": "Application", + "lastModifiedAt": "2023-10-18T14:10:27.826506Z"}, "properties": {"storeType": + "AzureContainerRegistry", "replicationStrategy": "SingleReplication", "managedResourceGroupConfiguration": + {"name": "ubuntu-acr-HostedResources-50EFD041", "location": "uaenorth"}, "provisioningState": + "Succeeded", "storageResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ubuntu-acr-HostedResources-50EFD041/providers/Microsoft.ContainerRegistry/registries/AutomatedTestsUbuntupublisherUbuntuAcrc4f3741041"}}' + headers: + cache-control: + - no-cache + content-length: + - '1049' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:41 GMT + etag: + - '"00003ef0-0000-3200-0000-652fe7540000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: '{"location": "uaenorth"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '24' + Content-Type: + - application/json + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "name": "ubuntu", "type": "microsoft.hybridnetwork/publishers/networkservicedesigngroups", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:11:42.2416686Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:11:42.2416686Z"}, "properties": {"description": null, "provisioningState": + "Accepted"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '649' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:51 GMT + etag: + - '"0200bd8a-0000-3200-0000-652fe7a70000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "name": "f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "status": "Accepted", "startTime": "2023-10-18T14:11:48.2835374Z"}' + headers: + cache-control: + - no-cache + content-length: + - '582' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:11:51 GMT + etag: + - '"00004815-0000-3200-0000-652fe7a40000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "name": "f7470f64-f339-469a-8c67-2511ab04eee5*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "status": "Succeeded", "startTime": "2023-10-18T14:11:48.2835374Z", "endTime": + "2023-10-18T14:11:57.0579934Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '646' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:21 GMT + etag: + - '"00004915-0000-3200-0000-652fe7ad0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "name": "ubuntu", "type": "microsoft.hybridnetwork/publishers/networkservicedesigngroups", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:11:42.2416686Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:11:42.2416686Z"}, "properties": {"description": null, "provisioningState": + "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '650' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:21 GMT + etag: + - '"0200c28a-0000-3200-0000-652fe7ad0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "ResourceNotFound", "message": "The Resource ''Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0'' + under resource group ''cli_test_vnf_nsd_000001'' was not found. For more details + please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '346' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:22 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "9410313761093503784"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "acrManifestNames": {"type": "array", "metadata": {"description": + "Name of the manifest to deploy for the ACR-backed Artifact Store"}}, "armTemplateNames": + {"type": "array", "metadata": {"description": "The name under which to store + the ARM template"}}, "armTemplateVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM template artifact, in format A.B.C. + e.g. 6.13.0. If testing for development, you can use any numbers you like."}}}, + "resources": [{"copy": {"name": "acrArtifactManifests", "count": "[length(parameters(''armTemplateNames''))]"}, + "type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''), parameters(''acrManifestNames'')[copyIndex()])]", + "location": "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[parameters(''armTemplateNames'')[copyIndex()]]", "artifactType": "ArmTemplate", + "artifactVersion": "[parameters(''armTemplateVersion'')]"}]}}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "acrManifestNames": {"value": + ["ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"]}, "armTemplateNames": {"value": ["ubuntu-vm-nfdg_nf_artifact"]}, + "armTemplateVersion": {"value": "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '2070' + Content-Type: + - application/json + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/validate?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638345", + "name": "AOSM_CLI_deployment_1697638345", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "9410313761093503784", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "acrManifestNames": {"type": "Array", "value": + ["ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"]}, "armTemplateNames": {"type": "Array", + "value": ["ubuntu-vm-nfdg_nf_artifact"]}, "armTemplateVersion": {"type": "String", + "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": "Succeeded", + "timestamp": "0001-01-01T00:00:00Z", "duration": "PT0S", "correlationId": + "e403618b-544f-4579-be8c-95f5b315cb43", "providers": [{"namespace": "Microsoft.Hybridnetwork", + "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": [], "validatedResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1403' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "9410313761093503784"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "acrManifestNames": {"type": "array", "metadata": {"description": + "Name of the manifest to deploy for the ACR-backed Artifact Store"}}, "armTemplateNames": + {"type": "array", "metadata": {"description": "The name under which to store + the ARM template"}}, "armTemplateVersion": {"type": "string", "metadata": {"description": + "The version that you want to name the NFM template artifact, in format A.B.C. + e.g. 6.13.0. If testing for development, you can use any numbers you like."}}}, + "resources": [{"copy": {"name": "acrArtifactManifests", "count": "[length(parameters(''armTemplateNames''))]"}, + "type": "Microsoft.Hybridnetwork/publishers/artifactStores/artifactManifests", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''), parameters(''acrManifestNames'')[copyIndex()])]", + "location": "[parameters(''location'')]", "properties": {"artifacts": [{"artifactName": + "[parameters(''armTemplateNames'')[copyIndex()]]", "artifactType": "ArmTemplate", + "artifactVersion": "[parameters(''armTemplateVersion'')]"}]}}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "acrManifestNames": {"value": + ["ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"]}, "armTemplateNames": {"value": ["ubuntu-vm-nfdg_nf_artifact"]}, + "armTemplateVersion": {"value": "1.0.0"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '2070' + Content-Type: + - application/json + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638345", + "name": "AOSM_CLI_deployment_1697638345", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "9410313761093503784", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "acrManifestNames": {"type": "Array", "value": + ["ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"]}, "armTemplateNames": {"type": "Array", + "value": ["ubuntu-vm-nfdg_nf_artifact"]}, "armTemplateVersion": {"type": "String", + "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": "Accepted", + "timestamp": "2023-10-18T14:12:30.6616781Z", "duration": "PT0.0008635S", "correlationId": + "efcc0799-2a2d-4923-b43b-dbb4cb17d8db", "providers": [{"namespace": "Microsoft.Hybridnetwork", + "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": []}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638345/operationStatuses/08585039685363593619?api-version=2022-09-01 + cache-control: + - no-cache + content-length: + - '1134' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:31 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039685363593619?api-version=2022-09-01 + response: + body: + string: '{"status": "Accepted"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:12:31 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039685363593619?api-version=2022-09-01 + response: + body: + string: '{"status": "Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:20:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697638345", + "name": "AOSM_CLI_deployment_1697638345", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "9410313761093503784", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "acrManifestNames": {"type": "Array", "value": + ["ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"]}, "armTemplateNames": {"type": "Array", + "value": ["ubuntu-vm-nfdg_nf_artifact"]}, "armTemplateVersion": {"type": "String", + "value": "1.0.0"}}, "mode": "Incremental", "provisioningState": "Succeeded", + "timestamp": "2023-10-18T14:13:02.9663835Z", "duration": "PT32.3055689S", + "correlationId": "efcc0799-2a2d-4923-b43b-dbb4cb17d8db", "providers": [{"namespace": + "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": "publishers/artifactStores/artifactManifests", + "locations": ["uaenorth"]}]}], "dependencies": [], "outputResources": [{"id": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '1417' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:20:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", + "name": "ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", "type": "microsoft.hybridnetwork/publishers/artifactstores/artifactmanifests", + "location": "uaenorth", "systemData": {"createdBy": "achurchard@microsoft.com", + "createdByType": "User", "createdAt": "2023-10-18T14:12:36.4799694Z", "lastModifiedBy": + "achurchard@microsoft.com", "lastModifiedByType": "User", "lastModifiedAt": + "2023-10-18T14:12:36.4799694Z"}, "properties": {"artifacts": [{"artifactName": + "ubuntu-vm-nfdg_nf_artifact", "artifactType": "ArmTemplate", "artifactVersion": + "1.0.0"}], "artifactManifestState": "Uploading", "provisioningState": "Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '872' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:42 GMT + etag: + - '"0400e19a-0000-3200-0000-652fe7e90000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0/listCredential?api-version=2023-09-01 + response: + body: + string: '{"username": "ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", "acrToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "acrServerUrl": "https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io", + "repositories": ["ubuntu-vm-nfdg_nf_artifact"], "expiry": "2023-10-19T14:25:46.7261147+00:00", + "credentialType": "AzureContainerRegistryScopedToken"}' + headers: + cache-control: + - no-cache + content-length: + - '357' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:47 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/ + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '310' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:53 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-nfdg_nf_artifact:push,pull" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-nfdg_nf_artifact%3Apush%2Cpull + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:53 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.316667' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/ + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:25:53 GMT + docker-distribution-api-version: + - registry/2.0 + docker-upload-uuid: + - 55b370ff-243b-456a-b07b-14d627dba105 + location: + - /v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/55b370ff-243b-456a-b07b-14d627dba105?_nouploadcache=false&_state=JtxCu3YaSw78XlKjNAyGp2iDHlDDgiIxWJl7uCnAS0l7Ik5hbWUiOiJ1YnVudHUtdm0tbmZkZ19uZl9hcnRpZmFjdCIsIlVVSUQiOiI1NWIzNzBmZi0yNDNiLTQ1NmEtYjA3Yi0xNGQ2MjdkYmExMDUiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjMtMTAtMThUMTQ6MjU6NTMuNDc0NDMzMzAxWiJ9 + range: + - 0-0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: "{\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n + \ \"contentVersion\": \"1.0.0.0\",\n \"metadata\": {\n \"_generator\": + {\n \"name\": \"bicep\",\n \"version\": \"0.15.31.15270\",\n + \ \"templateHash\": \"224172526033291650\"\n }\n },\n \"parameters\": + {\n \"publisherName\": {\n \"type\": \"string\",\n \"defaultValue\": + \"automated-tests-ubuntuPublisher\",\n \"metadata\": {\n \"description\": + \"Publisher where the NFD is published\"\n }\n },\n \"publisherResourceGroup\": + {\n \"type\": \"string\",\n \"defaultValue\": \"cli_test_vnf_nsd_qme7qkr2glsiiosfl3fbcm6yr4dvelszx6icqxx4yyuwe4eary6pt4rb7n\",\n + \ \"metadata\": {\n \"description\": \"Resource group + where the NFD publisher exists\"\n }\n },\n \"networkFunctionDefinitionGroupName\": + {\n \"type\": \"string\",\n \"defaultValue\": \"ubuntu-vm-nfdg\",\n + \ \"metadata\": {\n \"description\": \"NFD Group name + for the Network Function\"\n }\n },\n \"ubuntu_vm_nfdg_nfd_version\": + {\n \"type\": \"string\",\n \"metadata\": {\n \"description\": + \"NFD version\"\n }\n },\n \"managedIdentity\": {\n + \ \"type\": \"string\",\n \"metadata\": {\n \"description\": + \"The managed identity that should be used to create the NF.\"\n }\n + \ },\n \"location\": {\n \"type\": \"string\",\n \"defaultValue\": + \"uaenorth\"\n },\n \"nfviType\": {\n \"type\": \"string\",\n + \ \"defaultValue\": \"AzureCore\"\n },\n \"resourceGroupId\": + {\n \"type\": \"string\",\n \"defaultValue\": \"[resourceGroup().id]\"\n + \ },\n \"deploymentParametersObject\": {\n \"type\": + \"secureObject\"\n }\n },\n \"variables\": {\n \"deploymentParameters\": + \"[parameters('deploymentParametersObject').deploymentParameters]\",\n \"identityObject\": + \"[if(equals(parameters('managedIdentity'), ''), createObject('type', 'SystemAssigned'), + createObject('type', 'UserAssigned', 'userAssignedIdentities', createObject(format('{0}', + parameters('managedIdentity')), createObject())))]\"\n },\n \"resources\": + [\n {\n \"copy\": {\n \"name\": \"nf_resource\",\n + \ \"count\": \"[length(variables('deploymentParameters'))]\"\n + \ },\n \"type\": \"Microsoft.HybridNetwork/networkFunctions\",\n + \ \"apiVersion\": \"2023-09-01\",\n \"name\": \"[format('ubuntu-vm-nfdg{0}', + copyIndex())]\",\n \"location\": \"[parameters('location')]\",\n + \ \"identity\": \"[variables('identityObject')]\",\n \"properties\": + {\n \"networkFunctionDefinitionVersionResourceReference\": {\n + \ \"id\": \"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', + subscription().subscriptionId, parameters('publisherResourceGroup')), 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroups/networkfunctiondefinitionversions', + parameters('publisherName'), parameters('networkFunctionDefinitionGroupName'), + parameters('ubuntu_vm_nfdg_nfd_version'))]\",\n \"idType\": + \"Open\"\n },\n \"nfviType\": \"[parameters('nfviType')]\",\n + \ \"nfviId\": \"[parameters('resourceGroupId')]\",\n \"allowSoftwareUpdate\": + true,\n \"configurationType\": \"Secret\",\n \"secretDeploymentValues\": + \"[string(variables('deploymentParameters')[copyIndex()])]\"\n }\n + \ }\n ]\n}" + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '3634' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/55b370ff-243b-456a-b07b-14d627dba105?_nouploadcache=false&_state=JtxCu3YaSw78XlKjNAyGp2iDHlDDgiIxWJl7uCnAS0l7Ik5hbWUiOiJ1YnVudHUtdm0tbmZkZ19uZl9hcnRpZmFjdCIsIlVVSUQiOiI1NWIzNzBmZi0yNDNiLTQ1NmEtYjA3Yi0xNGQ2MjdkYmExMDUiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjMtMTAtMThUMTQ6MjU6NTMuNDc0NDMzMzAxWiJ9&digest=sha256%3A375e1c0899366f1a4c35c2151ac7c1431ad52ad49d1b4c5b5ce8a2f1add7e36e + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:25:53 GMT + docker-content-digest: + - sha256:375e1c0899366f1a4c35c2151ac7c1431ad52ad49d1b4c5b5ce8a2f1add7e36e + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-nfdg_nf_artifact/blobs/sha256:375e1c0899366f1a4c35c2151ac7c1431ad52ad49d1b4c5b5ce8a2f1add7e36e + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/ + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '310' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:53 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-nfdg_nf_artifact:pull,push" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-nfdg_nf_artifact%3Apull%2Cpush + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:54 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.3' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: POST + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/ + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:25:54 GMT + docker-distribution-api-version: + - registry/2.0 + docker-upload-uuid: + - d22110b6-d772-48e3-bf3b-04e4ce643eae + location: + - /v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/d22110b6-d772-48e3-bf3b-04e4ce643eae?_nouploadcache=false&_state=qCFRAnhotjGMxuG5YCwxEDgF1NablZcPQrukI__ajwl7Ik5hbWUiOiJ1YnVudHUtdm0tbmZkZ19uZl9hcnRpZmFjdCIsIlVVSUQiOiJkMjIxMTBiNi1kNzcyLTQ4ZTMtYmYzYi0wNGU0Y2U2NDNlYWUiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjMtMTAtMThUMTQ6MjU6NTQuMjA0NzQxMjk2WiJ9 + range: + - 0-0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/octet-stream + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/blobs/uploads/d22110b6-d772-48e3-bf3b-04e4ce643eae?_nouploadcache=false&_state=qCFRAnhotjGMxuG5YCwxEDgF1NablZcPQrukI__ajwl7Ik5hbWUiOiJ1YnVudHUtdm0tbmZkZ19uZl9hcnRpZmFjdCIsIlVVSUQiOiJkMjIxMTBiNi1kNzcyLTQ4ZTMtYmYzYi0wNGU0Y2U2NDNlYWUiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjMtMTAtMThUMTQ6MjU6NTQuMjA0NzQxMjk2WiJ9&digest=sha256%3Ae3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:25:54 GMT + docker-content-digest: + - sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-nfdg_nf_artifact/blobs/sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: '{"schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": {"mediaType": "application/vnd.unknown.config.v1+json", "size": 0, + "digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + "layers": [{"mediaType": "application/vnd.oci.image.layer.v1.tar", "size": 3634, + "digest": "sha256:375e1c0899366f1a4c35c2151ac7c1431ad52ad49d1b4c5b5ce8a2f1add7e36e", + "annotations": {"org.opencontainers.image.title": "nf_definition.json"}}], "annotations": + {}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '502' + Content-Type: + - application/vnd.oci.image.manifest.v1+json + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/manifests/1.0.0 + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "pull"}, {"Type": + "repository", "Name": "ubuntu-vm-nfdg_nf_artifact", "Action": "push"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '310' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:54 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token",service="automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io",scope="repository:ubuntu-vm-nfdg_nf_artifact:pull,push" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Service: + - automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io + User-Agent: + - oras-py + method: GET + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/oauth2/token?service=automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io&scope=repository%3Aubuntu-vm-nfdg_nf_artifact%3Apull%2Cpush + response: + body: + string: '{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:25:54 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '333.283333' + status: + code: 200 + message: OK +- request: + body: '{"schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": {"mediaType": "application/vnd.unknown.config.v1+json", "size": 0, + "digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + "layers": [{"mediaType": "application/vnd.oci.image.layer.v1.tar", "size": 3634, + "digest": "sha256:375e1c0899366f1a4c35c2151ac7c1431ad52ad49d1b4c5b5ce8a2f1add7e36e", + "annotations": {"org.opencontainers.image.title": "nf_definition.json"}}], "annotations": + {}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '502' + Content-Type: + - application/vnd.oci.image.manifest.v1+json + User-Agent: + - python-requests/2.26.0 + method: PUT + uri: https://automatedtestsubuntupublisherubuntuacrc4f3741041.azurecr.io/v2/ubuntu-vm-nfdg_nf_artifact/manifests/1.0.0 + response: + body: + string: '' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '0' + date: + - Wed, 18 Oct 2023 14:26:00 GMT + docker-content-digest: + - sha256:2011ec987725418a15590818992a2e016e8b2a9feef2bd1c9481dce060e95180 + docker-distribution-api-version: + - registry/2.0 + location: + - /v2/ubuntu-vm-nfdg_nf_artifact/manifests/sha256:2011ec987725418a15590818992a2e016e8b2a9feef2bd1c9481dce060e95180 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "14831763147023388379"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "nsDesignGroup": {"type": "string", "metadata": {"description": + "Name of an existing Network Service Design Group"}}, "nsDesignVersion": {"type": + "string", "metadata": {"description": "The version of the NSDV you want to create, + in format A.B.C"}}, "nfviSiteName": {"type": "string", "defaultValue": "ubuntu_NFVI", + "metadata": {"description": "Name of the nfvi site"}}}, "variables": {"$fxv#0": + {"$schema": "https://json-schema.org/draft-07/schema#", "title": "ubuntu_ConfigGroupSchema", + "type": "object", "properties": {"ubuntu-vm-nfdg": {"type": "object", "properties": + {"deploymentParameters": {"type": "object", "properties": {"location": {"type": + "string"}, "subnetName": {"type": "string"}, "ubuntuVmName": {"type": "string"}, + "virtualNetworkId": {"type": "string"}, "sshPublicKeyAdmin": {"type": "string"}}}, + "ubuntu_vm_nfdg_nfd_version": {"type": "string", "description": "The version + of the ubuntu-vm-nfdg NFD to use. This version must be compatible with (have + the same parameters exposed as) ubuntu-vm-nfdg."}}, "required": ["deploymentParameters", + "ubuntu_vm_nfdg_nfd_version"]}, "managedIdentity": {"type": "string", "description": + "The managed identity to use to deploy NFs within this SNS. This should be + of the form ''/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. If + you wish to use a system assigned identity, set this to a blank string."}}, + "required": ["ubuntu-vm-nfdg", "managedIdentity"]}, "$fxv#1": {"deploymentParametersObject": + {"deploymentParameters": ["{configurationparameters(''ubuntu_ConfigGroupSchema'').ubuntu-vm-nfdg.deploymentParameters}"]}, + "ubuntu_vm_nfdg_nfd_version": "{configurationparameters(''ubuntu_ConfigGroupSchema'').ubuntu-vm-nfdg.ubuntu_vm_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters(''ubuntu_ConfigGroupSchema'').managedIdentity}"}}, + "resources": [{"type": "Microsoft.Hybridnetwork/publishers/configurationGroupSchemas", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}'', parameters(''publisherName''), + ''ubuntu_ConfigGroupSchema'')]", "location": "[parameters(''location'')]", "properties": + {"schemaDefinition": "[string(variables(''$fxv#0''))]"}}, {"type": "Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''nsDesignGroup''), parameters(''nsDesignVersion''))]", "location": + "[parameters(''location'')]", "properties": {"description": "Plain ubuntu VM", + "versionState": "Preview", "configurationGroupSchemaReferences": {"ubuntu_ConfigGroupSchema": + {"id": "[resourceId(''Microsoft.Hybridnetwork/publishers/configurationGroupSchemas'', + parameters(''publisherName''), ''ubuntu_ConfigGroupSchema'')]"}}, "nfvisFromSite": + {"nfvi1": {"name": "[parameters(''nfviSiteName'')]", "type": "AzureCore"}}, + "resourceElementTemplates": [{"name": "ubuntu-vm-nfdg_nf_artifact_resource_element", + "type": "NetworkFunctionDefinition", "configuration": {"artifactProfile": {"artifactStoreReference": + {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''))]"}, "artifactName": "ubuntu-vm-nfdg_nf_artifact", + "artifactVersion": "1.0.0"}, "templateType": "ArmTemplate", "parameterValues": + "[string(variables(''$fxv#1''))]"}, "dependsOnProfile": {"installDependsOn": + [], "uninstallDependsOn": [], "updateDependsOn": []}}]}, "dependsOn": ["[resourceId(''Microsoft.Hybridnetwork/publishers/configurationGroupSchemas'', + parameters(''publisherName''), ''ubuntu_ConfigGroupSchema'')]"]}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "nsDesignGroup": {"value": + "ubuntu"}, "nsDesignVersion": {"value": "1.0.0"}, "nfviSiteName": {"value": + "ubuntu_NFVI"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '4560' + Content-Type: + - application/json + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/validate?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697639164", + "name": "AOSM_CLI_deployment_1697639164", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "14831763147023388379", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "nsDesignGroup": {"type": "String", "value": + "ubuntu"}, "nsDesignVersion": {"type": "String", "value": "1.0.0"}, "nfviSiteName": + {"type": "String", "value": "ubuntu_NFVI"}}, "mode": "Incremental", "provisioningState": + "Succeeded", "timestamp": "0001-01-01T00:00:00Z", "duration": "PT0S", "correlationId": + "fc094be4-8edd-42e9-aafd-5e4049d17f6c", "providers": [{"namespace": "Microsoft.Hybridnetwork", + "resourceTypes": [{"resourceType": "publishers/configurationGroupSchemas", + "locations": ["uaenorth"]}, {"resourceType": "publishers/networkservicedesigngroups/networkservicedesignversions", + "locations": ["uaenorth"]}]}], "dependencies": [{"dependsOn": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "resourceType": "Microsoft.Hybridnetwork/publishers/configurationGroupSchemas", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu_ConfigGroupSchema"}], + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkservicedesigngroups/ubuntu/networkservicedesignversions/1.0.0", + "resourceType": "Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu/1.0.0"}], "validatedResources": + [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema"}, + {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkservicedesigngroups/ubuntu/networkservicedesignversions/1.0.0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '2494' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:26:06 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "metadata": {"_generator": {"name": "bicep", "version": + "0.15.31.15270", "templateHash": "14831763147023388379"}}, "parameters": {"location": + {"type": "string"}, "publisherName": {"type": "string", "metadata": {"description": + "Name of an existing publisher, expected to be in the resource group where you + deploy the template"}}, "acrArtifactStoreName": {"type": "string", "metadata": + {"description": "Name of an existing ACR-backed Artifact Store, deployed under + the publisher."}}, "nsDesignGroup": {"type": "string", "metadata": {"description": + "Name of an existing Network Service Design Group"}}, "nsDesignVersion": {"type": + "string", "metadata": {"description": "The version of the NSDV you want to create, + in format A.B.C"}}, "nfviSiteName": {"type": "string", "defaultValue": "ubuntu_NFVI", + "metadata": {"description": "Name of the nfvi site"}}}, "variables": {"$fxv#0": + {"$schema": "https://json-schema.org/draft-07/schema#", "title": "ubuntu_ConfigGroupSchema", + "type": "object", "properties": {"ubuntu-vm-nfdg": {"type": "object", "properties": + {"deploymentParameters": {"type": "object", "properties": {"location": {"type": + "string"}, "subnetName": {"type": "string"}, "ubuntuVmName": {"type": "string"}, + "virtualNetworkId": {"type": "string"}, "sshPublicKeyAdmin": {"type": "string"}}}, + "ubuntu_vm_nfdg_nfd_version": {"type": "string", "description": "The version + of the ubuntu-vm-nfdg NFD to use. This version must be compatible with (have + the same parameters exposed as) ubuntu-vm-nfdg."}}, "required": ["deploymentParameters", + "ubuntu_vm_nfdg_nfd_version"]}, "managedIdentity": {"type": "string", "description": + "The managed identity to use to deploy NFs within this SNS. This should be + of the form ''/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. If + you wish to use a system assigned identity, set this to a blank string."}}, + "required": ["ubuntu-vm-nfdg", "managedIdentity"]}, "$fxv#1": {"deploymentParametersObject": + {"deploymentParameters": ["{configurationparameters(''ubuntu_ConfigGroupSchema'').ubuntu-vm-nfdg.deploymentParameters}"]}, + "ubuntu_vm_nfdg_nfd_version": "{configurationparameters(''ubuntu_ConfigGroupSchema'').ubuntu-vm-nfdg.ubuntu_vm_nfdg_nfd_version}", + "managedIdentity": "{configurationparameters(''ubuntu_ConfigGroupSchema'').managedIdentity}"}}, + "resources": [{"type": "Microsoft.Hybridnetwork/publishers/configurationGroupSchemas", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}'', parameters(''publisherName''), + ''ubuntu_ConfigGroupSchema'')]", "location": "[parameters(''location'')]", "properties": + {"schemaDefinition": "[string(variables(''$fxv#0''))]"}}, {"type": "Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions", + "apiVersion": "2023-09-01", "name": "[format(''{0}/{1}/{2}'', parameters(''publisherName''), + parameters(''nsDesignGroup''), parameters(''nsDesignVersion''))]", "location": + "[parameters(''location'')]", "properties": {"description": "Plain ubuntu VM", + "versionState": "Preview", "configurationGroupSchemaReferences": {"ubuntu_ConfigGroupSchema": + {"id": "[resourceId(''Microsoft.Hybridnetwork/publishers/configurationGroupSchemas'', + parameters(''publisherName''), ''ubuntu_ConfigGroupSchema'')]"}}, "nfvisFromSite": + {"nfvi1": {"name": "[parameters(''nfviSiteName'')]", "type": "AzureCore"}}, + "resourceElementTemplates": [{"name": "ubuntu-vm-nfdg_nf_artifact_resource_element", + "type": "NetworkFunctionDefinition", "configuration": {"artifactProfile": {"artifactStoreReference": + {"id": "[resourceId(''Microsoft.HybridNetwork/publishers/artifactStores'', parameters(''publisherName''), + parameters(''acrArtifactStoreName''))]"}, "artifactName": "ubuntu-vm-nfdg_nf_artifact", + "artifactVersion": "1.0.0"}, "templateType": "ArmTemplate", "parameterValues": + "[string(variables(''$fxv#1''))]"}, "dependsOnProfile": {"installDependsOn": + [], "uninstallDependsOn": [], "updateDependsOn": []}}]}, "dependsOn": ["[resourceId(''Microsoft.Hybridnetwork/publishers/configurationGroupSchemas'', + parameters(''publisherName''), ''ubuntu_ConfigGroupSchema'')]"]}]}, "parameters": + {"location": {"value": "uaenorth"}, "publisherName": {"value": "automated-tests-ubuntuPublisher"}, + "acrArtifactStoreName": {"value": "ubuntu-acr"}, "nsDesignGroup": {"value": + "ubuntu"}, "nsDesignVersion": {"value": "1.0.0"}, "nfviSiteName": {"value": + "ubuntu_NFVI"}}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + Content-Length: + - '4560' + Content-Type: + - application/json + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697639164", + "name": "AOSM_CLI_deployment_1697639164", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "14831763147023388379", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "nsDesignGroup": {"type": "String", "value": + "ubuntu"}, "nsDesignVersion": {"type": "String", "value": "1.0.0"}, "nfviSiteName": + {"type": "String", "value": "ubuntu_NFVI"}}, "mode": "Incremental", "provisioningState": + "Accepted", "timestamp": "2023-10-18T14:26:09.8001Z", "duration": "PT0.0006866S", + "correlationId": "68d53d12-c962-4078-93b5-7c791983f5a4", "providers": [{"namespace": + "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": "publishers/configurationGroupSchemas", + "locations": ["uaenorth"]}, {"resourceType": "publishers/networkservicedesigngroups/networkservicedesignversions", + "locations": ["uaenorth"]}]}], "dependencies": [{"dependsOn": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "resourceType": "Microsoft.Hybridnetwork/publishers/configurationGroupSchemas", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu_ConfigGroupSchema"}], + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkservicedesigngroups/ubuntu/networkservicedesignversions/1.0.0", + "resourceType": "Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu/1.0.0"}]}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697639164/operationStatuses/08585039677173127677?api-version=2022-09-01 + cache-control: + - no-cache + content-length: + - '2004' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:26:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039677173127677?api-version=2022-09-01 + response: + body: + string: '{"status": "Accepted"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:26:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039677173127677?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:26:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039677173127677?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:27:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039677173127677?api-version=2022-09-01 + response: + body: + string: '{"status": "Running"}' + headers: + cache-control: + - no-cache + content-length: + - '21' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:27:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585039677173127677?api-version=2022-09-01 + response: + body: + string: '{"status": "Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd publish + Connection: + - keep-alive + ParameterSetName: + - -f + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2022-09-01 + response: + body: + string: '{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Resources/deployments/AOSM_CLI_deployment_1697639164", + "name": "AOSM_CLI_deployment_1697639164", "type": "Microsoft.Resources/deployments", + "properties": {"templateHash": "14831763147023388379", "parameters": {"location": + {"type": "String", "value": "uaenorth"}, "publisherName": {"type": "String", + "value": "automated-tests-ubuntuPublisher"}, "acrArtifactStoreName": {"type": + "String", "value": "ubuntu-acr"}, "nsDesignGroup": {"type": "String", "value": + "ubuntu"}, "nsDesignVersion": {"type": "String", "value": "1.0.0"}, "nfviSiteName": + {"type": "String", "value": "ubuntu_NFVI"}}, "mode": "Incremental", "provisioningState": + "Succeeded", "timestamp": "2023-10-18T14:27:50.8828306Z", "duration": "PT1M41.0834172S", + "correlationId": "68d53d12-c962-4078-93b5-7c791983f5a4", "providers": [{"namespace": + "Microsoft.Hybridnetwork", "resourceTypes": [{"resourceType": "publishers/configurationGroupSchemas", + "locations": ["uaenorth"]}, {"resourceType": "publishers/networkservicedesigngroups/networkservicedesignversions", + "locations": ["uaenorth"]}]}], "dependencies": [{"dependsOn": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "resourceType": "Microsoft.Hybridnetwork/publishers/configurationGroupSchemas", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu_ConfigGroupSchema"}], + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkservicedesigngroups/ubuntu/networkservicedesignversions/1.0.0", + "resourceType": "Microsoft.Hybridnetwork/publishers/networkservicedesigngroups/networkservicedesignversions", + "resourceName": "automated-tests-ubuntuPublisher/ubuntu/1.0.0"}], "outputResources": + [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema"}, + {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.Hybridnetwork/publishers/automated-tests-ubuntuPublisher/networkservicedesigngroups/ubuntu/networkservicedesignversions/1.0.0"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '2510' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-2023-09-01"}' + headers: + cache-control: + - no-cache + content-length: + - '290' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-Publisher"}' + headers: + cache-control: + - no-cache + content-length: + - '288' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu/networkServiceDesignVersions/1.0.0?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:21 GMT + etag: + - '"6b002c53-0000-3200-0000-652feb860000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "name": "8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu/networkServiceDesignVersions/1.0.0", + "status": "Deleting", "startTime": "2023-10-18T14:28:18.2913406Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '617' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:21 GMT + etag: + - '"00005a15-0000-3200-0000-652feb820000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "name": "8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu/networkServiceDesignVersions/1.0.0", + "status": "Succeeded", "startTime": "2023-10-18T14:28:18.2913406Z", "endTime": + "2023-10-18T14:28:34.6929438Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '681' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:51 GMT + etag: + - '"00005b15-0000-3200-0000-652feb920000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "name": "8d779970-9490-4a00-831f-213151746155*E88B263ED337FF76C2D622550441DD41C00F955FD1DD7EA56D77D1FB17FF2C31", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu/networkServiceDesignVersions/1.0.0", + "status": "Succeeded", "startTime": "2023-10-18T14:28:18.2913406Z", "endTime": + "2023-10-18T14:28:34.6929438Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '681' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:51 GMT + etag: + - '"00005b15-0000-3200-0000-652feb920000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:57 GMT + etag: + - '"0400e29a-0000-3200-0000-652febaa0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14998' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "name": "fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", + "status": "Deleting", "startTime": "2023-10-18T14:28:55.2143789Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '629' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:28:59 GMT + etag: + - '"00005c15-0000-3200-0000-652feba70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "name": "fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:28:55.2143789Z", "endTime": + "2023-10-18T14:29:20.0194214Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '693' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:29:28 GMT + etag: + - '"00005d15-0000-3200-0000-652febc00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "name": "fdcac423-e8de-4316-91e3-b330020c8439*04D828A0BC42F9FD0D331CDBE7E05FBB6E6E4EE184AB19A69FCD9813BBC707D8", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-nfdg-nf-acr-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:28:55.2143789Z", "endTime": + "2023-10-18T14:29:20.0194214Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '693' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:29:28 GMT + etag: + - '"00005d15-0000-3200-0000-652febc00000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:29:34 GMT + etag: + - '"0100d40e-0000-3200-0000-652febce0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14997' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "name": "973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "status": "Deleting", "startTime": "2023-10-18T14:29:31.4080127Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '599' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:29:34 GMT + etag: + - '"00005e15-0000-3200-0000-652febcb0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "name": "973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "status": "Succeeded", "startTime": "2023-10-18T14:29:31.4080127Z", "endTime": + "2023-10-18T14:29:38.9124764Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '663' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:03 GMT + etag: + - '"00005f15-0000-3200-0000-652febd30000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "name": "973bb0a5-ba72-4d04-ba65-4b6d6c854d1d*9DF3B8143E719DF91DFC194B2DDB94A503AB3B0DDDB65606A2F75DDC1540DFD5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/configurationGroupSchemas/ubuntu_ConfigGroupSchema", + "status": "Succeeded", "startTime": "2023-10-18T14:29:31.4080127Z", "endTime": + "2023-10-18T14:29:38.9124764Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '663' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:03 GMT + etag: + - '"00005f15-0000-3200-0000-652febd30000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:10 GMT + etag: + - '"0200c08f-0000-3200-0000-652febf20000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14996' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "name": "b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "status": "Deleting", "startTime": "2023-10-18T14:30:08.4068021Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '582' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:10 GMT + etag: + - '"00006015-0000-3200-0000-652febf00000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "name": "b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "status": "Succeeded", "startTime": "2023-10-18T14:30:08.4068021Z", "endTime": + "2023-10-18T14:30:16.3047192Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '646' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:40 GMT + etag: + - '"00006215-0000-3200-0000-652febf80000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nsd delete + Connection: + - keep-alive + ParameterSetName: + - -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "name": "b01d9f94-f6cf-49ca-bf3d-886ef876bed0*07B306C85FFAFCD22DF0677DA697E92BF9D641954995CBCE968C98ADC599FA3F", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkServiceDesignGroups/ubuntu", + "status": "Succeeded", "startTime": "2023-10-18T14:30:08.4068021Z", "endTime": + "2023-10-18T14:30:16.3047192Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '646' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:40 GMT + etag: + - '"00006215-0000-3200-0000-652febf80000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-2023-09-01", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-2023-09-01"}' + headers: + cache-control: + - no-cache + content-length: + - '290' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher?api-version=2021-07-01 + response: + body: + string: '{"properties": {"state": "Registered"}, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Features/providers/Microsoft.HybridNetwork/features/Allow-Publisher", + "type": "Microsoft.Features/providers/features", "name": "Microsoft.HybridNetwork/Allow-Publisher"}' + headers: + cache-control: + - no-cache + content-length: + - '288' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:45 GMT + etag: + - '"1c002f33-0000-3200-0000-652fec150000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "name": "4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0", + "status": "Deleting", "startTime": "2023-10-18T14:30:44.6894841Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '635' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:30:45 GMT + etag: + - '"00006315-0000-3200-0000-652fec140000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "name": "4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0", + "status": "Deleting", "startTime": "2023-10-18T14:30:44.6894841Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '635' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:31:15 GMT + etag: + - '"00006315-0000-3200-0000-652fec140000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "name": "4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0", + "status": "Deleting", "startTime": "2023-10-18T14:30:44.6894841Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '635' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:31:44 GMT + etag: + - '"00006315-0000-3200-0000-652fec140000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "name": "4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0", + "status": "Succeeded", "startTime": "2023-10-18T14:30:44.6894841Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '656' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:14 GMT + etag: + - '"00006615-0000-3200-0000-652fec620000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "name": "4192fd7c-b0b0-4b0e-96a2-c77f43a1be4e*F84C1FD746CF0428B936256E6F68F15D7B48D7A2FD0C6737E46476EC83657278", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg/networkFunctionDefinitionVersions/1.0.0", + "status": "Succeeded", "startTime": "2023-10-18T14:30:44.6894841Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '656' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:15 GMT + etag: + - '"00006615-0000-3200-0000-652fec620000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:23 GMT + etag: + - '"0400e39a-0000-3200-0000-652fec770000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14998' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "name": "4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0", + "status": "Deleting", "startTime": "2023-10-18T14:32:20.255426Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '626' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:23 GMT + etag: + - '"00006715-0000-3200-0000-652fec740000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "name": "4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:32:20.255426Z", "endTime": + "2023-10-18T14:32:30.2954477Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '690' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:53 GMT + etag: + - '"00006815-0000-3200-0000-652fec7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "name": "4a1b9e23-9935-4642-898b-8f3c566a5842*88DFF89EF75DC06584B66049F832948B9C64D744B47D37D395A8092EFBD4C9B5", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store/artifactManifests/ubuntu-vm-sa-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:32:20.255426Z", "endTime": + "2023-10-18T14:32:30.2954477Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '690' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:53 GMT + etag: + - '"00006815-0000-3200-0000-652fec7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:57 GMT + etag: + - '"0400e49a-0000-3200-0000-652fec9a0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14997' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "name": "eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0", + "status": "Deleting", "startTime": "2023-10-18T14:32:55.7858491Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '621' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:32:58 GMT + etag: + - '"00006915-0000-3200-0000-652fec970000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "name": "eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:32:55.7858491Z", "endTime": + "2023-10-18T14:33:18.9183534Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '685' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:33:28 GMT + etag: + - '"00006a15-0000-3200-0000-652fecaf0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "name": "eb6aac3e-18ef-4bf2-a0b1-efe324212606*A3468C8737AC969A332E30033B1918E798E4485F614959DC40E9DA6FC602C5F2", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr/artifactManifests/ubuntu-vm-acr-manifest-1-0-0", + "status": "Succeeded", "startTime": "2023-10-18T14:32:55.7858491Z", "endTime": + "2023-10-18T14:33:18.9183534Z", "properties": null}' + headers: + cache-control: + - no-cache + content-length: + - '685' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:33:28 GMT + etag: + - '"00006a15-0000-3200-0000-652fecaf0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:33:37 GMT + etag: + - '"01005091-0000-3200-0000-652fecc10000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14996' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Deleting", "startTime": "2023-10-18T14:33:36.545335Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:33:37 GMT + etag: + - '"00006b15-0000-3200-0000-652fecc00000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Deleting", "startTime": "2023-10-18T14:33:36.545335Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:34:06 GMT + etag: + - '"00006b15-0000-3200-0000-652fecc00000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Deleting", "startTime": "2023-10-18T14:33:36.545335Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '594' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:34:36 GMT + etag: + - '"00006b15-0000-3200-0000-652fecc00000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Succeeded", "startTime": "2023-10-18T14:33:36.545335Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '615' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:35:06 GMT + etag: + - '"00007115-0000-3200-0000-652fed0e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "name": "8fb2b177-8a4a-498a-8263-963a1f9214b7*3D7B424C608F0FE023A3EF90EDF0DE88CBB6EC0A899EC2E141CCB27619CA7BDF", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/networkFunctionDefinitionGroups/ubuntu-vm-nfdg", + "status": "Succeeded", "startTime": "2023-10-18T14:33:36.545335Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '615' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:35:07 GMT + etag: + - '"00007115-0000-3200-0000-652fed0e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:35:10 GMT + etag: + - '"000070f3-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14995' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Deleting", "startTime": "2023-10-18T14:35:10.5758639Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:35:11 GMT + etag: + - '"00007215-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Deleting", "startTime": "2023-10-18T14:35:10.5758639Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:35:40 GMT + etag: + - '"00007215-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Deleting", "startTime": "2023-10-18T14:35:10.5758639Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:36:10 GMT + etag: + - '"00007215-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Deleting", "startTime": "2023-10-18T14:35:10.5758639Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:36:39 GMT + etag: + - '"00007215-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Deleting", "startTime": "2023-10-18T14:35:10.5758639Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '574' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:37:09 GMT + etag: + - '"00007215-0000-3200-0000-652fed1e0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Succeeded", "startTime": "2023-10-18T14:35:10.5758639Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '595' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:37:38 GMT + etag: + - '"00007815-0000-3200-0000-652feda80000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "name": "2a40aefb-1667-479c-892e-5aba8ec8598a*C489A37845DCE4DE35485E84536556E7E5E2C311C656CB69846034646BD1F74D", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-acr", + "status": "Succeeded", "startTime": "2023-10-18T14:35:10.5758639Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '595' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:37:39 GMT + etag: + - '"00007815-0000-3200-0000-652feda80000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:37:43 GMT + etag: + - '"0000daf3-0000-3200-0000-652fedb80000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14994' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:37:43 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:38:13 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:38:43 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:39:13 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:39:42 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:40:12 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Deleting", "startTime": "2023-10-18T14:37:43.7283155Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '581' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:40:41 GMT + etag: + - '"00007915-0000-3200-0000-652fedb70000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Succeeded", "startTime": "2023-10-18T14:37:43.7283155Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:41:12 GMT + etag: + - '"00007c15-0000-3200-0000-652fee7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "name": "271d638b-e5f2-42c8-846f-13742271f402*B741486A4E495F3D1985CCB3A2E57162B9345100065F16E9106C8F7672182F46", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher/artifactStores/ubuntu-blob-store", + "status": "Succeeded", "startTime": "2023-10-18T14:37:43.7283155Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:41:12 GMT + etag: + - '"00007c15-0000-3200-0000-652fee7e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: '{"error": {"code": "GatewayTimeout", "message": "Server failed to process + the request. Tracking Id: ''d7416ab1-2907-4fd2-82f0-89ce8e1fa770''."}}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '142' + content-type: + - application/json + date: + - Wed, 18 Oct 2023 14:42:13 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14993' + status: + code: 504 + message: Gateway Timeout +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher?api-version=2023-09-01 + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:42:41 GMT + etag: + - '"07005e51-0000-3200-0000-652feee20000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-build-version: + - 1.0.02477.1998 + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Deleting", "startTime": "2023-10-18T14:42:41.1606344Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:42:42 GMT + etag: + - '"00007e15-0000-3200-0000-652feee10000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Deleting", "startTime": "2023-10-18T14:42:41.1606344Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:43:11 GMT + etag: + - '"00007e15-0000-3200-0000-652feee10000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Deleting", "startTime": "2023-10-18T14:42:41.1606344Z"}' + headers: + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + cache-control: + - no-cache + content-length: + - '548' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:43:41 GMT + etag: + - '"00007e15-0000-3200-0000-652feee10000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.HybridNetwork/locations/uaenorth/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Succeeded", "startTime": "2023-10-18T14:42:41.1606344Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '569' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:44:11 GMT + etag: + - '"00008215-0000-3200-0000-652fef2d0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - aosm nfd delete + Connection: + - keep-alive + ParameterSetName: + - --definition-type -f --clean --force + User-Agent: + - AZURECLI/2.53.0 azsdk-python-hybridnetwork/unknown Python/3.8.10 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29) + method: GET + uri: https://management.azure.com/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418?api-version=2020-01-01-preview + response: + body: + string: '{"id": "/providers/Microsoft.HybridNetwork/locations/UAENORTH/operationStatuses/cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "name": "cb49c45f-3ebf-45d3-a099-bf641f97078d*CAC1063A94B052A2C0FBBA346CD54C0887C75C9C9CA89E8D0AC1EA95BA50F418", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vnf_nsd_000001/providers/Microsoft.HybridNetwork/publishers/automated-tests-ubuntuPublisher", + "status": "Succeeded", "startTime": "2023-10-18T14:42:41.1606344Z", "properties": + null}' + headers: + cache-control: + - no-cache + content-length: + - '569' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 18 Oct 2023 14:44:11 GMT + etag: + - '"00008215-0000-3200-0000-652fef2d0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/cnf_mocks/nginxdemo-0.1.0.tgz b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/cnf_mocks/nginxdemo-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..06a7a4ae7ba8871f2b60cb0fb475547d0f5de1f3 GIT binary patch literal 4509 zcmV;O5n}EiiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PH+}Z`(SO?{9sIIVFpEumH zG-1#SLhqr+`B>UZrT-Jca#X*<0Bq3zgWl18Q~&!1hmZPyA7uyL;*jJ_gOk5g>2gv8 z-VS^oQw3B3fq%aF@V+w?G9_AL0z=Bs0KCPR5s5G%l9B;K1zNxWAtOp*0+ee3Q;|#1 zm}ZPZ(n!(a+;KAwLt zUFb2w8>#7##2U`EkO*&%KRt)BxWWlaxWc^&!kEaU6N>~B+rV}M##jO231~6`$|1pw ziD`=5IY19U&S{9|{bPzAm?jY@ZAR(=WI1DJg3)*y!O8Gc=rf55xh@8DmNRyau|%yR z`1*&nk{>51B~35_-}i<&V@n@Bg>ph;d=tl(Kb9-!8OC%-QNh(1^%x}(DByrNKu}|m zv&1kzmPj-v9u!Xz3<*gloI8n5jrXE(Ofq555lJd0pI3`4_> zRe&+c$bd4cDJsV$fJBO{eD1)T_wVhqM3Q{uZ2CzE{a4CRO_jzpvcqryIe(*01vdcA z&wp1aBj^>xSZ0|X^fbc=j#;iW%9ArQ8-&ymybL{$@{vSki9&AXN>WLHa4s}49@W+t zqcOc*<^z-*jfzmwEpP-eBT5y%wG~h^)giI*zrG>d_W;I1=>mJlzC_Mtckr5|8N+~y zm@r!pkP$t0^V5uqxkt;v4k$Z&Ppx-fz|hf56>P40+i?gxt(|!imB?l6WL1dp9|*b1 z31d@`7>hJTp4cg;1t>e^r;rpTYTn-It^kH)f}o9sBE~|+f~%N{+z}R!g_+jIqM6y4 zE0lpVXM`yMl$+VCP#I!*?EXuwjLboBKt7>TaAOq|Tv0s+Mzv{6LE#{wqhdZ3~Z! z1kaIStc8q>bUiJYF$s2_+sQ?SL&~Y1+Uke)e2?X~w)juQV@yf#O$mNieQb#Tjt&l* z@n8Qae2o9@rOd1g@OPcq{RsTA)>+i;nhDS;CWDZpZX(H0cfzA?0r}iDBuPSzh7)!s zMTXLNV&D1C0wSw_pA{a*v@DFl!q;^;t^0hw2)c;;rcrAgv>B2Ze8X7#^U4~W-weQ( z$tkfYEh!(hW3j>B9gbw7&ehKY&DQ$0l(tYjZ&L-jcZ*k((Jc^qYtU~c)@Jm*EE^Ng zui!P|(~m>Hh=MlLL8K(p6=b*&?w8JtS~$6y!U61Wd*`&)W2HR@p*&V6e-BNmM|8e_}puQe@ z;239lv*m#as_*`-<}T$LM<`dJD3-SmJQVf+im}D+)US<1gSNRSU%1~q|L?yz>OJoN+(+pJ@H@IKXp&i{Z1foZ{^>morXX|9i^Cj+5Q{V=JW-K1 zn{|K=A^76<49kOxVqFI}Hx@z?K0??vD-(!bFG1V&nt=tVpaZ*da9_t-XS12@XR>4Ik|;z2#kes z`0(1eKsf#Q_T9zV$4{SM?>@QA2N-JxBh=987;~&L5+fKQJ|RP*FgTrmy}5yofNx50 zGuqewEKnK7fx)W2hJOUSAmYX^&*qfDM0w2e1i`P)XUp9y-;VWZgSeBk25APd`Y8gf z88@^kO?0jTk|ahDXulONH@+nx9t$Wo5qAqRqTM;OR`C73Ajy9dMtF>J9q$3an5PI% zG^At-np`3f7~&PAl;^rQ!8Y@`juKAJic@JaA(WYE8q~eaKSd5P;c!KCJa&hocAOxF zbv@YoVL7Ww44td3q_0<`G1>35qBq0=diKKQelKbsXw_=NHVuc4GR zt1+_FKnR~&9Sf|YIhFEnT4q2sl*ka<5Ud^TN@biMt!|->XCL2QoWA++uEDTOB->7S z20qEMVDV_xG<@C8%!-lEm)lXUv|-rmW`BlHE0rrnO%kGs#a&~j|Ai{5OP==jkAg4= zgI@G9d>IzU^)AJtX2VUSRC2;_s52DuipT_ZOICqt9=#0fR`H?z(PO#a(iZ<+jFDw1 zRiLvwNd?;!{~h#>8u8!Z;nBfk{C6K^HtRlv2~8uL;xnWSjb(kE8n(n^jNn<LpEt5@CvvNBsiqJ#ZY#tdYjAZucyVAKX?mUy zhx8i!PKC@^E%WRsJa*YhWZsAIcT@ORP8c0hOpJN7vD%CnF9fU*E9!EthqS7jm z^2W&0K#jY0$gAKBe%J=9Bd=&F)PtIWI7Yphr@Ob~nkTUvR7*|1!@qK&v9YdP#*z|F zMwoO4(?y!ji@eKqGpT89+jBM7$z^eG^K_M|SOg1-M9)sK=$g&u`u$}6y5i|7jJzg+ zxq>!u`^Cdjyx)qXMGGI=o&M=cTm09^hQ4(l8{)tI;fv<}-;0CZi^uryK1%)m56Lps zo%Fm*%99A*&S!yFE=!{_e|xL#1rG|Z5qa(4rN;>1J5Zh=*U&fZOyCr`9DK8wRnBS_ z2BCg*=sHnl(y6s3DbexxebKMm-1%v5w5s`f7X$Nj_kyAt_e^06#NC>_pCJ&SFqCK-hqGEq;s<>(E@NnSZ*T;0VI}oCoCZU&Lzgu z&Naim$lYgwCqfpf>NGB+)~5@&6A@pcwD)EfT5dw!h9t|?_{SQa*xNf}A`>XC^qA!r z(U9dDC|_|UsMryv3XV_z3TGdWYdGDtBk*e$#(oN_yhymYS)j;oHb1M~0b0USe9EOeqZ;U%NtlZGCwA$NtvsznEwf0sfkJr3( zdADTiUN-enOKYgQso!b&nVudx-fNb&_`f`4y{oIh8{+@{Fzhey{~kTY|MyWgoaE1U z`AlekTI}>~i2Ubm)Fd|Us($vraPC*zg;1DIP#%jkBND;?uh+ex*YAWr1jn^2p26Sp z0T#=Z;CHIajTpD(R4rsU>MJ2HDIW!wFWp8?Z-AQg7B?U2P4HSHH;-x&)@iL<5uG^Z zv@eG$4&7qq(_)26iPW9_V6f#wy72is{@U*4osP zJW6+D6EkXiXRQ_=7A~HeCe{18tPTK~Gu%M=0#W7lSks419a$pH9=py5;4aH9*#70z zm1?vu;;E8Rsxlz)CGw;hA{8ofx?*CrfV!B_fR-9pgIwTEJI@~420fOCD{cP2HT1nj zADjID;gbJ9>K{D%|9dHo-~Vxr?zmhGw79y3wLtOfAoj;G+7?%oVfjlPbDZ`>tg*%H zRzeD>c1NFXc>>-}*;>-kSc5&w3cQk_`sycw@7CloF}iR+Q35fe#{cc@N=${u3z8%f zI#9mm3Z;3mm)tKjO%ZnUOlgTEy^yFf!4koYq`PKDEcF+V{(07*z*~%95KH1l~-+2#xW{&!NdrlJ0Y^m z#Hd*C+N@1iAJ}>)xmsg`(B`Ff8+qhX2n_(;T*QW^|%O# zQVMyIkr6^aJcQT#VF#FvrSbEbUoY&Be`LL@| zX_x{0Fjvc`R?L|&S~{kD)S!0 zd>**J4{gJ5Q`-E0sr~n~{tsUqyjWiUKc4^HOKJ80MPkB3o%^}pRcdiZRnl*5_qa^}hPwIZX{MYDzkz#UtGq6ej5B3k5@qe%1 zf7Ji`C|hR%tuqt_c)Pv$!GqeLGaZjPKtEa9^xp(Es|NCJ- zd|dzEOKDZ>Gm*6DvcHYRGyFAooGe0#X1eJzTi_HYC?C{d zRr((o=F$-t67RT=P5OVh-;Dnc`r)Jhzn8KDXGCk1-0nR%@x#>^ISg{j60@4lNPI~~ zsOCQgtn$pp-=N0G7>t-0xU@UUN6$ebBbrXoo_y546P|cGz;Wc3^iML0Lwb#gJMQ|A zrvZHAYzl(gmWCwAP}-lu47}j&`Gw8r@phodNdIzt4hfaY3r19T?O#W}7YzO_yY_GS zVLa-ZKjo{M@NR`@K;p|hvzwL5dlsmx%zG9L$ffrz&}rs9`(JMdz7R=8uHfYDJLLtL v6yGq`UO*EhT?Z${H!ql|SR~ke3_%{tV|grpg7SX>009602d`vY0Av6FOl8-d literal 0 HcmV?d00001 diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_input_template.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_input_template.json new file mode 100644 index 00000000000..1a350599c29 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_input_template.json @@ -0,0 +1,20 @@ +{ + "publisher_name": "automated-tests-nginx-publisher", + "publisher_resource_group_name": "{{publisher_resource_group_name}}", + "nf_name": "nginx", + "version": "1.0.0", + "acr_artifact_store_name": "nginx-acr", + "location": "uaenorth", + "images":{ + "source_registry": "not-used-in-test-but-cannot-be-blank", + "source_registry_namespace": "" + }, + "helm_packages": [ + { + "name": "nginxdemo", + "path_to_chart": "{{path_to_chart}}", + "path_to_mappings": "", + "depends_on": [] + } + ] +} diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_nsd_input_template.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_nsd_input_template.json new file mode 100644 index 00000000000..dacd8c29e4c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/cnf_nsd_input_template.json @@ -0,0 +1,20 @@ +{ + "location": "uaenorth", + "publisher_name": "automated-tests-nginx-publisher", + "publisher_resource_group_name": "{{publisher_resource_group_name}}", + "acr_artifact_store_name": "nginx-acr", + "network_functions": [ + { + "name": "nginx-nfdg", + "version": "1.0.0", + "publisher_offering_location": "uaenorth", + "type": "cnf", + "multiple_instances": false, + "publisher": "automated-tests-nginx-publisher", + "publisher_resource_group": "{{publisher_resource_group_name}}" + } + ], + "nsd_name": "nginx", + "nsd_version": "1.0.0", + "nsdv_description": "Deploys a basic NGINX CNF" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/nsd_input.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/nsd_input.json new file mode 100644 index 00000000000..1e40b229d7a --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/nsd_input.json @@ -0,0 +1,20 @@ +{ + "location": "uaenorth", + "publisher_name": "automated-tests-ubuntuPublisher", + "publisher_resource_group_name": "cli_test_vnf_nsd_000001", + "acr_artifact_store_name": "ubuntu-acr", + "network_functions": [ + { + "name": "ubuntu-vm-nfdg", + "version": "1.0.0", + "publisher_offering_location": "uaenorth", + "type": "vnf", + "multiple_instances": false, + "publisher": "automated-tests-ubuntuPublisher", + "publisher_resource_group": "cli_test_vnf_nsd_000001" + } + ], + "nsd_name": "ubuntu", + "nsd_version": "1.0.0", + "nsdv_description": "Plain ubuntu VM" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input.json new file mode 100644 index 00000000000..fa4e8dd303d --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input.json @@ -0,0 +1,18 @@ +{ + "publisher_name": "automated-tests-ubuntuPublisher", + "publisher_resource_group_name": "cli_test_vnf_nsd_000001", + "acr_artifact_store_name": "ubuntu-acr", + "location": "uaenorth", + "nf_name": "ubuntu-vm", + "version": "1.0.0", + "blob_artifact_store_name": "ubuntu-blob-store", + "image_name_parameter": "imageName", + "arm_template": { + "file_path": "../vnf_mocks/ubuntu_template.json", + "version": "1.0.0" + }, + "vhd": { + "file_path": "../vnf_mocks/ubuntu.vhd", + "version": "1-0-0" + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input_template.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input_template.json new file mode 100644 index 00000000000..f0e4fdf6a3d --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_input_template.json @@ -0,0 +1,18 @@ +{ + "publisher_name": "automated-tests-ubuntuPublisher", + "publisher_resource_group_name": "{{publisher_resource_group_name}}", + "acr_artifact_store_name": "ubuntu-acr", + "location": "uaenorth", + "nf_name": "ubuntu-vm", + "version": "1.0.0", + "blob_artifact_store_name": "ubuntu-blob-store", + "image_name_parameter": "imageName", + "arm_template": { + "file_path": "../vnf_mocks/ubuntu_template.json", + "version": "1.0.0" + }, + "vhd": { + "file_path": "../vnf_mocks/ubuntu.vhd", + "version": "1-0-0" + } +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_nsd_input_template.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_nsd_input_template.json new file mode 100644 index 00000000000..320d0f1339b --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/mock_input_templates/vnf_nsd_input_template.json @@ -0,0 +1,20 @@ +{ + "location": "uaenorth", + "publisher_name": "automated-tests-ubuntuPublisher", + "publisher_resource_group_name": "{{publisher_resource_group_name}}", + "acr_artifact_store_name": "ubuntu-acr", + "network_functions": [ + { + "name": "ubuntu-vm-nfdg", + "version": "1.0.0", + "publisher_offering_location": "uaenorth", + "type": "vnf", + "multiple_instances": false, + "publisher": "automated-tests-ubuntuPublisher", + "publisher_resource_group": "{{publisher_resource_group_name}}" + } + ], + "nsd_name": "ubuntu", + "nsd_version": "1.0.0", + "nsdv_description": "Plain ubuntu VM" +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu.vhd b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu.vhd new file mode 100644 index 00000000000..8f1a1c99b84 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu.vhd @@ -0,0 +1,11 @@ +61 38 6b 92 16 4b cc ac 6f d4 02 5c 6f 62 79 b9 +8e 62 ae 07 02 1c dc 73 5b 7a 51 e7 56 4e 4a b0 +54 4a 93 2e 6b dd 3c b5 8b 60 fa 80 b1 80 1b 89 +1e 4d 7d 86 8e 25 76 58 24 8d 21 87 83 06 88 d6 +a4 fd 94 9c 66 b6 db ee 92 46 f0 25 fc 84 bb f5 +3f d9 49 28 ea 54 6a 2a 33 fa e0 47 eb 22 af 91 +d4 34 a6 d9 fe 58 cb 54 03 35 d6 45 40 96 4e f3 +31 ea 78 20 45 e9 f2 3a de cb 38 53 c0 9c b2 b7 +12 9e 57 d9 f6 1b cb 20 23 8c 86 d3 40 da 84 c3 +22 5b 48 61 63 e2 5f 5f 43 6d 8f 41 fc ce c1 87 +33 e1 e2 61 63 e2 5f 5 \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu_template.json b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu_template.json new file mode 100644 index 00000000000..fe7b586ab23 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/scenario_test_mocks/vnf_mocks/ubuntu_template.json @@ -0,0 +1,118 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.8.9.13224", + "templateHash": "14979664264804385741" + } + }, + "parameters": { + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + }, + "subnetName": { + "type": "string" + }, + "ubuntuVmName": { + "type": "string", + "defaultValue": "ubuntu-vm" + }, + "virtualNetworkId": { + "type": "string" + }, + "sshPublicKeyAdmin": { + "type": "string" + }, + "imageName": { + "type": "string" + } + }, + "variables": { + "imageResourceGroup": "[resourceGroup().name]", + "subscriptionId": "[subscription().subscriptionId]", + "vmSizeSku": "Standard_D2s_v3" + }, + "resources": [ + { + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2021-05-01", + "name": "[format('{0}_nic', parameters('ubuntuVmName'))]", + "location": "[parameters('location')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig1", + "properties": { + "subnet": { + "id": "[format('{0}/subnets/{1}', parameters('virtualNetworkId'), parameters('subnetName'))]" + }, + "primary": true, + "privateIPAddressVersion": "IPv4" + } + } + ] + } + }, + { + "type": "Microsoft.Compute/virtualMachines", + "apiVersion": "2021-07-01", + "name": "[parameters('ubuntuVmName')]", + "location": "[parameters('location')]", + "properties": { + "hardwareProfile": { + "vmSize": "[variables('vmSizeSku')]" + }, + "storageProfile": { + "imageReference": { + "id": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', variables('subscriptionId'), variables('imageResourceGroup')), 'Microsoft.Compute/images', parameters('imageName'))]" + }, + "osDisk": { + "osType": "Linux", + "name": "[format('{0}_disk', parameters('ubuntuVmName'))]", + "createOption": "FromImage", + "caching": "ReadWrite", + "writeAcceleratorEnabled": false, + "managedDisk": "[json('{\"storageAccountType\": \"Premium_LRS\"}')]", + "deleteOption": "Delete", + "diskSizeGB": 30 + } + }, + "osProfile": { + "computerName": "[parameters('ubuntuVmName')]", + "adminUsername": "azureuser", + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "ssh": { + "publicKeys": [ + { + "path": "/home/azureuser/.ssh/authorized_keys", + "keyData": "[parameters('sshPublicKeyAdmin')]" + } + ] + }, + "provisionVMAgent": true, + "patchSettings": { + "patchMode": "ImageDefault", + "assessmentMode": "ImageDefault" + } + }, + "secrets": [], + "allowExtensionOperations": true + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]" + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]" + ] + } + ] +} \ No newline at end of file diff --git a/src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py b/src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py new file mode 100644 index 00000000000..21935070f30 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_aosm_cnf_publish_and_delete.py @@ -0,0 +1,116 @@ +# # -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Integration tests for the aosm extension. They test the following commands for the +# cnf definition type: +# aosm nfd build +# aosm nfd publish +# aosm nfd delete +# aosm nsd build +# aosm nsd publish +# aosm nsd delete +# +# -------------------------------------------------------------------------------------------- + +import os +from typing import Dict +from azure.cli.testsdk import LiveScenarioTest, ResourceGroupPreparer +from knack.log import get_logger +from jinja2 import Template + +logger = get_logger(__name__) + +NFD_INPUT_TEMPLATE_NAME = "cnf_input_template.json" +NFD_INPUT_FILE_NAME = "cnf_input.json" +NSD_INPUT_TEMPLATE_NAME = "cnf_nsd_input_template.json" +NSD_INPUT_FILE_NAME = "nsd_cnf_input.json" +CHART_NAME = "nginxdemo-0.1.0.tgz" + + +def get_path_to_chart(): + code_dir = os.path.dirname(__file__) + templates_dir = os.path.join(code_dir, "scenario_test_mocks", "cnf_mocks") + chart_path = os.path.join(templates_dir, CHART_NAME) + return chart_path + + +def update_input_file(input_template_name, output_file_name, params: Dict[str, str]): + code_dir = os.path.dirname(__file__) + templates_dir = os.path.join( + code_dir, "scenario_test_mocks", "mock_input_templates" + ) + input_template_path = os.path.join(templates_dir, input_template_name) + + with open(input_template_path, "r", encoding="utf-8") as file: + contents = file.read() + + jinja_template = Template(contents) + + rendered_template = jinja_template.render(**params) + + output_path = os.path.join(templates_dir, output_file_name) + + with open(output_path, "w", encoding="utf-8") as file: + file.write(rendered_template) + + return output_path + + +class CnfNsdTest(LiveScenarioTest): + """ + Integration tests for the aosm extension for cnf definition type. + + This test uses Live Scenario Test because it depends on using the `az login` command + which does not work when playing back from the recording. + """ + + @ResourceGroupPreparer(name_prefix="cli_test_cnf_nsd_", location="uaenorth") + def test_cnf_nsd_publish_and_delete(self, resource_group): + """ + This test creates a cnf nfd and nsd, publishes them, and then deletes them. + + :param resource_group: The name of the resource group to use for the test. + This is passed in by the ResourceGroupPreparer decorator. + """ + + chart_path = get_path_to_chart() + + nfd_input_file_path = update_input_file( + NFD_INPUT_TEMPLATE_NAME, + NFD_INPUT_FILE_NAME, + params={ + "publisher_resource_group_name": resource_group, + "path_to_chart": chart_path, + }, + ) + + self.cmd( + f'az aosm nfd build -f "{nfd_input_file_path}" --definition-type cnf --force' + ) + + try: + self.cmd( + f'az aosm nfd publish -f "{nfd_input_file_path}" --definition-type cnf --debug --skip image-upload' + ) + except Exception: + self.cmd( + f'az aosm nfd delete --definition-type cnf -f "{nfd_input_file_path}" --debug --force' + ) + raise + + nsd_input_file_path = update_input_file( + NSD_INPUT_TEMPLATE_NAME, + NSD_INPUT_FILE_NAME, + params={"publisher_resource_group_name": resource_group}, + ) + + self.cmd(f'az aosm nsd build -f "{nsd_input_file_path}" --debug --force') + + try: + self.cmd(f'az aosm nsd publish -f "{nsd_input_file_path}" --debug') + finally: + self.cmd(f'az aosm nsd delete -f "{nsd_input_file_path}" --debug --force') + self.cmd( + f'az aosm nfd delete --definition-type cnf -f "{nfd_input_file_path}" --debug --force' + ) diff --git a/src/aosm/azext_aosm/tests/latest/test_aosm_scenario.py b/src/aosm/azext_aosm/tests/latest/test_aosm_scenario.py new file mode 100644 index 00000000000..fe10ce0d1de --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_aosm_scenario.py @@ -0,0 +1,39 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +# from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import ResourceGroupPreparer, ScenarioTest + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), "..")) + +## Note: keeping this only as an example for what we could do +# class AosmScenarioTest(ScenarioTest): +# @ResourceGroupPreparer(name_prefix="cli_test_aosm") +# def test_aosm(self, resource_group): +# self.kwargs.update({"name": "test1"}) + +# self.cmd( +# "aosm create -g {rg} -n {name} --tags foo=doo", +# checks=[self.check("tags.foo", "doo"), self.check("name", "{name}")], +# ) +# self.cmd( +# "aosm update -g {rg} -n {name} --tags foo=boo", +# checks=[self.check("tags.foo", "boo")], +# ) +# count = len(self.cmd("aosm list").get_output_in_json()) +# self.cmd( +# "aosm show - {rg} -n {name}", +# checks=[ +# self.check("name", "{name}"), +# self.check("resourceGroup", "{rg}"), +# self.check("tags.foo", "boo"), +# ], +# ) +# self.cmd("aosm delete -g {rg} -n {name}") +# final_count = len(self.cmd("aosm list").get_output_in_json()) +# self.assertTrue(final_count, count - 1) diff --git a/src/aosm/azext_aosm/tests/latest/test_aosm_vnf_publish_and_delete.py b/src/aosm/azext_aosm/tests/latest/test_aosm_vnf_publish_and_delete.py new file mode 100644 index 00000000000..39e099f7918 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_aosm_vnf_publish_and_delete.py @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# This is an integration tests for the aosm extension. It tests the following commands for the +# vnf definition type: +# aosm nfd build +# aosm nfd publish +# aosm nfd delete +# aosm nsd build +# aosm nsd publish +# aosm nsd delete +# -------------------------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import LiveScenarioTest, ResourceGroupPreparer +from knack.log import get_logger +from jinja2 import Template + + +logger = get_logger(__name__) + +NFD_INPUT_TEMPLATE_NAME = "vnf_input_template.json" +NFD_INPUT_FILE_NAME = "vnf_input.json" +NSD_INPUT_TEMPLATE_NAME = "vnf_nsd_input_template.json" +NSD_INPUT_FILE_NAME = "nsd_input.json" +ARM_TEMPLATE_RELATIVE_PATH = ( + "scenario_test_mocks/vnf_mocks/ubuntu_template.json" +) + + +def update_resource_group_in_input_file( + input_template_name: str, output_file_name: str, resource_group: str +) -> str: + """ + This function updates the resource group name in the input template file and returns the + path to the updated file. + + :param input_template_name: The name of the input template file. + :param output_file_name: The name of the output file. + :param resource_group: The name of the resource group to update the input template with. + :return: The path to the updated input template file. + """ + code_dir = os.path.dirname(__file__) + templates_dir = os.path.join( + code_dir, "scenario_test_mocks", "mock_input_templates" + ) + input_template_path = os.path.join(templates_dir, input_template_name) + + with open(input_template_path, "r", encoding="utf-8") as file: + contents = file.read() + + jinja_template = Template(contents) + + rendered_template = jinja_template.render( + publisher_resource_group_name=resource_group + ) + + output_path = os.path.join(templates_dir, output_file_name) + + with open(output_path, "w", encoding="utf-8") as file: + file.write(rendered_template) + + return output_path + + +class VnfNsdTest(LiveScenarioTest): + """This class contains the integration tests for the aosm extension for vnf definition type.""" + + @ResourceGroupPreparer( + name_prefix="cli_test_vnf_nsd_", location="uaenorth" + ) + def test_vnf_nsd_publish_and_delete(self, resource_group): + """ + This test creates a vnf nfd and nsd, publishes them, and then deletes them. + + :param resource_group: The name of the resource group to use for the test. + This is passed in by the ResourceGroupPreparer decorator. + """ + nfd_input_file_path = update_resource_group_in_input_file( + NFD_INPUT_TEMPLATE_NAME, NFD_INPUT_FILE_NAME, resource_group + ) + + self.cmd( + f'az aosm nfd build -f "{nfd_input_file_path}" --definition-type vnf --force' + ) + + try: + self.cmd( + f'az aosm nfd publish -f "{nfd_input_file_path}" --definition-type vnf' + ) + except Exception: + # If the command fails, then the test should fail. + # We still need to clean up the resources, so we run the delete command. + self.cmd( + f'az aosm nfd delete --definition-type vnf -f "{nfd_input_file_path}" --clean --force' + ) + raise + + nsd_input_file_path = update_resource_group_in_input_file( + NSD_INPUT_TEMPLATE_NAME, NSD_INPUT_FILE_NAME, resource_group + ) + + self.cmd(f'az aosm nsd build -f "{nsd_input_file_path}" --force') + + try: + self.cmd(f'az aosm nsd publish -f "{nsd_input_file_path}"') + finally: + # If the command fails, then the test should fail. + # We still need to clean up the resources, so we run the delete command. + self.cmd( + f'az aosm nsd delete -f "{nsd_input_file_path}" --clean --force' + ) + self.cmd( + f'az aosm nfd delete --definition-type vnf -f "{nfd_input_file_path}" --clean --force' + ) diff --git a/src/aosm/azext_aosm/tests/latest/test_cnf.py b/src/aosm/azext_aosm/tests/latest/test_cnf.py new file mode 100644 index 00000000000..0eaa1173a7c --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_cnf.py @@ -0,0 +1,67 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import unittest +import json +import os +from pathlib import Path +from tempfile import TemporaryDirectory + +from azext_aosm.custom import build_definition, generate_definition_config + + +mock_cnf_folder = ((Path(__file__).parent) / "mock_cnf").resolve() + + +class TestCNF(unittest.TestCase): + def test_generate_config(self): + """Test generating a config file for a VNF.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + generate_definition_config("cnf") + assert os.path.exists("input.json") + finally: + os.chdir(starting_directory) + + def test_build(self): + """Test the build command for CNFs.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition( + "cnf", str(mock_cnf_folder / "input-nfconfigchart.json") + ) + assert os.path.exists("nfd-bicep-nginx-basic-test") + # Confirm that the generated schema file correctly handles array deployment params. + assert os.path.exists("nfd-bicep-nginx-basic-test/schemas/deploymentParameters.json") + with open("nfd-bicep-nginx-basic-test/schemas/deploymentParameters.json") as f: + schema = json.load(f) + assert schema["properties"]["imagePullSecrets_0"]["type"] == "string" + finally: + os.chdir(starting_directory) + + def test_build_no_mapping(self): + """ + Test the build command for CNFs where no mapping file is supplied. + + Also reorder the parameters. + """ + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition( + "cnf", + str(mock_cnf_folder / "input-nf-agent-cnf.json"), + order_params=True, + ) + assert os.path.exists("nfd-bicep-nf-agent-cnf") + finally: + os.chdir(starting_directory) diff --git a/src/aosm/azext_aosm/tests/latest/test_nsd.py b/src/aosm/azext_aosm/tests/latest/test_nsd.py new file mode 100644 index 00000000000..4c689d4ab89 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_nsd.py @@ -0,0 +1,393 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json +import os +import shutil +import subprocess +from dataclasses import dataclass +from distutils.dir_util import copy_tree +from filecmp import dircmp +from pathlib import Path +from tempfile import TemporaryDirectory +from typing import Any +from unittest.mock import Mock, patch + +import jsonschema +import pytest +from azure.cli.core.azclierror import CLIInternalError +from azure.core import exceptions as azure_exceptions +from azure.mgmt.resource.features.v2015_12_01.models import ( + FeatureProperties, + FeatureResult, +) + +from azext_aosm.custom import ( + _check_features_enabled, + build_design, + generate_design_config, +) + +mock_nsd_folder = ((Path(__file__).parent) / "mock_nsd").resolve() +output_folder = ((Path(__file__).parent) / "nsd_output").resolve() + + +CGV_DATA = { + "ubuntu-vm-nfdg": { + "deploymentParameters": { + "location": "eastus", + "subnetName": "subnet", + "virtualNetworkId": "bar", + "sshPublicKeyAdmin": "foo", + }, + "ubuntu_vm_nfdg_nfd_version": "1.0.0", + }, + "managedIdentity": "blah", +} + + +MULTIPLE_INSTANCES_CGV_DATA = { + "ubuntu-vm-nfdg": { + "deploymentParameters": [ + { + "location": "eastus", + "subnetName": "subnet", + "virtualNetworkId": "bar", + "sshPublicKeyAdmin": "foo", + }, + { + "location": "eastus", + "subnetName": "subnet2", + "virtualNetworkId": "bar2", + "sshPublicKeyAdmin": "foo2", + }, + ], + "ubuntu_vm_nfdg_nfd_version": "1.0.0", + }, + "managedIdentity": "blah", +} + + +MULTIPLE_NFs_CGV_DATA = { + "managedIdentity": "managed_identity", + "nginx-nfdg": { + "customLocationId": "custom_location", + "nginx_nfdg_nfd_version": "1.0.0", + "deploymentParameters": {"service_port": 5222, "serviceAccount_create": False}, + }, + "ubuntu-nfdg": { + "ubuntu_nfdg_nfd_version": "1.0.0", + "deploymentParameters": { + "location": "eastus", + "subnetName": "ubuntu-vm-subnet", + "ubuntuVmName": "ubuntu-vm", + "virtualNetworkId": "ubuntu-vm-vnet", + "sshPublicKeyAdmin": "public_key", + }, + }, +} + + +ubuntu_deploy_parameters = { + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "DeployParametersSchema", + "type": "object", + "properties": { + "location": {"type": "string"}, + "subnetName": {"type": "string"}, + "virtualNetworkId": {"type": "string"}, + "sshPublicKeyAdmin": {"type": "string"}, + }, +} + +nginx_deploy_parameters = { + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "DeployParametersSchema", + "type": "object", + "properties": { + "serviceAccount_create": {"type": "boolean"}, + "service_port": {"type": "integer"}, + }, + "required": ["serviceAccount_create", "service_port"], +} + + +# We don't want to get details from a real NFD (calling out to Azure) in a UT. +# Therefore we pass in a fake client to supply the deployment parameters from the "NFD". +@dataclass +class NFDVProperties: + deploy_parameters: str + +@dataclass +class NFDV: + properties: NFDVProperties + +class NFDVs: + def get(self, network_function_definition_group_name, **_): + if "nginx" in network_function_definition_group_name: + return NFDV(NFDVProperties(json.dumps(nginx_deploy_parameters))) + else: + return NFDV(NFDVProperties(json.dumps(ubuntu_deploy_parameters))) + + +class AOSMClient: + def __init__(self) -> None: + self.network_function_definition_versions = NFDVs() + + +mock_client = AOSMClient() + + +class MockFeatures: + """Mock class for _check_features_enabled.""" + + def __init__(self) -> None: + """Mock init.""" + self.mock_state = "NotRegistered" + + def get( + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> FeatureResult: + """Mock Features get function.""" + return FeatureResult( + name=feature_name, properties=FeatureProperties(state=self.mock_state) + ) + + +class MockMissingFeatures: + """Mock class for _check_features_enabled.""" + + def __init__(self) -> None: + """Fake init.""" + pass + + def get( + self, resource_provider_namespace: str, feature_name: str, **kwargs: Any + ) -> FeatureResult: + """Mock features get function that raises an exception.""" + raise azure_exceptions.ResourceNotFoundError() + + +class FeaturesClient: + """Mock class for _check_features_enabled.""" + + def __init__(self) -> None: + """Mock class for _check_features_enabled.""" + self.features = MockFeatures() + + +class MissingFeaturesClient: + """Mock class for _check_features_enabled.""" + + def __init__(self) -> None: + """Mock class for _check_features_enabled.""" + self.features = MockMissingFeatures() + + +class FakeCmd: + def __init__(self) -> None: + self.cli_ctx = None + + +mock_cmd = FakeCmd() + + +def validate_schema_against_metaschema(schema_data): + """Validate that the schema produced by the CLI matches the AOSM metaschema.""" + + # There is a bug in the jsonschema module that means that it hits an error in with + # the "$id" bit of the metaschema. Here we use a modified version of the metaschema + # with that small section removed. + metaschema_file_path = ( + (Path(__file__).parent) / "metaschema_modified.json" + ).resolve() + with open(metaschema_file_path, "r", encoding="utf8") as f: + metaschema = json.load(f) + + jsonschema.validate(instance=schema_data, schema=metaschema) + + +def validate_json_against_schema(json_data, schema_file): + """Validate some test data against the schema produced by the CLI.""" + with open(schema_file, "r", encoding="utf8") as f: + schema = json.load(f) + + validate_schema_against_metaschema(schema) + + jsonschema.validate(instance=json_data, schema=schema) + + +def build_bicep(bicep_template_path): + bicep_output = subprocess.run( # noqa + [ + str(shutil.which("az")), + "bicep", + "build", + "--file", + bicep_template_path, + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + + if bicep_output.returncode != 0: + print(f"Invalid bicep: {bicep_template_path}") + print(str(bicep_output.stderr).replace("\\n", "\n").replace("\\t", "\t")) + raise RuntimeError("Invalid Bicep") + + +def compare_to_expected_output(expected_folder_name: str): + """ + Compares nsd-bicep-templates to the supplied folder name. + + :param expected_folder_name: The name of the folder within nsd_output to compare + with. + """ + # Check files and folders within the top level directory are the same. + expected_output_path = output_folder / expected_folder_name + comparison = dircmp("nsd-bicep-templates", expected_output_path) + + try: + assert len(comparison.diff_files) == 0 + assert len(comparison.left_only) == 0 + assert len(comparison.right_only) == 0 + + # Check the files and folders within each of the subdirectories are the same. + for subdir in comparison.subdirs.values(): + assert len(subdir.diff_files) == 0 + assert len(subdir.left_only) == 0 + assert len(subdir.right_only) == 0 + except: + copy_tree("nsd-bicep-templates", str(expected_output_path)) + print( + f"Output has changed in {expected_output_path}, use git diff to check if " + f"you are happy with those changes." + ) + raise + + +class TestNSDGenerator: + def test_generate_config(self): + """Test generating a config file for a VNF.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + generate_design_config() + assert os.path.exists("input.json") + finally: + os.chdir(starting_directory) + + @patch("azext_aosm.custom.cf_resources") + def test_build(self, cf_resources): + """Test building the NSD bicep templates.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_design( + mock_cmd, + client=mock_client, + config_file=str(mock_nsd_folder / "input.json"), + ) + + assert os.path.exists("nsd-bicep-templates") + validate_json_against_schema( + CGV_DATA, + "nsd-bicep-templates/schemas/ubuntu_ConfigGroupSchema.json", + ) + + compare_to_expected_output("test_build") + finally: + os.chdir(starting_directory) + + @patch("azext_aosm.custom.cf_resources") + def test_build_multiple_instances(self, cf_resources): + """Test building the NSD bicep templates with multiple NFs allowed.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_design( + mock_cmd, + client=mock_client, + config_file=str(mock_nsd_folder / "input_multiple_instances.json"), + ) + + assert os.path.exists("nsd-bicep-templates") + validate_json_against_schema( + MULTIPLE_INSTANCES_CGV_DATA, + "nsd-bicep-templates/schemas/ubuntu_ConfigGroupSchema.json", + ) + + compare_to_expected_output("test_build_multiple_instances") + finally: + os.chdir(starting_directory) + + @patch("azext_aosm.custom.cf_resources") + def test_build_multiple_nfs(self, cf_resources): + """Test building the NSD bicep templates with multiple NFs allowed.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_design( + mock_cmd, + client=mock_client, + config_file=str(mock_nsd_folder / "input_multi_nf_nsd.json"), + ) + + assert os.path.exists("nsd-bicep-templates") + validate_json_against_schema( + MULTIPLE_NFs_CGV_DATA, + "nsd-bicep-templates/schemas/multinf_ConfigGroupSchema.json", + ) + + # The bicep checks take a while, so we would only do them here and not + # on the other tests. However, they are disabled until we can look at + # them further, as the version of Bicep used ends up in the built file, + # and we don't control what version of bicep is used in the pipeline or + # on the user's machine. + # build_bicep("nsd-bicep-templates/nginx-nfdg_nf.bicep") + # build_bicep("nsd-bicep-templates/ubuntu-nfdg_nf.bicep") + # build_bicep("nsd-bicep-templates/nsd_definition.bicep") + # build_bicep("nsd-bicep-templates/artifact_manifest.bicep") + + compare_to_expected_output("test_build_multiple_nfs") + finally: + os.chdir(starting_directory) + + def test_check_features(self, caplog): + """ + Test the _check_features_enabled function. + + Does not test the actual feature check, just that the function logs and raises + exceptions appropriately. + """ + mock_features_client = FeaturesClient() + mock_missing_features_client = MissingFeaturesClient() + caplog.set_level("DEBUG") + with patch("azext_aosm.custom.cf_features", return_value=mock_features_client): + mock_features_client.features.mock_state = "NotRegistered" + + with pytest.raises(CLIInternalError): + _check_features_enabled(mock_cmd) + assert "is not registered on the subscription" in caplog.text + mock_features_client.features.mock_state = "Registered" + _check_features_enabled(mock_cmd) + + with patch( + "azext_aosm.custom.cf_features", return_value=mock_missing_features_client + ): + with pytest.raises(CLIInternalError): + _check_features_enabled(mock_cmd) + assert ( + "CLI encountered an error checking that your " + "subscription has been onboarded to AOSM." in caplog.text + ) diff --git a/src/aosm/azext_aosm/tests/latest/test_vnf.py b/src/aosm/azext_aosm/tests/latest/test_vnf.py new file mode 100644 index 00000000000..d6d178f56d0 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/test_vnf.py @@ -0,0 +1,89 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json +import os +import unittest +from pathlib import Path +from tempfile import TemporaryDirectory + +from azext_aosm.custom import build_definition, generate_definition_config + +mock_vnf_folder = ((Path(__file__).parent) / "mock_vnf").resolve() + +INPUT_WITH_SAS_VHD_PARAMS = { + "imageName": "ubuntu-vmImage", + "imageDiskSizeGB": 30, + "imageHyperVGeneration": "V1", + "imageApiVersion": "2023-03-01", +} + + +def validate_vhd_parameters(expected_params, vhd_params_file_path): + """Validate that the expected parameters are in the actual parameters.""" + assert os.path.exists(vhd_params_file_path) + with open(vhd_params_file_path) as f: + actual_params = json.load(f) + assert expected_params == actual_params + + +class TestVNF(unittest.TestCase): + def test_generate_config(self): + """Test generating a config file for a VNF.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + generate_definition_config("vnf") + assert os.path.exists("input.json") + finally: + os.chdir(starting_directory) + + def test_build(self): + """Test building an NFDV for a VNF.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition( + "vnf", str(mock_vnf_folder / "input_with_fp.json") + ) + assert os.path.exists("nfd-bicep-ubuntu-template") + finally: + os.chdir(starting_directory) + + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition( + "vnf", str(mock_vnf_folder / "input_with_sas.json") + ) + assert os.path.exists("nfd-bicep-ubuntu-template") + print(os.listdir("nfd-bicep-ubuntu-template")) + validate_vhd_parameters( + INPUT_WITH_SAS_VHD_PARAMS, + "nfd-bicep-ubuntu-template/configMappings/vhdParameters.json", + ) + finally: + os.chdir(starting_directory) + + def test_build_with_ordered_params(self): + """Test building an NFDV for a VNF.""" + starting_directory = os.getcwd() + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition( + "vnf", + str(mock_vnf_folder / "input_with_fp.json"), + order_params=True, + ) + assert os.path.exists("nfd-bicep-ubuntu-template") + finally: + os.chdir(starting_directory) diff --git a/src/aosm/azext_aosm/util/__init__.py b/src/aosm/azext_aosm/util/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/aosm/azext_aosm/util/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/aosm/azext_aosm/util/constants.py b/src/aosm/azext_aosm/util/constants.py new file mode 100644 index 00000000000..fc8c8a1e092 --- /dev/null +++ b/src/aosm/azext_aosm/util/constants.py @@ -0,0 +1,124 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Constants used across aosm cli extension.""" + +from enum import Enum + +# The types of definition that can be generated +VNF = "vnf" +CNF = "cnf" +NSD = "nsd" + + +class DeployableResourceTypes(str, Enum): + VNF = VNF + CNF = CNF + NSD = NSD + + +# Skip steps +BICEP_PUBLISH = "bicep-publish" +ARTIFACT_UPLOAD = "artifact-upload" +IMAGE_UPLOAD = "image-upload" + + +class SkipSteps(Enum): + BICEP_PUBLISH = BICEP_PUBLISH + ARTIFACT_UPLOAD = ARTIFACT_UPLOAD + IMAGE_UPLOAD = IMAGE_UPLOAD + + +# Names of files used in the repo +NF_TEMPLATE_JINJA2_SOURCE_TEMPLATE = "nf_template.bicep.j2" +NF_DEFINITION_JSON_FILENAME = "nf_definition.json" +NF_DEFINITION_OUTPUT_BICEP_PREFIX = "nfd-bicep-" +NSD_DEFINITION_JINJA2_SOURCE_TEMPLATE = "nsd_template.bicep.j2" +NSD_BICEP_FILENAME = "nsd_definition.bicep" +NSD_OUTPUT_BICEP_PREFIX = "nsd-bicep-templates" +NSD_ARTIFACT_MANIFEST_BICEP_FILENAME = "artifact_manifest.bicep" +NSD_ARTIFACT_MANIFEST_SOURCE_TEMPLATE_FILENAME = ( + "artifact_manifest_template.bicep" +) + +VNF_DEFINITION_BICEP_TEMPLATE_FILENAME = "vnfdefinition.bicep" +VNF_MANIFEST_BICEP_TEMPLATE_FILENAME = "vnfartifactmanifests.bicep" + +CNF_DEFINITION_JINJA2_SOURCE_TEMPLATE_FILENAME = "cnfdefinition.bicep.j2" +CNF_MANIFEST_JINJA2_SOURCE_TEMPLATE_FILENAME = "cnfartifactmanifest.bicep.j2" +CNF_DEFINITION_BICEP_TEMPLATE_FILENAME = "cnfdefinition.bicep" +CNF_MANIFEST_BICEP_TEMPLATE_FILENAME = "cnfartifactmanifest.bicep" +CNF_VALUES_SCHEMA_FILENAME = "values.schema.json" + + +# Names of directories used in the repo +CONFIG_MAPPINGS_DIR_NAME = "configMappings" +SCHEMAS_DIR_NAME = "schemas" +TEMPLATES_DIR_NAME = "templates" +GENERATED_VALUES_MAPPINGS_DIR_NAME = "generatedValuesMappings" + +# Items used when building NFDs/NSDs +DEPLOYMENT_PARAMETERS_FILENAME = "deploymentParameters.json" +OPTIONAL_DEPLOYMENT_PARAMETERS_FILENAME = "optionalDeploymentParameters.txt" +TEMPLATE_PARAMETERS_FILENAME = "templateParameters.json" +VHD_PARAMETERS_FILENAME = "vhdParameters.json" +OPTIONAL_DEPLOYMENT_PARAMETERS_HEADING = ( + "# The following parameters are optional as they have default values.\n" + "# If you do not wish to expose them in the NFD, find and remove them from both\n" + f"# {DEPLOYMENT_PARAMETERS_FILENAME} and {TEMPLATE_PARAMETERS_FILENAME} (and {VHD_PARAMETERS_FILENAME} if\n" + "they are there)\n" + "# You can re-run the build command with the --order-params flag to order those\n" + "# files with the optional parameters at the end of the file, and with the \n" + "# --interactive flag to interactively choose y/n for each parameter to expose.\n\n" +) + +# Deployment Schema +SCHEMA_PREFIX = { + "$schema": "https://json-schema.org/draft-07/schema#", + "title": "DeployParametersSchema", + "type": "object", + "properties": {}, +} + +# For VNF NFD Generator +# Additional config fields from VHD artifact config in input.json that are +# converted to camel case and end up within configMappings/vhdParameters.json +# These become part of the vnfdefinition.bicep, namely: +# deployParametersMappingRuleProfile: { +# vhdImageMappingRuleProfile: { +# userConfiguration: string(loadJsonContent('configMappings/vhdParameters.json')) +# } +# Add new config fields to this list if they should also end up there. +EXTRA_VHD_PARAMETERS = [ + "image_disk_size_GB", + "image_hyper_v_generation", + "image_api_version" +] + +# For CNF NFD Generator +# To match the image path if image: is present in the yaml file +IMAGE_START_STRING = "image:" +IMAGE_PATH_REGEX = r".Values\.([^\s})]*)" + +# To match the image name and version if 'imagePullSecrets:' is present in the yaml file +IMAGE_PULL_SECRETS_START_STRING = "imagePullSecrets:" +IMAGE_NAME_AND_VERSION_REGEX = r"\/(?P[^\s]*):(?P[^\s)\"}]*)" + +DEPLOYMENT_PARAMETER_MAPPING_REGEX = r"\{deployParameters.(.+?)\}" + +# Assume that the registry id is of the form: +# /subscriptions//resourceGroups//providers/ +# Microsoft.ContainerRegistry/registries/ +# This returns groups for the resource group name and registry name +SOURCE_ACR_REGEX = ( + r".*\/resourceGroups\/(?P[^\/]*)\/providers\/Microsoft." + r"ContainerRegistry\/registries\/(?P[^\/]*)" +) + +# Required features for AOSM publish aka deploy +AOSM_FEATURE_NAMESPACE = "Microsoft.HybridNetwork" +AOSM_REQUIRED_FEATURES = [ + "Allow-2023-09-01", + "Allow-Publisher", +] diff --git a/src/aosm/azext_aosm/util/management_clients.py b/src/aosm/azext_aosm/util/management_clients.py new file mode 100644 index 00000000000..936e0d16ec7 --- /dev/null +++ b/src/aosm/azext_aosm/util/management_clients.py @@ -0,0 +1,22 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Clients for the python SDK along with useful caches.""" + +from dataclasses import dataclass + +from azure.mgmt.resource import ResourceManagementClient +from knack.log import get_logger + +from azext_aosm.vendored_sdks import HybridNetworkManagementClient + +logger = get_logger(__name__) + + +@dataclass +class ApiClients: + """A class for API Clients needed throughout.""" + + aosm_client: HybridNetworkManagementClient + resource_client: ResourceManagementClient diff --git a/src/aosm/azext_aosm/util/utils.py b/src/aosm/azext_aosm/util/utils.py new file mode 100644 index 00000000000..91d144a764c --- /dev/null +++ b/src/aosm/azext_aosm/util/utils.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +"""Utility functions.""" + + +def input_ack(ack: str, request_to_user: str) -> bool: + """ + Overarching function to request, sanitise and return True if input is specified ack. + + This prints the question string and asks for user input. which is santised by + removing all whitespaces in the string, and made lowercase. True is returned if the + user input is equal to supplied acknowledgement string and False if anything else + """ + unsanitised_ans = input(request_to_user) + return str(unsanitised_ans.strip().replace(" ", "").lower()) == ack + + +def snake_case_to_camel_case(text): + """Converts snake case to camel case.""" + components = text.split("_") + return components[0] + "".join( + x[0].upper() + x[1:] for x in components[1:] + ) diff --git a/src/aosm/azext_aosm/vendored_sdks/__init__.py b/src/aosm/azext_aosm/vendored_sdks/__init__.py new file mode 100644 index 00000000000..0033ecc5848 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/__init__.py @@ -0,0 +1,23 @@ +# 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 ._client import HybridNetworkManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HybridNetworkManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/src/aosm/azext_aosm/vendored_sdks/_client.py b/src/aosm/azext_aosm/vendored_sdks/_client.py new file mode 100644 index 00000000000..24be765e165 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/_client.py @@ -0,0 +1,177 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from ._configuration import HybridNetworkManagementClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + ArtifactManifestsOperations, + ArtifactStoresOperations, + ComponentsOperations, + ConfigurationGroupSchemasOperations, + ConfigurationGroupValuesOperations, + NetworkFunctionDefinitionGroupsOperations, + NetworkFunctionDefinitionVersionsOperations, + NetworkFunctionsOperations, + NetworkServiceDesignGroupsOperations, + NetworkServiceDesignVersionsOperations, + Operations, + ProxyArtifactOperations, + PublishersOperations, + SiteNetworkServicesOperations, + SitesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class HybridNetworkManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The definitions in this swagger specification will be used to manage the Hybrid Network + resources. + + :ivar configuration_group_schemas: ConfigurationGroupSchemasOperations operations + :vartype configuration_group_schemas: + Microsoft.HybridNetwork.operations.ConfigurationGroupSchemasOperations + :ivar configuration_group_values: ConfigurationGroupValuesOperations operations + :vartype configuration_group_values: + Microsoft.HybridNetwork.operations.ConfigurationGroupValuesOperations + :ivar network_functions: NetworkFunctionsOperations operations + :vartype network_functions: Microsoft.HybridNetwork.operations.NetworkFunctionsOperations + :ivar components: ComponentsOperations operations + :vartype components: Microsoft.HybridNetwork.operations.ComponentsOperations + :ivar network_function_definition_groups: NetworkFunctionDefinitionGroupsOperations operations + :vartype network_function_definition_groups: + Microsoft.HybridNetwork.operations.NetworkFunctionDefinitionGroupsOperations + :ivar network_function_definition_versions: NetworkFunctionDefinitionVersionsOperations + operations + :vartype network_function_definition_versions: + Microsoft.HybridNetwork.operations.NetworkFunctionDefinitionVersionsOperations + :ivar network_service_design_groups: NetworkServiceDesignGroupsOperations operations + :vartype network_service_design_groups: + Microsoft.HybridNetwork.operations.NetworkServiceDesignGroupsOperations + :ivar network_service_design_versions: NetworkServiceDesignVersionsOperations operations + :vartype network_service_design_versions: + Microsoft.HybridNetwork.operations.NetworkServiceDesignVersionsOperations + :ivar operations: Operations operations + :vartype operations: Microsoft.HybridNetwork.operations.Operations + :ivar publishers: PublishersOperations operations + :vartype publishers: Microsoft.HybridNetwork.operations.PublishersOperations + :ivar artifact_stores: ArtifactStoresOperations operations + :vartype artifact_stores: Microsoft.HybridNetwork.operations.ArtifactStoresOperations + :ivar artifact_manifests: ArtifactManifestsOperations operations + :vartype artifact_manifests: Microsoft.HybridNetwork.operations.ArtifactManifestsOperations + :ivar proxy_artifact: ProxyArtifactOperations operations + :vartype proxy_artifact: Microsoft.HybridNetwork.operations.ProxyArtifactOperations + :ivar sites: SitesOperations operations + :vartype sites: Microsoft.HybridNetwork.operations.SitesOperations + :ivar site_network_services: SiteNetworkServicesOperations operations + :vartype site_network_services: + Microsoft.HybridNetwork.operations.SiteNetworkServicesOperations + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param endpoint: Service URL. Default value is "https://management.azure.com". + :type endpoint: str + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + endpoint: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HybridNetworkManagementClientConfiguration( + subscription_id=subscription_id, credential=credential, **kwargs + ) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=endpoint, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models._models.__dict__.items() if isinstance(v, type)} + client_models.update({k: v for k, v in _models.__dict__.items() if isinstance(v, type)}) + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.configuration_group_schemas = ConfigurationGroupSchemasOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_group_values = ConfigurationGroupValuesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_functions = NetworkFunctionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.network_function_definition_groups = NetworkFunctionDefinitionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_definition_versions = NetworkFunctionDefinitionVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_service_design_groups = NetworkServiceDesignGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_service_design_versions = NetworkServiceDesignVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.publishers = PublishersOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_stores = ArtifactStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_manifests = ArtifactManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proxy_artifact = ProxyArtifactOperations(self._client, self._config, self._serialize, self._deserialize) + self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) + self.site_network_services = SiteNetworkServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> 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/dpcodegen/python/send_request + + :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.rest.HttpResponse + """ + + 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) -> None: + self._client.close() + + def __enter__(self) -> "HybridNetworkManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/src/aosm/azext_aosm/vendored_sdks/_configuration.py b/src/aosm/azext_aosm/vendored_sdks/_configuration.py new file mode 100644 index 00000000000..372da3062f6 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/_configuration.py @@ -0,0 +1,68 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + + +class HybridNetworkManagementClientConfiguration( # pylint: disable=too-many-instance-attributes,name-too-long + Configuration +): + """Configuration for HybridNetworkManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, subscription_id: str, credential: "TokenCredential", **kwargs: Any) -> None: + super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-09-01") + + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.subscription_id = subscription_id + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "hybridnetwork/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + 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 = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/src/aosm/azext_aosm/vendored_sdks/_patch.py b/src/aosm/azext_aosm/vendored_sdks/_patch.py new file mode 100644 index 00000000000..f99e77fef98 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/_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 diff --git a/src/aosm/azext_aosm/vendored_sdks/_serialization.py b/src/aosm/azext_aosm/vendored_sdks/_serialization.py new file mode 100644 index 00000000000..9f3e29b1138 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/_serialization.py @@ -0,0 +1,2008 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Dict[str, Any] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to azure from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + # https://github.com/Azure/autorest.python/issues/2063 + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is AzureCoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/__init__.py b/src/aosm/azext_aosm/vendored_sdks/aio/__init__.py new file mode 100644 index 00000000000..0033ecc5848 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/__init__.py @@ -0,0 +1,23 @@ +# 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 ._client import HybridNetworkManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HybridNetworkManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/_client.py b/src/aosm/azext_aosm/vendored_sdks/aio/_client.py new file mode 100644 index 00000000000..8ea52c785d1 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/_client.py @@ -0,0 +1,177 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import HybridNetworkManagementClientConfiguration +from .operations import ( + ArtifactManifestsOperations, + ArtifactStoresOperations, + ComponentsOperations, + ConfigurationGroupSchemasOperations, + ConfigurationGroupValuesOperations, + NetworkFunctionDefinitionGroupsOperations, + NetworkFunctionDefinitionVersionsOperations, + NetworkFunctionsOperations, + NetworkServiceDesignGroupsOperations, + NetworkServiceDesignVersionsOperations, + Operations, + ProxyArtifactOperations, + PublishersOperations, + SiteNetworkServicesOperations, + SitesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class HybridNetworkManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The definitions in this swagger specification will be used to manage the Hybrid Network + resources. + + :ivar configuration_group_schemas: ConfigurationGroupSchemasOperations operations + :vartype configuration_group_schemas: + Microsoft.HybridNetwork.aio.operations.ConfigurationGroupSchemasOperations + :ivar configuration_group_values: ConfigurationGroupValuesOperations operations + :vartype configuration_group_values: + Microsoft.HybridNetwork.aio.operations.ConfigurationGroupValuesOperations + :ivar network_functions: NetworkFunctionsOperations operations + :vartype network_functions: Microsoft.HybridNetwork.aio.operations.NetworkFunctionsOperations + :ivar components: ComponentsOperations operations + :vartype components: Microsoft.HybridNetwork.aio.operations.ComponentsOperations + :ivar network_function_definition_groups: NetworkFunctionDefinitionGroupsOperations operations + :vartype network_function_definition_groups: + Microsoft.HybridNetwork.aio.operations.NetworkFunctionDefinitionGroupsOperations + :ivar network_function_definition_versions: NetworkFunctionDefinitionVersionsOperations + operations + :vartype network_function_definition_versions: + Microsoft.HybridNetwork.aio.operations.NetworkFunctionDefinitionVersionsOperations + :ivar network_service_design_groups: NetworkServiceDesignGroupsOperations operations + :vartype network_service_design_groups: + Microsoft.HybridNetwork.aio.operations.NetworkServiceDesignGroupsOperations + :ivar network_service_design_versions: NetworkServiceDesignVersionsOperations operations + :vartype network_service_design_versions: + Microsoft.HybridNetwork.aio.operations.NetworkServiceDesignVersionsOperations + :ivar operations: Operations operations + :vartype operations: Microsoft.HybridNetwork.aio.operations.Operations + :ivar publishers: PublishersOperations operations + :vartype publishers: Microsoft.HybridNetwork.aio.operations.PublishersOperations + :ivar artifact_stores: ArtifactStoresOperations operations + :vartype artifact_stores: Microsoft.HybridNetwork.aio.operations.ArtifactStoresOperations + :ivar artifact_manifests: ArtifactManifestsOperations operations + :vartype artifact_manifests: Microsoft.HybridNetwork.aio.operations.ArtifactManifestsOperations + :ivar proxy_artifact: ProxyArtifactOperations operations + :vartype proxy_artifact: Microsoft.HybridNetwork.aio.operations.ProxyArtifactOperations + :ivar sites: SitesOperations operations + :vartype sites: Microsoft.HybridNetwork.aio.operations.SitesOperations + :ivar site_network_services: SiteNetworkServicesOperations operations + :vartype site_network_services: + Microsoft.HybridNetwork.aio.operations.SiteNetworkServicesOperations + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param endpoint: Service URL. Default value is "https://management.azure.com". + :type endpoint: str + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + subscription_id: str, + credential: "AsyncTokenCredential", + endpoint: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HybridNetworkManagementClientConfiguration( + subscription_id=subscription_id, credential=credential, **kwargs + ) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=endpoint, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models._models.__dict__.items() if isinstance(v, type)} + client_models.update({k: v for k, v in _models.__dict__.items() if isinstance(v, type)}) + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.configuration_group_schemas = ConfigurationGroupSchemasOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.configuration_group_values = ConfigurationGroupValuesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_functions = NetworkFunctionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.network_function_definition_groups = NetworkFunctionDefinitionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_function_definition_versions = NetworkFunctionDefinitionVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_service_design_groups = NetworkServiceDesignGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_service_design_versions = NetworkServiceDesignVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.publishers = PublishersOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_stores = ArtifactStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifact_manifests = ArtifactManifestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proxy_artifact = ProxyArtifactOperations(self._client, self._config, self._serialize, self._deserialize) + self.sites = SitesOperations(self._client, self._config, self._serialize, self._deserialize) + self.site_network_services = SiteNetworkServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> 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/dpcodegen/python/send_request + + :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.rest.AsyncHttpResponse + """ + + 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() + + async def __aenter__(self) -> "HybridNetworkManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/_configuration.py b/src/aosm/azext_aosm/vendored_sdks/aio/_configuration.py new file mode 100644 index 00000000000..5bf3294a4eb --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/_configuration.py @@ -0,0 +1,68 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + + +class HybridNetworkManagementClientConfiguration( # pylint: disable=too-many-instance-attributes,name-too-long + Configuration +): + """Configuration for HybridNetworkManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2023-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, subscription_id: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(HybridNetworkManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-09-01") + + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.subscription_id = subscription_id + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "hybridnetwork/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + 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 = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/_patch.py b/src/aosm/azext_aosm/vendored_sdks/aio/_patch.py new file mode 100644 index 00000000000..f99e77fef98 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/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 diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/operations/__init__.py b/src/aosm/azext_aosm/vendored_sdks/aio/operations/__init__.py new file mode 100644 index 00000000000..a874bdde6c9 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/operations/__init__.py @@ -0,0 +1,47 @@ +# 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 ._operations import ConfigurationGroupSchemasOperations +from ._operations import ConfigurationGroupValuesOperations +from ._operations import NetworkFunctionsOperations +from ._operations import ComponentsOperations +from ._operations import NetworkFunctionDefinitionGroupsOperations +from ._operations import NetworkFunctionDefinitionVersionsOperations +from ._operations import NetworkServiceDesignGroupsOperations +from ._operations import NetworkServiceDesignVersionsOperations +from ._operations import Operations +from ._operations import PublishersOperations +from ._operations import ArtifactStoresOperations +from ._operations import ArtifactManifestsOperations +from ._operations import ProxyArtifactOperations +from ._operations import SitesOperations +from ._operations import SiteNetworkServicesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ConfigurationGroupSchemasOperations", + "ConfigurationGroupValuesOperations", + "NetworkFunctionsOperations", + "ComponentsOperations", + "NetworkFunctionDefinitionGroupsOperations", + "NetworkFunctionDefinitionVersionsOperations", + "NetworkServiceDesignGroupsOperations", + "NetworkServiceDesignVersionsOperations", + "Operations", + "PublishersOperations", + "ArtifactStoresOperations", + "ArtifactManifestsOperations", + "ProxyArtifactOperations", + "SitesOperations", + "SiteNetworkServicesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/src/aosm/azext_aosm/vendored_sdks/aio/operations/_operations.py b/src/aosm/azext_aosm/vendored_sdks/aio/operations/_operations.py new file mode 100644 index 00000000000..38981cca2b3 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/operations/_operations.py @@ -0,0 +1,10435 @@ +# pylint: disable=too-many-lines +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._operations import ( + build_artifact_manifests_create_or_update_request, + build_artifact_manifests_delete_request, + build_artifact_manifests_get_request, + build_artifact_manifests_list_by_artifact_store_request, + build_artifact_manifests_list_credential_request, + build_artifact_manifests_update_request, + build_artifact_manifests_update_state_request, + build_artifact_stores_create_or_update_request, + build_artifact_stores_delete_request, + build_artifact_stores_get_request, + build_artifact_stores_list_by_publisher_request, + build_artifact_stores_update_request, + build_components_get_request, + build_components_list_by_network_function_request, + build_configuration_group_schemas_create_or_update_request, + build_configuration_group_schemas_delete_request, + build_configuration_group_schemas_get_request, + build_configuration_group_schemas_list_by_publisher_request, + build_configuration_group_schemas_update_request, + build_configuration_group_schemas_update_state_request, + build_configuration_group_values_create_or_update_request, + build_configuration_group_values_delete_request, + build_configuration_group_values_get_request, + build_configuration_group_values_list_by_resource_group_request, + build_configuration_group_values_list_by_subscription_request, + build_configuration_group_values_update_tags_request, + build_network_function_definition_groups_create_or_update_request, + build_network_function_definition_groups_delete_request, + build_network_function_definition_groups_get_request, + build_network_function_definition_groups_list_by_publisher_request, + build_network_function_definition_groups_update_request, + build_network_function_definition_versions_create_or_update_request, + build_network_function_definition_versions_delete_request, + build_network_function_definition_versions_get_request, + build_network_function_definition_versions_list_by_network_function_definition_group_request, + build_network_function_definition_versions_update_request, + build_network_function_definition_versions_update_state_request, + build_network_functions_create_or_update_request, + build_network_functions_delete_request, + build_network_functions_execute_request_request, + build_network_functions_get_request, + build_network_functions_list_by_resource_group_request, + build_network_functions_list_by_subscription_request, + build_network_functions_update_tags_request, + build_network_service_design_groups_create_or_update_request, + build_network_service_design_groups_delete_request, + build_network_service_design_groups_get_request, + build_network_service_design_groups_list_by_publisher_request, + build_network_service_design_groups_update_request, + build_network_service_design_versions_create_or_update_request, + build_network_service_design_versions_delete_request, + build_network_service_design_versions_get_request, + build_network_service_design_versions_list_by_network_service_design_group_request, + build_network_service_design_versions_update_request, + build_network_service_design_versions_update_state_request, + build_operations_list_request, + build_proxy_artifact_get_request, + build_proxy_artifact_list_request, + build_proxy_artifact_update_state_request, + build_publishers_create_or_update_request, + build_publishers_delete_request, + build_publishers_get_request, + build_publishers_list_by_resource_group_request, + build_publishers_list_by_subscription_request, + build_publishers_update_request, + build_site_network_services_create_or_update_request, + build_site_network_services_delete_request, + build_site_network_services_get_request, + build_site_network_services_list_by_resource_group_request, + build_site_network_services_list_by_subscription_request, + build_site_network_services_update_tags_request, + build_sites_create_or_update_request, + build_sites_delete_request, + build_sites_get_request, + build_sites_list_by_resource_group_request, + build_sites_list_by_subscription_request, + build_sites_update_tags_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConfigurationGroupSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`configuration_group_schemas` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationGroupSchema"]: + """Gets information of the configuration group schemas under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of ConfigurationGroupSchema + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupSchemaListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_schemas_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupSchemaListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_configuration_group_schemas_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specified configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchema, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupSchema") + + request = build_configuration_group_schemas_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.ConfigurationGroupSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchema + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchema + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchema, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Is either a ConfigurationGroupSchema type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchema + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Gets information about the specified configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + request = build_configuration_group_schemas_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_configuration_group_schemas_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchemaVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.ConfigurationGroupSchemaVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ConfigurationGroupSchemaVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupSchemaVersionUpdateState") + + request = build_configuration_group_schemas_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupSchemaVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.ConfigurationGroupSchemaVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchemaVersionUpdateState, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. Is + either a ConfigurationGroupSchemaVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchemaVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupSchemaVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ConfigurationGroupValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`configuration_group_values` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_configuration_group_values_delete_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Gets information about the specified hybrid configuration group values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + request = build_configuration_group_values_get_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _create_or_update_initial( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.ConfigurationGroupValue, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupValue") + + request = build_configuration_group_values_create_or_update_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: _models.ConfigurationGroupValue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupValue + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupValue + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.ConfigurationGroupValue, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Is either a ConfigurationGroupValue type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ConfigurationGroupValue + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Is either a + TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_configuration_group_values_update_tags_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ConfigurationGroupValue"]: + """Lists all sites in the configuration group value in a subscription. + + :return: An iterator like instance of ConfigurationGroupValue + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupValueListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_values_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupValueListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationGroupValue"]: + """Lists all the hybrid network configurationGroupValues in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ConfigurationGroupValue + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupValueListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_values_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupValueListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + +class NetworkFunctionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_functions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, network_function_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_functions_delete_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, network_function_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, network_function_name: str, **kwargs: Any) -> _models.NetworkFunction: + """Gets information about the specified network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function resource. Required. + :type network_function_name: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + request = build_network_functions_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _create_or_update_initial( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.NetworkFunction, IO], + **kwargs: Any + ) -> _models.NetworkFunction: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunction") + + request = build_network_functions_create_or_update_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.NetworkFunction, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunction + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.NetworkFunction, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Is either a NetworkFunction type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunction or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunction", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Is either + a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_functions_update_tags_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NetworkFunction"]: + """Lists all the network functions in a subscription. + + :return: An iterator like instance of NetworkFunction + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.NetworkFunctionListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_functions_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkFunction"]: + """Lists all the network function resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of NetworkFunction + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.NetworkFunctionListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_functions_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _execute_request_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.ExecuteRequestParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExecuteRequestParameters") + + request = build_network_functions_execute_request_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @overload + async def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ExecuteRequestParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.ExecuteRequestParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Is either a ExecuteRequestParameters + type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ExecuteRequestParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._execute_request_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, network_function_name: str, component_name: str, **kwargs: Any + ) -> _models.Component: + """Gets information about the specified application instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param component_name: The name of the component. Required. + :type component_name: str + :return: Component + :rtype: ~Microsoft.HybridNetwork.models.Component + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Component] = kwargs.pop("cls", None) + + request = build_components_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Component", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_function( + self, resource_group_name: str, network_function_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Component"]: + """Lists all the component resources in a network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :return: An iterator like instance of Component + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Component] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ComponentListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_components_list_by_network_function_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ComponentListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + +class NetworkFunctionDefinitionGroupsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_function_definition_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkFunctionDefinitionGroup"]: + """Gets information of the network function definition groups under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkFunctionDefinitionGroupListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_function_definition_groups_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionDefinitionGroupListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_function_definition_groups_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specified network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.NetworkFunctionDefinitionGroup, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionGroup") + + request = build_network_function_definition_groups_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: _models.NetworkFunctionDefinitionGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.NetworkFunctionDefinitionGroup, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Is either a NetworkFunctionDefinitionGroup type or a IO type. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Gets information about the specified networkFunctionDefinition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + request = build_network_function_definition_groups_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_function_definition_groups_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NetworkFunctionDefinitionVersionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_function_definition_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_function_definition_versions_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersion, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionVersion") + + request = build_network_function_definition_versions_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.NetworkFunctionDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersion, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Is either a NetworkFunctionDefinitionVersion type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Gets information about a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + request = build_network_function_definition_versions_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_function_definition_versions_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_function_definition_group( # pylint: disable=name-too-long + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkFunctionDefinitionVersion"]: + """Gets information about a list of network function definition versions under a network function + definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :return: An iterator like instance of NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkFunctionDefinitionVersionListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_function_definition_versions_list_by_network_function_definition_group_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionDefinitionVersionListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.NetworkFunctionDefinitionVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NetworkFunctionDefinitionVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionVersionUpdateState") + + request = build_network_function_definition_versions_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.NetworkFunctionDefinitionVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersionUpdateState, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Is either a NetworkFunctionDefinitionVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class NetworkServiceDesignGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_service_design_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkServiceDesignGroup"]: + """Gets information of the network service design groups under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of NetworkServiceDesignGroup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkServiceDesignGroupListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_service_design_groups_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkServiceDesignGroupListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_service_design_groups_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a specified network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.NetworkServiceDesignGroup, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignGroup") + + request = build_network_service_design_groups_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: _models.NetworkServiceDesignGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.NetworkServiceDesignGroup, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Is either a NetworkServiceDesignGroup type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Gets information about the specified networkServiceDesign group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + request = build_network_service_design_groups_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_service_design_groups_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NetworkServiceDesignVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`network_service_design_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_service_design_versions_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersion, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignVersion") + + request = build_network_service_design_versions_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.NetworkServiceDesignVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersion, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a NetworkServiceDesignVersion type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Gets information about a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + request = build_network_service_design_versions_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_service_design_versions_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_service_design_group( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkServiceDesignVersion"]: + """Gets information about a list of network service design versions under a network service design + group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :return: An iterator like instance of NetworkServiceDesignVersion + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkServiceDesignVersionListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_service_design_versions_list_by_network_service_design_group_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkServiceDesignVersionListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.NetworkServiceDesignVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NetworkServiceDesignVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignVersionUpdateState") + + request = build_network_service_design_versions_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.NetworkServiceDesignVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersionUpdateState, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Is either a NetworkServiceDesignVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Gets a list of the operations. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.OperationListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.OperationListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + +class PublishersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`publishers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Publisher"]: + """Lists all the publishers in a subscription. + + :return: An iterator like instance of Publisher + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.PublisherListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_publishers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.PublisherListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Publisher"]: + """Lists all the publishers in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Publisher + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.PublisherListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_publishers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.PublisherListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_publishers_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, publisher_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the specified publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, publisher_name: str, **kwargs: Any) -> _models.Publisher: + """Gets information about the specified publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + request = build_publishers_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.Publisher, IO]] = None, + **kwargs: Any + ) -> _models.Publisher: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Publisher") + else: + _json = None + + request = build_publishers_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("Publisher", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[_models.Publisher] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: ~Microsoft.HybridNetwork.models.Publisher + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Publisher + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Publisher + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.Publisher, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Is either a Publisher + type or a IO type. Default value is None. + :type parameters: ~Microsoft.HybridNetwork.models.Publisher or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Publisher + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Publisher", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[_models.TagsObject] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.TagsObject, IO]] = None, + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Is either a + TagsObject type or a IO type. Default value is None. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "TagsObject") + else: + _json = None + + request = build_publishers_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ArtifactStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`artifact_stores` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArtifactStore"]: + """Gets information of the ArtifactStores under publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of ArtifactStore + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ArtifactStoreListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_artifact_stores_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ArtifactStoreListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_artifact_stores_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.ArtifactStore, IO], + **kwargs: Any + ) -> _models.ArtifactStore: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactStore") + + request = build_artifact_stores_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: _models.ArtifactStore, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactStore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.ArtifactStore, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. Is + either a ArtifactStore type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactStore or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactStore", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> _models.ArtifactStore: + """Gets information about the specified artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + request = build_artifact_stores_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. Is + either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_artifact_stores_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ArtifactManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`artifact_manifests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_artifact_store( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArtifactManifest"]: + """Gets information about the artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: An iterator like instance of ArtifactManifest + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ArtifactManifestListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_artifact_manifests_list_by_artifact_store_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ArtifactManifestListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_artifact_manifests_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifest, IO], + **kwargs: Any + ) -> _models.ArtifactManifest: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactManifest") + + request = build_artifact_manifests_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.ArtifactManifest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifest, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. Is + either a ArtifactManifest type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> _models.ArtifactManifest: + """Gets information about a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + request = build_artifact_manifests_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. Is + either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_artifact_manifests_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def list_credential( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> _models.ArtifactAccessCredential: + """List credential for publishing artifacts defined in artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :return: ArtifactAccessCredential + :rtype: ~Microsoft.HybridNetwork.models.ArtifactAccessCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactAccessCredential] = kwargs.pop("cls", None) + + request = build_artifact_manifests_list_credential_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactAccessCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifestUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.ArtifactManifestUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArtifactManifestUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactManifestUpdateState") + + request = build_artifact_manifests_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ArtifactManifestUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.ArtifactManifestUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifestUpdateState, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Is either a + ArtifactManifestUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifestUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactManifestUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ProxyArtifactOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`proxy_artifact` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ProxyArtifactListOverview"]: + """Lists all the available artifacts in the parent Artifact Store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: An iterator like instance of ProxyArtifactListOverview + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ProxyArtifactListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ProxyArtifactOverviewListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_proxy_artifact_list_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ProxyArtifactOverviewListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def get( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + *, + artifact_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ProxyArtifactVersionsListOverview"]: + """Get a Artifact overview information. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :return: An iterator like instance of ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ProxyArtifactVersionsOverviewListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_proxy_artifact_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + artifact_name=artifact_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ProxyArtifactVersionsOverviewListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + async def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: Union[_models.ArtifactChangeState, IO], + *, + artifact_name: str, + **kwargs: Any + ) -> Optional[_models.ProxyArtifactVersionsListOverview]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ProxyArtifactVersionsListOverview]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactChangeState") + + request = build_proxy_artifact_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_version_name=artifact_version_name, + subscription_id=self._config.subscription_id, + artifact_name=artifact_name, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ProxyArtifactVersionsListOverview", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: _models.ArtifactChangeState, + *, + artifact_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactChangeState + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: IO, + *, + artifact_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: IO + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: Union[_models.ArtifactChangeState, IO], + *, + artifact_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Is either a + ArtifactChangeState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactChangeState or IO + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProxyArtifactVersionsListOverview] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_version_name=artifact_version_name, + parameters=parameters, + artifact_name=artifact_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ProxyArtifactVersionsListOverview", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SitesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`sites` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, site_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_sites_delete_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, site_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the specified network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + site_name=site_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, site_name: str, **kwargs: Any) -> _models.Site: + """Gets information about the specified network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + request = build_sites_get_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _create_or_update_initial( + self, resource_group_name: str, site_name: str, parameters: Union[_models.Site, IO], **kwargs: Any + ) -> _models.Site: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Site") + + request = build_sites_create_or_update_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("Site", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + site_name: str, + parameters: _models.Site, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.Site + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Site + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Site + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, site_name: str, parameters: Union[_models.Site, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. Is + either a Site type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.Site or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns Site + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + site_name=site_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Site", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + site_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, resource_group_name: str, site_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Is either a TagsObject type + or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_sites_update_tags_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Site"]: + """Lists all sites in the network service in a subscription. + + :return: An iterator like instance of Site + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_sites_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Site"]: + """Lists all sites in the network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Site + :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_sites_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + +class SiteNetworkServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.aio.HybridNetworkManagementClient`'s + :attr:`site_network_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, site_network_service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_site_network_services_delete_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, site_network_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified site network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, site_network_service_name: str, **kwargs: Any + ) -> _models.SiteNetworkService: + """Gets information about the specified site network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + request = build_site_network_services_get_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + async def _create_or_update_initial( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.SiteNetworkService, IO], + **kwargs: Any + ) -> _models.SiteNetworkService: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SiteNetworkService") + + request = build_site_network_services_create_or_update_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: _models.SiteNetworkService, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.SiteNetworkService + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.SiteNetworkService, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Is either a SiteNetworkService type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.SiteNetworkService or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.AsyncLROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Is either a TagsObject type + or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_site_network_services_update_tags_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SiteNetworkService"]: + """Lists all sites in the network service in a subscription. + + :return: An iterator like instance of SiteNetworkService + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteNetworkServiceListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_site_network_services_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteNetworkServiceListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SiteNetworkService"]: + """Lists all site network services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of SiteNetworkService + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteNetworkServiceListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_site_network_services_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteNetworkServiceListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + await response.read() # Load the body in memory and close the socket + 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/src/aosm/azext_aosm/vendored_sdks/aio/operations/_patch.py b/src/aosm/azext_aosm/vendored_sdks/aio/operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/aosm/azext_aosm/vendored_sdks/models/__init__.py b/src/aosm/azext_aosm/vendored_sdks/models/__init__.py new file mode 100644 index 00000000000..54ee0c7eb05 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/models/__init__.py @@ -0,0 +1,335 @@ +# 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 ._models import ArmResourceDefinitionResourceElementTemplate +from ._models import ArmResourceDefinitionResourceElementTemplateDetails +from ._models import ArmTemplateArtifactProfile +from ._models import ArmTemplateMappingRuleProfile +from ._models import ArtifactAccessCredential +from ._models import ArtifactChangeState +from ._models import ArtifactChangeStateProperties +from ._models import ArtifactManifest +from ._models import ArtifactManifestPropertiesFormat +from ._models import ArtifactManifestUpdateState +from ._models import ArtifactProfile +from ._models import ArtifactStore +from ._models import ArtifactStorePropertiesFormat +from ._models import ArtifactStorePropertiesFormatManagedResourceGroupConfiguration +from ._models import AzureArcK8SClusterNFVIDetails +from ._models import AzureArcKubernetesArtifactProfile +from ._models import AzureArcKubernetesDeployMappingRuleProfile +from ._models import AzureArcKubernetesHelmApplication +from ._models import AzureArcKubernetesNetworkFunctionApplication +from ._models import AzureArcKubernetesNetworkFunctionTemplate +from ._models import AzureContainerRegistryScopedTokenCredential +from ._models import AzureCoreArmTemplateArtifactProfile +from ._models import AzureCoreArmTemplateDeployMappingRuleProfile +from ._models import AzureCoreNFVIDetails +from ._models import AzureCoreNetworkFunctionApplication +from ._models import AzureCoreNetworkFunctionArmTemplateApplication +from ._models import AzureCoreNetworkFunctionTemplate +from ._models import AzureCoreNetworkFunctionVhdApplication +from ._models import AzureCoreVhdImageArtifactProfile +from ._models import AzureCoreVhdImageDeployMappingRuleProfile +from ._models import AzureOperatorNexusArmTemplateArtifactProfile +from ._models import AzureOperatorNexusArmTemplateDeployMappingRuleProfile +from ._models import AzureOperatorNexusClusterNFVIDetails +from ._models import AzureOperatorNexusImageArtifactProfile +from ._models import AzureOperatorNexusImageDeployMappingRuleProfile +from ._models import AzureOperatorNexusNetworkFunctionApplication +from ._models import AzureOperatorNexusNetworkFunctionArmTemplateApplication +from ._models import AzureOperatorNexusNetworkFunctionImageApplication +from ._models import AzureOperatorNexusNetworkFunctionTemplate +from ._models import AzureStorageAccountContainerCredential +from ._models import AzureStorageAccountCredential +from ._models import Component +from ._models import ComponentProperties +from ._models import ConfigurationGroupSchema +from ._models import ConfigurationGroupSchemaPropertiesFormat +from ._models import ConfigurationGroupSchemaVersionUpdateState +from ._models import ConfigurationGroupValue +from ._models import ConfigurationGroupValuePropertiesFormat +from ._models import ConfigurationValueWithSecrets +from ._models import ConfigurationValueWithoutSecrets +from ._models import ContainerizedNetworkFunctionDefinitionVersion +from ._models import ContainerizedNetworkFunctionTemplate +from ._models import CustomLocationResourceId +from ._models import DaemonSet +from ._models import DependsOnProfile +from ._models import Deployment +from ._models import DeploymentResourceIdReference +from ._models import DeploymentStatusProperties +from ._models import ErrorAdditionalInfo +from ._models import ErrorDetail +from ._models import ErrorResponse +from ._models import ExecuteRequestParameters +from ._models import HelmArtifactProfile +from ._models import HelmInstallOptions +from ._models import HelmMappingRuleProfile +from ._models import HelmMappingRuleProfileOptions +from ._models import HelmUpgradeOptions +from ._models import ImageArtifactProfile +from ._models import ImageMappingRuleProfile +from ._models import ManagedResourceGroupConfiguration +from ._models import ManagedServiceIdentity +from ._models import ManifestArtifactFormat +from ._models import MappingRuleProfile +from ._models import NFVIs +from ._models import NSDArtifactProfile +from ._models import NetworkFunction +from ._models import NetworkFunctionApplication +from ._models import NetworkFunctionDefinitionGroup +from ._models import NetworkFunctionDefinitionGroupPropertiesFormat +from ._models import NetworkFunctionDefinitionResourceElementTemplateDetails +from ._models import NetworkFunctionDefinitionVersion +from ._models import NetworkFunctionDefinitionVersionPropertiesFormat +from ._models import NetworkFunctionDefinitionVersionUpdateState +from ._models import NetworkFunctionPropertiesFormat +from ._models import NetworkFunctionValueWithSecrets +from ._models import NetworkFunctionValueWithoutSecrets +from ._models import NetworkServiceDesignGroup +from ._models import NetworkServiceDesignGroupPropertiesFormat +from ._models import NetworkServiceDesignVersion +from ._models import NetworkServiceDesignVersionPropertiesFormat +from ._models import NetworkServiceDesignVersionUpdateState +from ._models import NfviDetails +from ._models import OpenDeploymentResourceReference +from ._models import Operation +from ._models import OperationDisplay +from ._models import Pod +from ._models import PodEvent +from ._models import ProxyArtifactListOverview +from ._models import ProxyArtifactOverview +from ._models import ProxyArtifactOverviewPropertiesFormat +from ._models import ProxyArtifactOverviewPropertiesValue +from ._models import ProxyArtifactVersionsListOverview +from ._models import ProxyResource +from ._models import Publisher +from ._models import PublisherPropertiesFormat +from ._models import ReferencedResource +from ._models import ReplicaSet +from ._models import RequestMetadata +from ._models import Resource +from ._models import ResourceElementTemplate +from ._models import Resources +from ._models import SecretDeploymentResourceReference +from ._models import Site +from ._models import SiteNetworkService +from ._models import SiteNetworkServicePropertiesFormat +from ._models import SitePropertiesFormat +from ._models import Sku +from ._models import StatefulSet +from ._models import SystemData +from ._models import TagsObject +from ._models import TrackedResource +from ._models import UserAssignedIdentity +from ._models import VhdImageArtifactProfile +from ._models import VhdImageMappingRuleProfile +from ._models import VirtualNetworkFunctionDefinitionVersion +from ._models import VirtualNetworkFunctionTemplate + +from ._enums import ActionType +from ._enums import ApplicationEnablement +from ._enums import ArtifactManifestState +from ._enums import ArtifactReplicationStrategy +from ._enums import ArtifactState +from ._enums import ArtifactStoreType +from ._enums import ArtifactType +from ._enums import AzureArcKubernetesArtifactType +from ._enums import AzureCoreArtifactType +from ._enums import AzureOperatorNexusArtifactType +from ._enums import ConfigurationGenerationType +from ._enums import ConfigurationGroupValueConfigurationType +from ._enums import ContainerizedNetworkFunctionNFVIType +from ._enums import CreatedByType +from ._enums import CredentialType +from ._enums import HttpMethod +from ._enums import IdType +from ._enums import ManagedServiceIdentityType +from ._enums import NFVIType +from ._enums import NetworkFunctionConfigurationType +from ._enums import NetworkFunctionType +from ._enums import Origin +from ._enums import PodEventType +from ._enums import PodStatus +from ._enums import ProvisioningState +from ._enums import PublisherScope +from ._enums import SkuName +from ._enums import SkuTier +from ._enums import Status +from ._enums import TemplateType +from ._enums import Type +from ._enums import VersionState +from ._enums import VirtualNetworkFunctionNFVIType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ArmResourceDefinitionResourceElementTemplate", + "ArmResourceDefinitionResourceElementTemplateDetails", + "ArmTemplateArtifactProfile", + "ArmTemplateMappingRuleProfile", + "ArtifactAccessCredential", + "ArtifactChangeState", + "ArtifactChangeStateProperties", + "ArtifactManifest", + "ArtifactManifestPropertiesFormat", + "ArtifactManifestUpdateState", + "ArtifactProfile", + "ArtifactStore", + "ArtifactStorePropertiesFormat", + "ArtifactStorePropertiesFormatManagedResourceGroupConfiguration", + "AzureArcK8SClusterNFVIDetails", + "AzureArcKubernetesArtifactProfile", + "AzureArcKubernetesDeployMappingRuleProfile", + "AzureArcKubernetesHelmApplication", + "AzureArcKubernetesNetworkFunctionApplication", + "AzureArcKubernetesNetworkFunctionTemplate", + "AzureContainerRegistryScopedTokenCredential", + "AzureCoreArmTemplateArtifactProfile", + "AzureCoreArmTemplateDeployMappingRuleProfile", + "AzureCoreNFVIDetails", + "AzureCoreNetworkFunctionApplication", + "AzureCoreNetworkFunctionArmTemplateApplication", + "AzureCoreNetworkFunctionTemplate", + "AzureCoreNetworkFunctionVhdApplication", + "AzureCoreVhdImageArtifactProfile", + "AzureCoreVhdImageDeployMappingRuleProfile", + "AzureOperatorNexusArmTemplateArtifactProfile", + "AzureOperatorNexusArmTemplateDeployMappingRuleProfile", + "AzureOperatorNexusClusterNFVIDetails", + "AzureOperatorNexusImageArtifactProfile", + "AzureOperatorNexusImageDeployMappingRuleProfile", + "AzureOperatorNexusNetworkFunctionApplication", + "AzureOperatorNexusNetworkFunctionArmTemplateApplication", + "AzureOperatorNexusNetworkFunctionImageApplication", + "AzureOperatorNexusNetworkFunctionTemplate", + "AzureStorageAccountContainerCredential", + "AzureStorageAccountCredential", + "Component", + "ComponentProperties", + "ConfigurationGroupSchema", + "ConfigurationGroupSchemaPropertiesFormat", + "ConfigurationGroupSchemaVersionUpdateState", + "ConfigurationGroupValue", + "ConfigurationGroupValuePropertiesFormat", + "ConfigurationValueWithSecrets", + "ConfigurationValueWithoutSecrets", + "ContainerizedNetworkFunctionDefinitionVersion", + "ContainerizedNetworkFunctionTemplate", + "CustomLocationResourceId", + "DaemonSet", + "DependsOnProfile", + "Deployment", + "DeploymentResourceIdReference", + "DeploymentStatusProperties", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "ExecuteRequestParameters", + "HelmArtifactProfile", + "HelmInstallOptions", + "HelmMappingRuleProfile", + "HelmMappingRuleProfileOptions", + "HelmUpgradeOptions", + "ImageArtifactProfile", + "ImageMappingRuleProfile", + "ManagedResourceGroupConfiguration", + "ManagedServiceIdentity", + "ManifestArtifactFormat", + "MappingRuleProfile", + "NFVIs", + "NSDArtifactProfile", + "NetworkFunction", + "NetworkFunctionApplication", + "NetworkFunctionDefinitionGroup", + "NetworkFunctionDefinitionGroupPropertiesFormat", + "NetworkFunctionDefinitionResourceElementTemplateDetails", + "NetworkFunctionDefinitionVersion", + "NetworkFunctionDefinitionVersionPropertiesFormat", + "NetworkFunctionDefinitionVersionUpdateState", + "NetworkFunctionPropertiesFormat", + "NetworkFunctionValueWithSecrets", + "NetworkFunctionValueWithoutSecrets", + "NetworkServiceDesignGroup", + "NetworkServiceDesignGroupPropertiesFormat", + "NetworkServiceDesignVersion", + "NetworkServiceDesignVersionPropertiesFormat", + "NetworkServiceDesignVersionUpdateState", + "NfviDetails", + "OpenDeploymentResourceReference", + "Operation", + "OperationDisplay", + "Pod", + "PodEvent", + "ProxyArtifactListOverview", + "ProxyArtifactOverview", + "ProxyArtifactOverviewPropertiesFormat", + "ProxyArtifactOverviewPropertiesValue", + "ProxyArtifactVersionsListOverview", + "ProxyResource", + "Publisher", + "PublisherPropertiesFormat", + "ReferencedResource", + "ReplicaSet", + "RequestMetadata", + "Resource", + "ResourceElementTemplate", + "Resources", + "SecretDeploymentResourceReference", + "Site", + "SiteNetworkService", + "SiteNetworkServicePropertiesFormat", + "SitePropertiesFormat", + "Sku", + "StatefulSet", + "SystemData", + "TagsObject", + "TrackedResource", + "UserAssignedIdentity", + "VhdImageArtifactProfile", + "VhdImageMappingRuleProfile", + "VirtualNetworkFunctionDefinitionVersion", + "VirtualNetworkFunctionTemplate", + "ActionType", + "ApplicationEnablement", + "ArtifactManifestState", + "ArtifactReplicationStrategy", + "ArtifactState", + "ArtifactStoreType", + "ArtifactType", + "AzureArcKubernetesArtifactType", + "AzureCoreArtifactType", + "AzureOperatorNexusArtifactType", + "ConfigurationGenerationType", + "ConfigurationGroupValueConfigurationType", + "ContainerizedNetworkFunctionNFVIType", + "CreatedByType", + "CredentialType", + "HttpMethod", + "IdType", + "ManagedServiceIdentityType", + "NFVIType", + "NetworkFunctionConfigurationType", + "NetworkFunctionType", + "Origin", + "PodEventType", + "PodStatus", + "ProvisioningState", + "PublisherScope", + "SkuName", + "SkuTier", + "Status", + "TemplateType", + "Type", + "VersionState", + "VirtualNetworkFunctionNFVIType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/src/aosm/azext_aosm/vendored_sdks/models/_enums.py b/src/aosm/azext_aosm/vendored_sdks/models/_enums.py new file mode 100644 index 00000000000..dab9852f90f --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/models/_enums.py @@ -0,0 +1,302 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class ApplicationEnablement(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The application enablement.""" + + UNKNOWN = "Unknown" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ArtifactManifestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact manifest state.""" + + UNKNOWN = "Unknown" + UPLOADING = "Uploading" + UPLOADED = "Uploaded" + VALIDATING = "Validating" + VALIDATION_FAILED = "ValidationFailed" + SUCCEEDED = "Succeeded" + + +class ArtifactReplicationStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The replication strategy.""" + + UNKNOWN = "Unknown" + SINGLE_REPLICATION = "SingleReplication" + + +class ArtifactState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact state.""" + + UNKNOWN = "Unknown" + PREVIEW = "Preview" + ACTIVE = "Active" + DEPRECATED = "Deprecated" + + +class ArtifactStoreType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact store type.""" + + UNKNOWN = "Unknown" + AZURE_CONTAINER_REGISTRY = "AzureContainerRegistry" + AZURE_STORAGE_ACCOUNT = "AzureStorageAccount" + + +class ArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact type.""" + + UNKNOWN = "Unknown" + OCI_ARTIFACT = "OCIArtifact" + VHD_IMAGE_FILE = "VhdImageFile" + ARM_TEMPLATE = "ArmTemplate" + IMAGE_FILE = "ImageFile" + + +class AzureArcKubernetesArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact type.""" + + UNKNOWN = "Unknown" + HELM_PACKAGE = "HelmPackage" + + +class AzureCoreArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact type.""" + + UNKNOWN = "Unknown" + VHD_IMAGE_FILE = "VhdImageFile" + ARM_TEMPLATE = "ArmTemplate" + + +class AzureOperatorNexusArtifactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The artifact type.""" + + UNKNOWN = "Unknown" + IMAGE_FILE = "ImageFile" + ARM_TEMPLATE = "ArmTemplate" + + +class ConfigurationGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The configuration generation type.""" + + UNKNOWN = "Unknown" + HANDLEBAR_TEMPLATE = "HandlebarTemplate" + + +class ConfigurationGroupValueConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The secret type which indicates if secret or not.""" + + UNKNOWN = "Unknown" + SECRET = "Secret" + OPEN = "Open" + + +class ContainerizedNetworkFunctionNFVIType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network function type.""" + + UNKNOWN = "Unknown" + AZURE_ARC_KUBERNETES = "AzureArcKubernetes" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CredentialType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The credential type.""" + + UNKNOWN = "Unknown" + AZURE_CONTAINER_REGISTRY_SCOPED_TOKEN = "AzureContainerRegistryScopedToken" + AZURE_STORAGE_ACCOUNT_TOKEN = "AzureStorageAccountToken" + + +class HttpMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The http method of the request.""" + + UNKNOWN = "Unknown" + POST = "Post" + PUT = "Put" + GET = "Get" + PATCH = "Patch" + DELETE = "Delete" + + +class IdType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The resource reference arm id type.""" + + UNKNOWN = "Unknown" + OPEN = "Open" + SECRET = "Secret" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class NetworkFunctionConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The secret type which indicates if secret or not.""" + + UNKNOWN = "Unknown" + SECRET = "Secret" + OPEN = "Open" + + +class NetworkFunctionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network function type.""" + + UNKNOWN = "Unknown" + VIRTUAL_NETWORK_FUNCTION = "VirtualNetworkFunction" + CONTAINERIZED_NETWORK_FUNCTION = "ContainerizedNetworkFunction" + + +class NFVIType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The NFVI type.""" + + UNKNOWN = "Unknown" + AZURE_ARC_KUBERNETES = "AzureArcKubernetes" + AZURE_CORE = "AzureCore" + AZURE_OPERATOR_NEXUS = "AzureOperatorNexus" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + +class PodEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of pod event.""" + + NORMAL = "Normal" + WARNING = "Warning" + + +class PodStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a Pod.""" + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + RUNNING = "Running" + PENDING = "Pending" + TERMINATING = "Terminating" + NOT_READY = "NotReady" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + ACCEPTED = "Accepted" + DELETING = "Deleting" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + CONVERGING = "Converging" + + +class PublisherScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Publisher Scope.""" + + UNKNOWN = "Unknown" + PRIVATE = "Private" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of this Sku.""" + + BASIC = "Basic" + STANDARD = "Standard" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier based on the SKU name.""" + + BASIC = "Basic" + STANDARD = "Standard" + + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The component resource deployment status.""" + + UNKNOWN = "Unknown" + DEPLOYED = "Deployed" + UNINSTALLED = "Uninstalled" + SUPERSEDED = "Superseded" + FAILED = "Failed" + UNINSTALLING = "Uninstalling" + PENDING_INSTALL = "Pending-Install" + PENDING_UPGRADE = "Pending-Upgrade" + PENDING_ROLLBACK = "Pending-Rollback" + DOWNLOADING = "Downloading" + INSTALLING = "Installing" + REINSTALLING = "Reinstalling" + ROLLINGBACK = "Rollingback" + UPGRADING = "Upgrading" + + +class TemplateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The template type.""" + + UNKNOWN = "Unknown" + ARM_TEMPLATE = "ArmTemplate" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The resource element template type.""" + + UNKNOWN = "Unknown" + ARM_RESOURCE_DEFINITION = "ArmResourceDefinition" + NETWORK_FUNCTION_DEFINITION = "NetworkFunctionDefinition" + + +class VersionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The configuration group schema state.""" + + UNKNOWN = "Unknown" + PREVIEW = "Preview" + ACTIVE = "Active" + DEPRECATED = "Deprecated" + VALIDATING = "Validating" + VALIDATION_FAILED = "ValidationFailed" + + +class VirtualNetworkFunctionNFVIType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network function type.""" + + UNKNOWN = "Unknown" + AZURE_CORE = "AzureCore" + AZURE_OPERATOR_NEXUS = "AzureOperatorNexus" diff --git a/src/aosm/azext_aosm/vendored_sdks/models/_models.py b/src/aosm/azext_aosm/vendored_sdks/models/_models.py new file mode 100644 index 00000000000..a8685b992fe --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/models/_models.py @@ -0,0 +1,6325 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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 datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ArmResourceDefinitionResourceElementTemplate(_serialization.Model): + """The arm template RE. + + :ivar template_type: The template type. Known values are: "Unknown" and "ArmTemplate". + :vartype template_type: str or ~Microsoft.HybridNetwork.models.TemplateType + :ivar parameter_values: Name and value pairs that define the parameter values. It can be a + well formed escaped JSON string. + :vartype parameter_values: str + :ivar artifact_profile: Artifact profile properties. + :vartype artifact_profile: ~Microsoft.HybridNetwork.models.NSDArtifactProfile + """ + + _attribute_map = { + "template_type": {"key": "templateType", "type": "str"}, + "parameter_values": {"key": "parameterValues", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "NSDArtifactProfile"}, + } + + def __init__( + self, + *, + template_type: Optional[Union[str, "_models.TemplateType"]] = None, + parameter_values: Optional[str] = None, + artifact_profile: Optional["_models.NSDArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword template_type: The template type. Known values are: "Unknown" and "ArmTemplate". + :paramtype template_type: str or ~Microsoft.HybridNetwork.models.TemplateType + :keyword parameter_values: Name and value pairs that define the parameter values. It can be a + well formed escaped JSON string. + :paramtype parameter_values: str + :keyword artifact_profile: Artifact profile properties. + :paramtype artifact_profile: ~Microsoft.HybridNetwork.models.NSDArtifactProfile + """ + super().__init__(**kwargs) + self.template_type = template_type + self.parameter_values = parameter_values + self.artifact_profile = artifact_profile + + +class ResourceElementTemplate(_serialization.Model): + """The resource element template object. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArmResourceDefinitionResourceElementTemplateDetails, + NetworkFunctionDefinitionResourceElementTemplateDetails + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the resource element template. + :vartype name: str + :ivar resource_element_type: The resource element template type. Required. Known values are: + "Unknown", "ArmResourceDefinition", and "NetworkFunctionDefinition". + :vartype resource_element_type: str or ~Microsoft.HybridNetwork.models.Type + :ivar depends_on_profile: The depends on profile. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + + _validation = { + "resource_element_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "resource_element_type": {"key": "type", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + } + + _subtype_map = { + "resource_element_type": { + "ArmResourceDefinition": "ArmResourceDefinitionResourceElementTemplateDetails", + "NetworkFunctionDefinition": "NetworkFunctionDefinitionResourceElementTemplateDetails", + } + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource element template. + :paramtype name: str + :keyword depends_on_profile: The depends on profile. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + super().__init__(**kwargs) + self.name = name + self.resource_element_type: Optional[str] = None + self.depends_on_profile = depends_on_profile + + +class ArmResourceDefinitionResourceElementTemplateDetails(ResourceElementTemplate): + """The arm resource definition resource element template details. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the resource element template. + :vartype name: str + :ivar resource_element_type: The resource element template type. Required. Known values are: + "Unknown", "ArmResourceDefinition", and "NetworkFunctionDefinition". + :vartype resource_element_type: str or ~Microsoft.HybridNetwork.models.Type + :ivar depends_on_profile: The depends on profile. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar configuration: The resource element template type. + :vartype configuration: + ~Microsoft.HybridNetwork.models.ArmResourceDefinitionResourceElementTemplate + """ + + _validation = { + "resource_element_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "resource_element_type": {"key": "type", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "configuration": {"key": "configuration", "type": "ArmResourceDefinitionResourceElementTemplate"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + configuration: Optional["_models.ArmResourceDefinitionResourceElementTemplate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource element template. + :paramtype name: str + :keyword depends_on_profile: The depends on profile. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword configuration: The resource element template type. + :paramtype configuration: + ~Microsoft.HybridNetwork.models.ArmResourceDefinitionResourceElementTemplate + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.resource_element_type: str = "ArmResourceDefinition" + self.configuration = configuration + + +class ArmTemplateArtifactProfile(_serialization.Model): + """Template artifact profile. + + :ivar template_name: Template name. + :vartype template_name: str + :ivar template_version: Template version. + :vartype template_version: str + """ + + _attribute_map = { + "template_name": {"key": "templateName", "type": "str"}, + "template_version": {"key": "templateVersion", "type": "str"}, + } + + def __init__( + self, *, template_name: Optional[str] = None, template_version: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword template_name: Template name. + :paramtype template_name: str + :keyword template_version: Template version. + :paramtype template_version: str + """ + super().__init__(**kwargs) + self.template_name = template_name + self.template_version = template_version + + +class ArmTemplateMappingRuleProfile(_serialization.Model): + """Template mapping rule profile. + + :ivar template_parameters: List of template parameters. + :vartype template_parameters: str + """ + + _attribute_map = { + "template_parameters": {"key": "templateParameters", "type": "str"}, + } + + def __init__(self, *, template_parameters: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword template_parameters: List of template parameters. + :paramtype template_parameters: str + """ + super().__init__(**kwargs) + self.template_parameters = template_parameters + + +class ArtifactAccessCredential(_serialization.Model): + """The artifact manifest credential definition. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureContainerRegistryScopedTokenCredential, AzureStorageAccountCredential + + All required parameters must be populated in order to send to Azure. + + :ivar credential_type: The credential type. Required. Known values are: "Unknown", + "AzureContainerRegistryScopedToken", and "AzureStorageAccountToken". + :vartype credential_type: str or ~Microsoft.HybridNetwork.models.CredentialType + """ + + _validation = { + "credential_type": {"required": True}, + } + + _attribute_map = { + "credential_type": {"key": "credentialType", "type": "str"}, + } + + _subtype_map = { + "credential_type": { + "AzureContainerRegistryScopedToken": "AzureContainerRegistryScopedTokenCredential", + "AzureStorageAccountToken": "AzureStorageAccountCredential", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.credential_type: Optional[str] = None + + +class ArtifactChangeState(_serialization.Model): + """The artifact updating request payload. + + :ivar properties: Artifact update state properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ArtifactChangeStateProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "ArtifactChangeStateProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ArtifactChangeStateProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Artifact update state properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ArtifactChangeStateProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ArtifactChangeStateProperties(_serialization.Model): + """The artifact update state properties. + + :ivar artifact_state: The artifact state. Known values are: "Unknown", "Preview", "Active", and + "Deprecated". + :vartype artifact_state: str or ~Microsoft.HybridNetwork.models.ArtifactState + """ + + _attribute_map = { + "artifact_state": {"key": "artifactState", "type": "str"}, + } + + def __init__(self, *, artifact_state: Optional[Union[str, "_models.ArtifactState"]] = None, **kwargs: Any) -> None: + """ + :keyword artifact_state: The artifact state. Known values are: "Unknown", "Preview", "Active", + and "Deprecated". + :paramtype artifact_state: str or ~Microsoft.HybridNetwork.models.ArtifactState + """ + super().__init__(**kwargs) + self.artifact_state = artifact_state + + +class Resource(_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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class ArtifactManifest(TrackedResource): + """Artifact manifest properties. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Artifact manifest properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ArtifactManifestPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "ArtifactManifestPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ArtifactManifestPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Artifact manifest properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ArtifactManifestPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class ArtifactManifestListResult(_serialization.Model): + """A list of artifact manifests. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of artifact manifests. + :vartype value: list[~Microsoft.HybridNetwork.models.ArtifactManifest] + :ivar next_link: The URI to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ArtifactManifest]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ArtifactManifest"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of artifact manifests. + :paramtype value: list[~Microsoft.HybridNetwork.models.ArtifactManifest] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ArtifactManifestPropertiesFormat(_serialization.Model): + """Artifact manifest properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the ArtifactManifest resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar artifact_manifest_state: The artifact manifest state. Known values are: "Unknown", + "Uploading", "Uploaded", "Validating", "ValidationFailed", and "Succeeded". + :vartype artifact_manifest_state: str or ~Microsoft.HybridNetwork.models.ArtifactManifestState + :ivar artifacts: The artifacts list. + :vartype artifacts: list[~Microsoft.HybridNetwork.models.ManifestArtifactFormat] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "artifact_manifest_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "artifact_manifest_state": {"key": "artifactManifestState", "type": "str"}, + "artifacts": {"key": "artifacts", "type": "[ManifestArtifactFormat]"}, + } + + def __init__(self, *, artifacts: Optional[List["_models.ManifestArtifactFormat"]] = None, **kwargs: Any) -> None: + """ + :keyword artifacts: The artifacts list. + :paramtype artifacts: list[~Microsoft.HybridNetwork.models.ManifestArtifactFormat] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.artifact_manifest_state = None + self.artifacts = artifacts + + +class ArtifactManifestUpdateState(_serialization.Model): + """The artifact manifest updating request payload. Only the 'Uploaded' state is allowed for + updates. Other states are used for internal state transitioning. + + :ivar artifact_manifest_state: The artifact manifest state. Known values are: "Unknown", + "Uploading", "Uploaded", "Validating", "ValidationFailed", and "Succeeded". + :vartype artifact_manifest_state: str or ~Microsoft.HybridNetwork.models.ArtifactManifestState + """ + + _attribute_map = { + "artifact_manifest_state": {"key": "artifactManifestState", "type": "str"}, + } + + def __init__( + self, *, artifact_manifest_state: Optional[Union[str, "_models.ArtifactManifestState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword artifact_manifest_state: The artifact manifest state. Known values are: "Unknown", + "Uploading", "Uploaded", "Validating", "ValidationFailed", and "Succeeded". + :paramtype artifact_manifest_state: str or + ~Microsoft.HybridNetwork.models.ArtifactManifestState + """ + super().__init__(**kwargs) + self.artifact_manifest_state = artifact_manifest_state + + +class ArtifactProfile(_serialization.Model): + """Artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + } + + def __init__(self, *, artifact_store: Optional["_models.ReferencedResource"] = None, **kwargs: Any) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + super().__init__(**kwargs) + self.artifact_store = artifact_store + + +class ArtifactStore(TrackedResource): + """Artifact store properties. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: ArtifactStores properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ArtifactStorePropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "ArtifactStorePropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ArtifactStorePropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: ArtifactStores properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ArtifactStorePropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class ArtifactStoreListResult(_serialization.Model): + """A list of artifact stores. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of artifact stores. + :vartype value: list[~Microsoft.HybridNetwork.models.ArtifactStore] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ArtifactStore]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ArtifactStore"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of artifact stores. + :paramtype value: list[~Microsoft.HybridNetwork.models.ArtifactStore] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ArtifactStorePropertiesFormat(_serialization.Model): + """Artifact store properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the application groups resource. Known + values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", + and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar store_type: The artifact store type. Known values are: "Unknown", + "AzureContainerRegistry", and "AzureStorageAccount". + :vartype store_type: str or ~Microsoft.HybridNetwork.models.ArtifactStoreType + :ivar replication_strategy: The replication strategy. Known values are: "Unknown" and + "SingleReplication". + :vartype replication_strategy: str or + ~Microsoft.HybridNetwork.models.ArtifactReplicationStrategy + :ivar managed_resource_group_configuration: + :vartype managed_resource_group_configuration: + ~Microsoft.HybridNetwork.models.ArtifactStorePropertiesFormatManagedResourceGroupConfiguration + :ivar storage_resource_id: The created storage resource id. + :vartype storage_resource_id: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "storage_resource_id": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "store_type": {"key": "storeType", "type": "str"}, + "replication_strategy": {"key": "replicationStrategy", "type": "str"}, + "managed_resource_group_configuration": { + "key": "managedResourceGroupConfiguration", + "type": "ArtifactStorePropertiesFormatManagedResourceGroupConfiguration", + }, + "storage_resource_id": {"key": "storageResourceId", "type": "str"}, + } + + def __init__( + self, + *, + store_type: Optional[Union[str, "_models.ArtifactStoreType"]] = None, + replication_strategy: Optional[Union[str, "_models.ArtifactReplicationStrategy"]] = None, + managed_resource_group_configuration: Optional[ + "_models.ArtifactStorePropertiesFormatManagedResourceGroupConfiguration" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword store_type: The artifact store type. Known values are: "Unknown", + "AzureContainerRegistry", and "AzureStorageAccount". + :paramtype store_type: str or ~Microsoft.HybridNetwork.models.ArtifactStoreType + :keyword replication_strategy: The replication strategy. Known values are: "Unknown" and + "SingleReplication". + :paramtype replication_strategy: str or + ~Microsoft.HybridNetwork.models.ArtifactReplicationStrategy + :keyword managed_resource_group_configuration: + :paramtype managed_resource_group_configuration: + ~Microsoft.HybridNetwork.models.ArtifactStorePropertiesFormatManagedResourceGroupConfiguration + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.store_type = store_type + self.replication_strategy = replication_strategy + self.managed_resource_group_configuration = managed_resource_group_configuration + self.storage_resource_id = None + + +class ArtifactStorePropertiesFormatManagedResourceGroupConfiguration(_serialization.Model): + """ArtifactStorePropertiesFormatManagedResourceGroupConfiguration. + + :ivar name: The managed resource group name. + :vartype name: str + :ivar location: The managed resource group location. + :vartype location: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: The managed resource group name. + :paramtype name: str + :keyword location: The managed resource group location. + :paramtype location: str + """ + super().__init__(**kwargs) + self.name = name + self.location = location + + +class NFVIs(_serialization.Model): + """The NFVI object. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureArcK8SClusterNFVIDetails, AzureCoreNFVIDetails, AzureOperatorNexusClusterNFVIDetails + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the nfvi. + :vartype name: str + :ivar nfvi_type: The NFVI type. Required. Known values are: "Unknown", "AzureArcKubernetes", + "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "nfvi_type": {"key": "nfviType", "type": "str"}, + } + + _subtype_map = { + "nfvi_type": { + "AzureArcKubernetes": "AzureArcK8SClusterNFVIDetails", + "AzureCore": "AzureCoreNFVIDetails", + "AzureOperatorNexus": "AzureOperatorNexusClusterNFVIDetails", + } + } + + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the nfvi. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.nfvi_type: Optional[str] = None + + +class AzureArcK8SClusterNFVIDetails(NFVIs): + """The AzureArcK8sCluster NFVI detail. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the nfvi. + :vartype name: str + :ivar nfvi_type: The NFVI type. Required. Known values are: "Unknown", "AzureArcKubernetes", + "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar custom_location_reference: The reference to the custom location. + :vartype custom_location_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "custom_location_reference": {"key": "customLocationReference", "type": "ReferencedResource"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + custom_location_reference: Optional["_models.ReferencedResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the nfvi. + :paramtype name: str + :keyword custom_location_reference: The reference to the custom location. + :paramtype custom_location_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + super().__init__(name=name, **kwargs) + self.nfvi_type: str = "AzureArcKubernetes" + self.custom_location_reference = custom_location_reference + + +class AzureArcKubernetesArtifactProfile(ArtifactProfile): + """Azure arc kubernetes artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar helm_artifact_profile: Helm artifact profile. + :vartype helm_artifact_profile: ~Microsoft.HybridNetwork.models.HelmArtifactProfile + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + "helm_artifact_profile": {"key": "helmArtifactProfile", "type": "HelmArtifactProfile"}, + } + + def __init__( + self, + *, + artifact_store: Optional["_models.ReferencedResource"] = None, + helm_artifact_profile: Optional["_models.HelmArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword helm_artifact_profile: Helm artifact profile. + :paramtype helm_artifact_profile: ~Microsoft.HybridNetwork.models.HelmArtifactProfile + """ + super().__init__(artifact_store=artifact_store, **kwargs) + self.helm_artifact_profile = helm_artifact_profile + + +class MappingRuleProfile(_serialization.Model): + """Mapping rule profile properties. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + } + + def __init__( + self, *, application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + """ + super().__init__(**kwargs) + self.application_enablement = application_enablement + + +class AzureArcKubernetesDeployMappingRuleProfile(MappingRuleProfile): + """Azure arc kubernetes deploy mapping rule profile. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :ivar helm_mapping_rule_profile: The helm mapping rule profile. + :vartype helm_mapping_rule_profile: ~Microsoft.HybridNetwork.models.HelmMappingRuleProfile + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + "helm_mapping_rule_profile": {"key": "helmMappingRuleProfile", "type": "HelmMappingRuleProfile"}, + } + + def __init__( + self, + *, + application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, + helm_mapping_rule_profile: Optional["_models.HelmMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :keyword helm_mapping_rule_profile: The helm mapping rule profile. + :paramtype helm_mapping_rule_profile: ~Microsoft.HybridNetwork.models.HelmMappingRuleProfile + """ + super().__init__(application_enablement=application_enablement, **kwargs) + self.helm_mapping_rule_profile = helm_mapping_rule_profile + + +class NetworkFunctionApplication(_serialization.Model): + """Network function application definition. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + super().__init__(**kwargs) + self.name = name + self.depends_on_profile = depends_on_profile + + +class AzureArcKubernetesNetworkFunctionApplication(NetworkFunctionApplication): + """Azure arc kubernetes network function application definition. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureArcKubernetesHelmApplication + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown" and + "HelmPackage". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureArcKubernetesArtifactType + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + } + + _subtype_map = {"artifact_type": {"HelmPackage": "AzureArcKubernetesHelmApplication"}} + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: Optional[str] = None + + +class AzureArcKubernetesHelmApplication(AzureArcKubernetesNetworkFunctionApplication): + """Azure arc kubernetes helm application configurations. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown" and + "HelmPackage". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureArcKubernetesArtifactType + :ivar artifact_profile: Azure arc kubernetes artifact profile. + :vartype artifact_profile: ~Microsoft.HybridNetwork.models.AzureArcKubernetesArtifactProfile + :ivar deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :vartype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureArcKubernetesDeployMappingRuleProfile + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "AzureArcKubernetesArtifactProfile"}, + "deploy_parameters_mapping_rule_profile": { + "key": "deployParametersMappingRuleProfile", + "type": "AzureArcKubernetesDeployMappingRuleProfile", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + artifact_profile: Optional["_models.AzureArcKubernetesArtifactProfile"] = None, + deploy_parameters_mapping_rule_profile: Optional["_models.AzureArcKubernetesDeployMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword artifact_profile: Azure arc kubernetes artifact profile. + :paramtype artifact_profile: ~Microsoft.HybridNetwork.models.AzureArcKubernetesArtifactProfile + :keyword deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :paramtype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureArcKubernetesDeployMappingRuleProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: str = "HelmPackage" + self.artifact_profile = artifact_profile + self.deploy_parameters_mapping_rule_profile = deploy_parameters_mapping_rule_profile + + +class ContainerizedNetworkFunctionTemplate(_serialization.Model): + """Containerized network function template. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureArcKubernetesNetworkFunctionTemplate + + All required parameters must be populated in order to send to Azure. + + :ivar nfvi_type: The network function type. Required. Known values are: "Unknown" and + "AzureArcKubernetes". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.ContainerizedNetworkFunctionNFVIType + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "nfvi_type": {"key": "nfviType", "type": "str"}, + } + + _subtype_map = {"nfvi_type": {"AzureArcKubernetes": "AzureArcKubernetesNetworkFunctionTemplate"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.nfvi_type: Optional[str] = None + + +class AzureArcKubernetesNetworkFunctionTemplate(ContainerizedNetworkFunctionTemplate): + """Azure Arc kubernetes network function template. + + All required parameters must be populated in order to send to Azure. + + :ivar nfvi_type: The network function type. Required. Known values are: "Unknown" and + "AzureArcKubernetes". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.ContainerizedNetworkFunctionNFVIType + :ivar network_function_applications: Network function applications. + :vartype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureArcKubernetesNetworkFunctionApplication] + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "nfvi_type": {"key": "nfviType", "type": "str"}, + "network_function_applications": { + "key": "networkFunctionApplications", + "type": "[AzureArcKubernetesNetworkFunctionApplication]", + }, + } + + def __init__( + self, + *, + network_function_applications: Optional[List["_models.AzureArcKubernetesNetworkFunctionApplication"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_applications: Network function applications. + :paramtype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureArcKubernetesNetworkFunctionApplication] + """ + super().__init__(**kwargs) + self.nfvi_type: str = "AzureArcKubernetes" + self.network_function_applications = network_function_applications + + +class AzureContainerRegistryScopedTokenCredential(ArtifactAccessCredential): + """The azure container registry scoped token credential definition. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_type: The credential type. Required. Known values are: "Unknown", + "AzureContainerRegistryScopedToken", and "AzureStorageAccountToken". + :vartype credential_type: str or ~Microsoft.HybridNetwork.models.CredentialType + :ivar username: The username of the credential. + :vartype username: str + :ivar acr_token: The credential value. + :vartype acr_token: str + :ivar acr_server_url: The Acr server url. + :vartype acr_server_url: str + :ivar repositories: The repositories that could be accessed using the current credential. + :vartype repositories: list[str] + :ivar expiry: The UTC time when credential will expire. + :vartype expiry: ~datetime.datetime + """ + + _validation = { + "credential_type": {"required": True}, + } + + _attribute_map = { + "credential_type": {"key": "credentialType", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "acr_token": {"key": "acrToken", "type": "str"}, + "acr_server_url": {"key": "acrServerUrl", "type": "str"}, + "repositories": {"key": "repositories", "type": "[str]"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + } + + def __init__( + self, + *, + username: Optional[str] = None, + acr_token: Optional[str] = None, + acr_server_url: Optional[str] = None, + repositories: Optional[List[str]] = None, + expiry: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword username: The username of the credential. + :paramtype username: str + :keyword acr_token: The credential value. + :paramtype acr_token: str + :keyword acr_server_url: The Acr server url. + :paramtype acr_server_url: str + :keyword repositories: The repositories that could be accessed using the current credential. + :paramtype repositories: list[str] + :keyword expiry: The UTC time when credential will expire. + :paramtype expiry: ~datetime.datetime + """ + super().__init__(**kwargs) + self.credential_type: str = "AzureContainerRegistryScopedToken" + self.username = username + self.acr_token = acr_token + self.acr_server_url = acr_server_url + self.repositories = repositories + self.expiry = expiry + + +class AzureCoreArmTemplateArtifactProfile(ArtifactProfile): + """Azure template artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar template_artifact_profile: Template artifact profile. + :vartype template_artifact_profile: ~Microsoft.HybridNetwork.models.ArmTemplateArtifactProfile + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + "template_artifact_profile": {"key": "templateArtifactProfile", "type": "ArmTemplateArtifactProfile"}, + } + + def __init__( + self, + *, + artifact_store: Optional["_models.ReferencedResource"] = None, + template_artifact_profile: Optional["_models.ArmTemplateArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword template_artifact_profile: Template artifact profile. + :paramtype template_artifact_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateArtifactProfile + """ + super().__init__(artifact_store=artifact_store, **kwargs) + self.template_artifact_profile = template_artifact_profile + + +class AzureCoreArmTemplateDeployMappingRuleProfile(MappingRuleProfile): + """Azure template deploy mapping rule profile. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :ivar template_mapping_rule_profile: The template mapping rule profile. + :vartype template_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateMappingRuleProfile + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + "template_mapping_rule_profile": {"key": "templateMappingRuleProfile", "type": "ArmTemplateMappingRuleProfile"}, + } + + def __init__( + self, + *, + application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, + template_mapping_rule_profile: Optional["_models.ArmTemplateMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :keyword template_mapping_rule_profile: The template mapping rule profile. + :paramtype template_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateMappingRuleProfile + """ + super().__init__(application_enablement=application_enablement, **kwargs) + self.template_mapping_rule_profile = template_mapping_rule_profile + + +class AzureCoreNetworkFunctionApplication(NetworkFunctionApplication): + """Azure virtual network function application definition. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureCoreNetworkFunctionArmTemplateApplication, AzureCoreNetworkFunctionVhdApplication + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "VhdImageFile", + and "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureCoreArtifactType + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + } + + _subtype_map = { + "artifact_type": { + "ArmTemplate": "AzureCoreNetworkFunctionArmTemplateApplication", + "VhdImageFile": "AzureCoreNetworkFunctionVhdApplication", + } + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: Optional[str] = None + + +class AzureCoreNetworkFunctionArmTemplateApplication(AzureCoreNetworkFunctionApplication): + """Azure core network function Template application definition. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "VhdImageFile", + and "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureCoreArtifactType + :ivar artifact_profile: Azure template artifact profile. + :vartype artifact_profile: ~Microsoft.HybridNetwork.models.AzureCoreArmTemplateArtifactProfile + :ivar deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :vartype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureCoreArmTemplateDeployMappingRuleProfile + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "AzureCoreArmTemplateArtifactProfile"}, + "deploy_parameters_mapping_rule_profile": { + "key": "deployParametersMappingRuleProfile", + "type": "AzureCoreArmTemplateDeployMappingRuleProfile", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + artifact_profile: Optional["_models.AzureCoreArmTemplateArtifactProfile"] = None, + deploy_parameters_mapping_rule_profile: Optional["_models.AzureCoreArmTemplateDeployMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword artifact_profile: Azure template artifact profile. + :paramtype artifact_profile: + ~Microsoft.HybridNetwork.models.AzureCoreArmTemplateArtifactProfile + :keyword deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :paramtype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureCoreArmTemplateDeployMappingRuleProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: str = "ArmTemplate" + self.artifact_profile = artifact_profile + self.deploy_parameters_mapping_rule_profile = deploy_parameters_mapping_rule_profile + + +class VirtualNetworkFunctionTemplate(_serialization.Model): + """Virtual network function template. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureCoreNetworkFunctionTemplate, AzureOperatorNexusNetworkFunctionTemplate + + All required parameters must be populated in order to send to Azure. + + :ivar nfvi_type: The network function type. Required. Known values are: "Unknown", "AzureCore", + and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.VirtualNetworkFunctionNFVIType + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "nfvi_type": {"key": "nfviType", "type": "str"}, + } + + _subtype_map = { + "nfvi_type": { + "AzureCore": "AzureCoreNetworkFunctionTemplate", + "AzureOperatorNexus": "AzureOperatorNexusNetworkFunctionTemplate", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.nfvi_type: Optional[str] = None + + +class AzureCoreNetworkFunctionTemplate(VirtualNetworkFunctionTemplate): + """Azure virtual network function template. + + All required parameters must be populated in order to send to Azure. + + :ivar nfvi_type: The network function type. Required. Known values are: "Unknown", "AzureCore", + and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.VirtualNetworkFunctionNFVIType + :ivar network_function_applications: Network function applications. + :vartype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureCoreNetworkFunctionApplication] + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "nfvi_type": {"key": "nfviType", "type": "str"}, + "network_function_applications": { + "key": "networkFunctionApplications", + "type": "[AzureCoreNetworkFunctionApplication]", + }, + } + + def __init__( + self, + *, + network_function_applications: Optional[List["_models.AzureCoreNetworkFunctionApplication"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_applications: Network function applications. + :paramtype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureCoreNetworkFunctionApplication] + """ + super().__init__(**kwargs) + self.nfvi_type: str = "AzureCore" + self.network_function_applications = network_function_applications + + +class AzureCoreNetworkFunctionVhdApplication(AzureCoreNetworkFunctionApplication): + """Azure core network function vhd application definition. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "VhdImageFile", + and "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureCoreArtifactType + :ivar artifact_profile: Azure vhd image artifact profile. + :vartype artifact_profile: ~Microsoft.HybridNetwork.models.AzureCoreVhdImageArtifactProfile + :ivar deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :vartype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureCoreVhdImageDeployMappingRuleProfile + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "AzureCoreVhdImageArtifactProfile"}, + "deploy_parameters_mapping_rule_profile": { + "key": "deployParametersMappingRuleProfile", + "type": "AzureCoreVhdImageDeployMappingRuleProfile", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + artifact_profile: Optional["_models.AzureCoreVhdImageArtifactProfile"] = None, + deploy_parameters_mapping_rule_profile: Optional["_models.AzureCoreVhdImageDeployMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword artifact_profile: Azure vhd image artifact profile. + :paramtype artifact_profile: ~Microsoft.HybridNetwork.models.AzureCoreVhdImageArtifactProfile + :keyword deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :paramtype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureCoreVhdImageDeployMappingRuleProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: str = "VhdImageFile" + self.artifact_profile = artifact_profile + self.deploy_parameters_mapping_rule_profile = deploy_parameters_mapping_rule_profile + + +class AzureCoreNFVIDetails(NFVIs): + """The Azure Core NFVI detail. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the nfvi. + :vartype name: str + :ivar nfvi_type: The NFVI type. Required. Known values are: "Unknown", "AzureArcKubernetes", + "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar location: Location of the Azure core. + :vartype location: str + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the nfvi. + :paramtype name: str + :keyword location: Location of the Azure core. + :paramtype location: str + """ + super().__init__(name=name, **kwargs) + self.nfvi_type: str = "AzureCore" + self.location = location + + +class AzureCoreVhdImageArtifactProfile(ArtifactProfile): + """Azure vhd artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar vhd_artifact_profile: Vhd artifact profile. + :vartype vhd_artifact_profile: ~Microsoft.HybridNetwork.models.VhdImageArtifactProfile + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + "vhd_artifact_profile": {"key": "vhdArtifactProfile", "type": "VhdImageArtifactProfile"}, + } + + def __init__( + self, + *, + artifact_store: Optional["_models.ReferencedResource"] = None, + vhd_artifact_profile: Optional["_models.VhdImageArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword vhd_artifact_profile: Vhd artifact profile. + :paramtype vhd_artifact_profile: ~Microsoft.HybridNetwork.models.VhdImageArtifactProfile + """ + super().__init__(artifact_store=artifact_store, **kwargs) + self.vhd_artifact_profile = vhd_artifact_profile + + +class AzureCoreVhdImageDeployMappingRuleProfile(MappingRuleProfile): + """Azure vhd deploy mapping rule profile. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :ivar vhd_image_mapping_rule_profile: The vhd mapping rule profile. + :vartype vhd_image_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.VhdImageMappingRuleProfile + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + "vhd_image_mapping_rule_profile": {"key": "vhdImageMappingRuleProfile", "type": "VhdImageMappingRuleProfile"}, + } + + def __init__( + self, + *, + application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, + vhd_image_mapping_rule_profile: Optional["_models.VhdImageMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :keyword vhd_image_mapping_rule_profile: The vhd mapping rule profile. + :paramtype vhd_image_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.VhdImageMappingRuleProfile + """ + super().__init__(application_enablement=application_enablement, **kwargs) + self.vhd_image_mapping_rule_profile = vhd_image_mapping_rule_profile + + +class AzureOperatorNexusArmTemplateArtifactProfile(ArtifactProfile): + """Azure Operator Distributed Services vhd artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar template_artifact_profile: Template artifact profile. + :vartype template_artifact_profile: ~Microsoft.HybridNetwork.models.ArmTemplateArtifactProfile + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + "template_artifact_profile": {"key": "templateArtifactProfile", "type": "ArmTemplateArtifactProfile"}, + } + + def __init__( + self, + *, + artifact_store: Optional["_models.ReferencedResource"] = None, + template_artifact_profile: Optional["_models.ArmTemplateArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword template_artifact_profile: Template artifact profile. + :paramtype template_artifact_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateArtifactProfile + """ + super().__init__(artifact_store=artifact_store, **kwargs) + self.template_artifact_profile = template_artifact_profile + + +class AzureOperatorNexusArmTemplateDeployMappingRuleProfile(MappingRuleProfile): + """Azure Operator Distributed Services template deploy mapping rule profile. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :ivar template_mapping_rule_profile: The template mapping rule profile. + :vartype template_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateMappingRuleProfile + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + "template_mapping_rule_profile": {"key": "templateMappingRuleProfile", "type": "ArmTemplateMappingRuleProfile"}, + } + + def __init__( + self, + *, + application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, + template_mapping_rule_profile: Optional["_models.ArmTemplateMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :keyword template_mapping_rule_profile: The template mapping rule profile. + :paramtype template_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.ArmTemplateMappingRuleProfile + """ + super().__init__(application_enablement=application_enablement, **kwargs) + self.template_mapping_rule_profile = template_mapping_rule_profile + + +class AzureOperatorNexusClusterNFVIDetails(NFVIs): + """The AzureOperatorNexusCluster NFVI detail. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the nfvi. + :vartype name: str + :ivar nfvi_type: The NFVI type. Required. Known values are: "Unknown", "AzureArcKubernetes", + "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar custom_location_reference: The reference to the custom location. + :vartype custom_location_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "custom_location_reference": {"key": "customLocationReference", "type": "ReferencedResource"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + custom_location_reference: Optional["_models.ReferencedResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the nfvi. + :paramtype name: str + :keyword custom_location_reference: The reference to the custom location. + :paramtype custom_location_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + """ + super().__init__(name=name, **kwargs) + self.nfvi_type: str = "AzureOperatorNexus" + self.custom_location_reference = custom_location_reference + + +class AzureOperatorNexusImageArtifactProfile(ArtifactProfile): + """Azure Operator Distributed Services image artifact profile properties. + + :ivar artifact_store: The reference to artifact store. + :vartype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar image_artifact_profile: Image artifact profile. + :vartype image_artifact_profile: ~Microsoft.HybridNetwork.models.ImageArtifactProfile + """ + + _attribute_map = { + "artifact_store": {"key": "artifactStore", "type": "ReferencedResource"}, + "image_artifact_profile": {"key": "imageArtifactProfile", "type": "ImageArtifactProfile"}, + } + + def __init__( + self, + *, + artifact_store: Optional["_models.ReferencedResource"] = None, + image_artifact_profile: Optional["_models.ImageArtifactProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store: The reference to artifact store. + :paramtype artifact_store: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword image_artifact_profile: Image artifact profile. + :paramtype image_artifact_profile: ~Microsoft.HybridNetwork.models.ImageArtifactProfile + """ + super().__init__(artifact_store=artifact_store, **kwargs) + self.image_artifact_profile = image_artifact_profile + + +class AzureOperatorNexusImageDeployMappingRuleProfile(MappingRuleProfile): + """Azure Operator Distributed Services image deploy mapping rule profile. + + :ivar application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :vartype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :ivar image_mapping_rule_profile: The vhd mapping rule profile. + :vartype image_mapping_rule_profile: ~Microsoft.HybridNetwork.models.ImageMappingRuleProfile + """ + + _attribute_map = { + "application_enablement": {"key": "applicationEnablement", "type": "str"}, + "image_mapping_rule_profile": {"key": "imageMappingRuleProfile", "type": "ImageMappingRuleProfile"}, + } + + def __init__( + self, + *, + application_enablement: Optional[Union[str, "_models.ApplicationEnablement"]] = None, + image_mapping_rule_profile: Optional["_models.ImageMappingRuleProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword application_enablement: The application enablement. Known values are: "Unknown", + "Enabled", and "Disabled". + :paramtype application_enablement: str or ~Microsoft.HybridNetwork.models.ApplicationEnablement + :keyword image_mapping_rule_profile: The vhd mapping rule profile. + :paramtype image_mapping_rule_profile: ~Microsoft.HybridNetwork.models.ImageMappingRuleProfile + """ + super().__init__(application_enablement=application_enablement, **kwargs) + self.image_mapping_rule_profile = image_mapping_rule_profile + + +class AzureOperatorNexusNetworkFunctionApplication(NetworkFunctionApplication): + """Azure Operator Distributed Services network function application definition. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureOperatorNexusNetworkFunctionArmTemplateApplication, + AzureOperatorNexusNetworkFunctionImageApplication + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "ImageFile", and + "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureOperatorNexusArtifactType + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + } + + _subtype_map = { + "artifact_type": { + "ArmTemplate": "AzureOperatorNexusNetworkFunctionArmTemplateApplication", + "ImageFile": "AzureOperatorNexusNetworkFunctionImageApplication", + } + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: Optional[str] = None + + +class AzureOperatorNexusNetworkFunctionArmTemplateApplication(AzureOperatorNexusNetworkFunctionApplication): + """Azure Operator Distributed Services network function Template application definition. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "ImageFile", and + "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureOperatorNexusArtifactType + :ivar artifact_profile: Azure Operator Distributed Services Template artifact profile. + :vartype artifact_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusArmTemplateArtifactProfile + :ivar deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :vartype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusArmTemplateDeployMappingRuleProfile + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "AzureOperatorNexusArmTemplateArtifactProfile"}, + "deploy_parameters_mapping_rule_profile": { + "key": "deployParametersMappingRuleProfile", + "type": "AzureOperatorNexusArmTemplateDeployMappingRuleProfile", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + artifact_profile: Optional["_models.AzureOperatorNexusArmTemplateArtifactProfile"] = None, + deploy_parameters_mapping_rule_profile: Optional[ + "_models.AzureOperatorNexusArmTemplateDeployMappingRuleProfile" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword artifact_profile: Azure Operator Distributed Services Template artifact profile. + :paramtype artifact_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusArmTemplateArtifactProfile + :keyword deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :paramtype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusArmTemplateDeployMappingRuleProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: str = "ArmTemplate" + self.artifact_profile = artifact_profile + self.deploy_parameters_mapping_rule_profile = deploy_parameters_mapping_rule_profile + + +class AzureOperatorNexusNetworkFunctionImageApplication(AzureOperatorNexusNetworkFunctionApplication): + """Azure Operator Distributed Services network function image application definition. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the network function application. + :vartype name: str + :ivar depends_on_profile: Depends on profile definition. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar artifact_type: The artifact type. Required. Known values are: "Unknown", "ImageFile", and + "ArmTemplate". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.AzureOperatorNexusArtifactType + :ivar artifact_profile: Azure Operator Distributed Services image artifact profile. + :vartype artifact_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusImageArtifactProfile + :ivar deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :vartype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusImageDeployMappingRuleProfile + """ + + _validation = { + "artifact_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_profile": {"key": "artifactProfile", "type": "AzureOperatorNexusImageArtifactProfile"}, + "deploy_parameters_mapping_rule_profile": { + "key": "deployParametersMappingRuleProfile", + "type": "AzureOperatorNexusImageDeployMappingRuleProfile", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + artifact_profile: Optional["_models.AzureOperatorNexusImageArtifactProfile"] = None, + deploy_parameters_mapping_rule_profile: Optional[ + "_models.AzureOperatorNexusImageDeployMappingRuleProfile" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the network function application. + :paramtype name: str + :keyword depends_on_profile: Depends on profile definition. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword artifact_profile: Azure Operator Distributed Services image artifact profile. + :paramtype artifact_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusImageArtifactProfile + :keyword deploy_parameters_mapping_rule_profile: Deploy mapping rule profile. + :paramtype deploy_parameters_mapping_rule_profile: + ~Microsoft.HybridNetwork.models.AzureOperatorNexusImageDeployMappingRuleProfile + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.artifact_type: str = "ImageFile" + self.artifact_profile = artifact_profile + self.deploy_parameters_mapping_rule_profile = deploy_parameters_mapping_rule_profile + + +class AzureOperatorNexusNetworkFunctionTemplate(VirtualNetworkFunctionTemplate): + """Azure Operator Distributed Services network function template. + + All required parameters must be populated in order to send to Azure. + + :ivar nfvi_type: The network function type. Required. Known values are: "Unknown", "AzureCore", + and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.VirtualNetworkFunctionNFVIType + :ivar network_function_applications: Network function applications. + :vartype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureOperatorNexusNetworkFunctionApplication] + """ + + _validation = { + "nfvi_type": {"required": True}, + } + + _attribute_map = { + "nfvi_type": {"key": "nfviType", "type": "str"}, + "network_function_applications": { + "key": "networkFunctionApplications", + "type": "[AzureOperatorNexusNetworkFunctionApplication]", + }, + } + + def __init__( + self, + *, + network_function_applications: Optional[List["_models.AzureOperatorNexusNetworkFunctionApplication"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_applications: Network function applications. + :paramtype network_function_applications: + list[~Microsoft.HybridNetwork.models.AzureOperatorNexusNetworkFunctionApplication] + """ + super().__init__(**kwargs) + self.nfvi_type: str = "AzureOperatorNexus" + self.network_function_applications = network_function_applications + + +class AzureStorageAccountContainerCredential(_serialization.Model): + """The azure storage account container credential definition. + + :ivar container_name: The storage account container name. + :vartype container_name: str + :ivar container_sas_uri: The storage account container sas uri. + :vartype container_sas_uri: str + """ + + _attribute_map = { + "container_name": {"key": "containerName", "type": "str"}, + "container_sas_uri": {"key": "containerSasUri", "type": "str"}, + } + + def __init__( + self, *, container_name: Optional[str] = None, container_sas_uri: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword container_name: The storage account container name. + :paramtype container_name: str + :keyword container_sas_uri: The storage account container sas uri. + :paramtype container_sas_uri: str + """ + super().__init__(**kwargs) + self.container_name = container_name + self.container_sas_uri = container_sas_uri + + +class AzureStorageAccountCredential(ArtifactAccessCredential): + """The azure storage account credential definition. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_type: The credential type. Required. Known values are: "Unknown", + "AzureContainerRegistryScopedToken", and "AzureStorageAccountToken". + :vartype credential_type: str or ~Microsoft.HybridNetwork.models.CredentialType + :ivar storage_account_id: The storage account Id. + :vartype storage_account_id: str + :ivar container_credentials: The containers that could be accessed using the current + credential. + :vartype container_credentials: + list[~Microsoft.HybridNetwork.models.AzureStorageAccountContainerCredential] + :ivar expiry: The UTC time when credential will expire. + :vartype expiry: ~datetime.datetime + """ + + _validation = { + "credential_type": {"required": True}, + } + + _attribute_map = { + "credential_type": {"key": "credentialType", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + "container_credentials": {"key": "containerCredentials", "type": "[AzureStorageAccountContainerCredential]"}, + "expiry": {"key": "expiry", "type": "iso-8601"}, + } + + def __init__( + self, + *, + storage_account_id: Optional[str] = None, + container_credentials: Optional[List["_models.AzureStorageAccountContainerCredential"]] = None, + expiry: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_account_id: The storage account Id. + :paramtype storage_account_id: str + :keyword container_credentials: The containers that could be accessed using the current + credential. + :paramtype container_credentials: + list[~Microsoft.HybridNetwork.models.AzureStorageAccountContainerCredential] + :keyword expiry: The UTC time when credential will expire. + :paramtype expiry: ~datetime.datetime + """ + super().__init__(**kwargs) + self.credential_type: str = "AzureStorageAccountToken" + self.storage_account_id = storage_account_id + self.container_credentials = container_credentials + self.expiry = expiry + + +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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + """ + + +class Component(ProxyResource): + """The component sub resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar properties: The component properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ComponentProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ComponentProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ComponentProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The component properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ComponentProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ComponentListResult(_serialization.Model): + """Response for list component API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of component resources in a networkFunction. + :vartype value: list[~Microsoft.HybridNetwork.models.Component] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Component]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Component"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of component resources in a networkFunction. + :paramtype value: list[~Microsoft.HybridNetwork.models.Component] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ComponentProperties(_serialization.Model): + """The component properties of the network function. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the component resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar deployment_profile: The JSON-serialized deployment profile of the component resource. + :vartype deployment_profile: str + :ivar deployment_status: The deployment status of the component resource. + :vartype deployment_status: ~Microsoft.HybridNetwork.models.DeploymentStatusProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "deployment_profile": {"readonly": True}, + "deployment_status": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "deployment_profile": {"key": "deploymentProfile", "type": "str"}, + "deployment_status": {"key": "deploymentStatus", "type": "DeploymentStatusProperties"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.deployment_profile = None + self.deployment_status = None + + +class ConfigurationGroupSchema(TrackedResource): + """Configuration group schema resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Configuration group schema properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigurationGroupSchemaPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ConfigurationGroupSchemaPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Configuration group schema properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class ConfigurationGroupSchemaListResult(_serialization.Model): + """A list of configuration group schema resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of configuration group schema. + :vartype value: list[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationGroupSchema]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ConfigurationGroupSchema"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of configuration group schema. + :paramtype value: list[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ConfigurationGroupSchemaPropertiesFormat(_serialization.Model): + """Configuration group schema properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the Configuration group schema resource. + Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar version_state: The configuration group schema version state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + :ivar description: Description of what schema can contain. + :vartype description: str + :ivar schema_definition: Name and value pairs that define the configuration value. It can be a + well formed escaped JSON string. + :vartype schema_definition: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "schema_definition": {"key": "schemaDefinition", "type": "str"}, + } + + def __init__( + self, *, description: Optional[str] = None, schema_definition: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword description: Description of what schema can contain. + :paramtype description: str + :keyword schema_definition: Name and value pairs that define the configuration value. It can be + a well formed escaped JSON string. + :paramtype schema_definition: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.version_state = None + self.description = description + self.schema_definition = schema_definition + + +class ConfigurationGroupSchemaVersionUpdateState(_serialization.Model): + """Publisher configuration group schema update request definition. + + :ivar version_state: The configuration group schema state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + + _attribute_map = { + "version_state": {"key": "versionState", "type": "str"}, + } + + def __init__(self, *, version_state: Optional[Union[str, "_models.VersionState"]] = None, **kwargs: Any) -> None: + """ + :keyword version_state: The configuration group schema state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :paramtype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + super().__init__(**kwargs) + self.version_state = version_state + + +class ConfigurationGroupValue(TrackedResource): + """Hybrid configuration group value resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Hybrid configuration group value properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ConfigurationGroupValuePropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "ConfigurationGroupValuePropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.ConfigurationGroupValuePropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Hybrid configuration group value properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.ConfigurationGroupValuePropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class ConfigurationGroupValueListResult(_serialization.Model): + """Response for hybrid configurationGroups API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of hybrid configurationGroups. + :vartype value: list[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ConfigurationGroupValue]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ConfigurationGroupValue"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of hybrid configurationGroups. + :paramtype value: list[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ConfigurationGroupValuePropertiesFormat(_serialization.Model): + """Hybrid configuration group value properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ConfigurationValueWithoutSecrets, ConfigurationValueWithSecrets + + 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 provisioning_state: The provisioning state of the site resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the configuration group schema. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar configuration_group_schema_name: The configuration group schema name. + :vartype configuration_group_schema_name: str + :ivar configuration_group_schema_offering_location: The location of the configuration group + schema offering. + :vartype configuration_group_schema_offering_location: str + :ivar configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :vartype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar configuration_type: The value which indicates if configuration values are secrets. + Required. Known values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.ConfigurationGroupValueConfigurationType + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "configuration_group_schema_name": {"readonly": True}, + "configuration_group_schema_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "configuration_group_schema_name": {"key": "configurationGroupSchemaName", "type": "str"}, + "configuration_group_schema_offering_location": { + "key": "configurationGroupSchemaOfferingLocation", + "type": "str", + }, + "configuration_group_schema_resource_reference": { + "key": "configurationGroupSchemaResourceReference", + "type": "DeploymentResourceIdReference", + }, + "configuration_type": {"key": "configurationType", "type": "str"}, + } + + _subtype_map = { + "configuration_type": {"Open": "ConfigurationValueWithoutSecrets", "Secret": "ConfigurationValueWithSecrets"} + } + + def __init__( + self, + *, + configuration_group_schema_resource_reference: Optional["_models.DeploymentResourceIdReference"] = None, + **kwargs: Any + ) -> None: + """ + :keyword configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :paramtype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.publisher_name = None + self.publisher_scope = None + self.configuration_group_schema_name = None + self.configuration_group_schema_offering_location = None + self.configuration_group_schema_resource_reference = configuration_group_schema_resource_reference + self.configuration_type: Optional[str] = None + + +class ConfigurationValueWithoutSecrets(ConfigurationGroupValuePropertiesFormat): + """The ConfigurationValue with no secrets. + + 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 provisioning_state: The provisioning state of the site resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the configuration group schema. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar configuration_group_schema_name: The configuration group schema name. + :vartype configuration_group_schema_name: str + :ivar configuration_group_schema_offering_location: The location of the configuration group + schema offering. + :vartype configuration_group_schema_offering_location: str + :ivar configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :vartype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar configuration_type: The value which indicates if configuration values are secrets. + Required. Known values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.ConfigurationGroupValueConfigurationType + :ivar configuration_value: Name and value pairs that define the configuration value. It can be + a well formed escaped JSON string. + :vartype configuration_value: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "configuration_group_schema_name": {"readonly": True}, + "configuration_group_schema_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "configuration_group_schema_name": {"key": "configurationGroupSchemaName", "type": "str"}, + "configuration_group_schema_offering_location": { + "key": "configurationGroupSchemaOfferingLocation", + "type": "str", + }, + "configuration_group_schema_resource_reference": { + "key": "configurationGroupSchemaResourceReference", + "type": "DeploymentResourceIdReference", + }, + "configuration_type": {"key": "configurationType", "type": "str"}, + "configuration_value": {"key": "configurationValue", "type": "str"}, + } + + def __init__( + self, + *, + configuration_group_schema_resource_reference: Optional["_models.DeploymentResourceIdReference"] = None, + configuration_value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :paramtype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword configuration_value: Name and value pairs that define the configuration value. It can + be a well formed escaped JSON string. + :paramtype configuration_value: str + """ + super().__init__( + configuration_group_schema_resource_reference=configuration_group_schema_resource_reference, **kwargs + ) + self.configuration_type: str = "Open" + self.configuration_value = configuration_value + + +class ConfigurationValueWithSecrets(ConfigurationGroupValuePropertiesFormat): + """The ConfigurationValue with secrets. + + 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 provisioning_state: The provisioning state of the site resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the configuration group schema. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar configuration_group_schema_name: The configuration group schema name. + :vartype configuration_group_schema_name: str + :ivar configuration_group_schema_offering_location: The location of the configuration group + schema offering. + :vartype configuration_group_schema_offering_location: str + :ivar configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :vartype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar configuration_type: The value which indicates if configuration values are secrets. + Required. Known values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.ConfigurationGroupValueConfigurationType + :ivar secret_configuration_value: Name and value pairs that define the configuration value + secrets. It can be a well formed escaped JSON string. + :vartype secret_configuration_value: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "configuration_group_schema_name": {"readonly": True}, + "configuration_group_schema_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "configuration_group_schema_name": {"key": "configurationGroupSchemaName", "type": "str"}, + "configuration_group_schema_offering_location": { + "key": "configurationGroupSchemaOfferingLocation", + "type": "str", + }, + "configuration_group_schema_resource_reference": { + "key": "configurationGroupSchemaResourceReference", + "type": "DeploymentResourceIdReference", + }, + "configuration_type": {"key": "configurationType", "type": "str"}, + "secret_configuration_value": {"key": "secretConfigurationValue", "type": "str"}, + } + + def __init__( + self, + *, + configuration_group_schema_resource_reference: Optional["_models.DeploymentResourceIdReference"] = None, + secret_configuration_value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword configuration_group_schema_resource_reference: The configuration group schema resource + reference. + :paramtype configuration_group_schema_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword secret_configuration_value: Name and value pairs that define the configuration value + secrets. It can be a well formed escaped JSON string. + :paramtype secret_configuration_value: str + """ + super().__init__( + configuration_group_schema_resource_reference=configuration_group_schema_resource_reference, **kwargs + ) + self.configuration_type: str = "Secret" + self.secret_configuration_value = secret_configuration_value + + +class NetworkFunctionDefinitionVersionPropertiesFormat(_serialization.Model): + """Network function definition version properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContainerizedNetworkFunctionDefinitionVersion, VirtualNetworkFunctionDefinitionVersion + + 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 provisioning_state: The provisioning state of the network function definition version + resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar version_state: The network function definition version state. Known values are: + "Unknown", "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + :ivar description: The network function definition version description. + :vartype description: str + :ivar deploy_parameters: The deployment parameters of the network function definition version. + :vartype deploy_parameters: str + :ivar network_function_type: The network function type. Required. Known values are: "Unknown", + "VirtualNetworkFunction", and "ContainerizedNetworkFunction". + :vartype network_function_type: str or ~Microsoft.HybridNetwork.models.NetworkFunctionType + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version_state": {"readonly": True}, + "network_function_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "deploy_parameters": {"key": "deployParameters", "type": "str"}, + "network_function_type": {"key": "networkFunctionType", "type": "str"}, + } + + _subtype_map = { + "network_function_type": { + "ContainerizedNetworkFunction": "ContainerizedNetworkFunctionDefinitionVersion", + "VirtualNetworkFunction": "VirtualNetworkFunctionDefinitionVersion", + } + } + + def __init__( + self, *, description: Optional[str] = None, deploy_parameters: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword description: The network function definition version description. + :paramtype description: str + :keyword deploy_parameters: The deployment parameters of the network function definition + version. + :paramtype deploy_parameters: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.version_state = None + self.description = description + self.deploy_parameters = deploy_parameters + self.network_function_type: Optional[str] = None + + +class ContainerizedNetworkFunctionDefinitionVersion(NetworkFunctionDefinitionVersionPropertiesFormat): + """Containerized network function network function definition version properties. + + 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 provisioning_state: The provisioning state of the network function definition version + resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar version_state: The network function definition version state. Known values are: + "Unknown", "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + :ivar description: The network function definition version description. + :vartype description: str + :ivar deploy_parameters: The deployment parameters of the network function definition version. + :vartype deploy_parameters: str + :ivar network_function_type: The network function type. Required. Known values are: "Unknown", + "VirtualNetworkFunction", and "ContainerizedNetworkFunction". + :vartype network_function_type: str or ~Microsoft.HybridNetwork.models.NetworkFunctionType + :ivar network_function_template: Containerized network function template. + :vartype network_function_template: + ~Microsoft.HybridNetwork.models.ContainerizedNetworkFunctionTemplate + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version_state": {"readonly": True}, + "network_function_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "deploy_parameters": {"key": "deployParameters", "type": "str"}, + "network_function_type": {"key": "networkFunctionType", "type": "str"}, + "network_function_template": {"key": "networkFunctionTemplate", "type": "ContainerizedNetworkFunctionTemplate"}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + deploy_parameters: Optional[str] = None, + network_function_template: Optional["_models.ContainerizedNetworkFunctionTemplate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: The network function definition version description. + :paramtype description: str + :keyword deploy_parameters: The deployment parameters of the network function definition + version. + :paramtype deploy_parameters: str + :keyword network_function_template: Containerized network function template. + :paramtype network_function_template: + ~Microsoft.HybridNetwork.models.ContainerizedNetworkFunctionTemplate + """ + super().__init__(description=description, deploy_parameters=deploy_parameters, **kwargs) + self.network_function_type: str = "ContainerizedNetworkFunction" + self.network_function_template = network_function_template + + +class CustomLocationResourceId(_serialization.Model): + """Reference to an Azure ARC custom location resource. + + :ivar id: Azure ARC custom location resource ID. + :vartype id: str + """ + + _validation = { + "id": { + "pattern": r"^/[sS][uU][bB][sS][cC][rR][iI][pP][tT][iI][oO][nN][sS]/[^/?#]+/[rR][eE][sS][oO][uU][rR][cC][eE][gG][rR][oO][uU][pP][sS]/[^/?#]+/[pP][rR][oO][vV][iI][dD][eE][rR][sS]/[mM][iI][cC][rR][oO][sS][oO][fF][tT]\.[eE][xX][tT][eE][nN][dD][eE][dD][lL][oO][cC][aA][tT][iI][oO][nN]/[cC][uU][sS][tT][oO][mM][lL][oO][cC][aA][tT][iI][oO][nN][sS]/[^/?#]+$" + }, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Azure ARC custom location resource ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class DaemonSet(_serialization.Model): + """Helm DaemonSet status properties. + + :ivar name: The name of the daemonSet. + :vartype name: str + :ivar namespace: The namespace of the daemonSet. + :vartype namespace: str + :ivar desired: Desired number of pods. + :vartype desired: int + :ivar current: Current number of pods. + :vartype current: int + :ivar ready: Number of Ready pods. + :vartype ready: int + :ivar up_to_date: Number of upto date pods. + :vartype up_to_date: int + :ivar available: Number of available pods. + :vartype available: int + :ivar creation_time: Creation Time of daemonSet. + :vartype creation_time: ~datetime.datetime + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "desired": {"key": "desired", "type": "int"}, + "current": {"key": "current", "type": "int"}, + "ready": {"key": "ready", "type": "int"}, + "up_to_date": {"key": "upToDate", "type": "int"}, + "available": {"key": "available", "type": "int"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + desired: Optional[int] = None, + current: Optional[int] = None, + ready: Optional[int] = None, + up_to_date: Optional[int] = None, + available: Optional[int] = None, + creation_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the daemonSet. + :paramtype name: str + :keyword namespace: The namespace of the daemonSet. + :paramtype namespace: str + :keyword desired: Desired number of pods. + :paramtype desired: int + :keyword current: Current number of pods. + :paramtype current: int + :keyword ready: Number of Ready pods. + :paramtype ready: int + :keyword up_to_date: Number of upto date pods. + :paramtype up_to_date: int + :keyword available: Number of available pods. + :paramtype available: int + :keyword creation_time: Creation Time of daemonSet. + :paramtype creation_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.desired = desired + self.current = current + self.ready = ready + self.up_to_date = up_to_date + self.available = available + self.creation_time = creation_time + + +class DependsOnProfile(_serialization.Model): + """Depends on profile definition. + + :ivar install_depends_on: Application installation operation dependency. + :vartype install_depends_on: list[str] + :ivar uninstall_depends_on: Application deletion operation dependency. + :vartype uninstall_depends_on: list[str] + :ivar update_depends_on: Application update operation dependency. + :vartype update_depends_on: list[str] + """ + + _attribute_map = { + "install_depends_on": {"key": "installDependsOn", "type": "[str]"}, + "uninstall_depends_on": {"key": "uninstallDependsOn", "type": "[str]"}, + "update_depends_on": {"key": "updateDependsOn", "type": "[str]"}, + } + + def __init__( + self, + *, + install_depends_on: Optional[List[str]] = None, + uninstall_depends_on: Optional[List[str]] = None, + update_depends_on: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword install_depends_on: Application installation operation dependency. + :paramtype install_depends_on: list[str] + :keyword uninstall_depends_on: Application deletion operation dependency. + :paramtype uninstall_depends_on: list[str] + :keyword update_depends_on: Application update operation dependency. + :paramtype update_depends_on: list[str] + """ + super().__init__(**kwargs) + self.install_depends_on = install_depends_on + self.uninstall_depends_on = uninstall_depends_on + self.update_depends_on = update_depends_on + + +class Deployment(_serialization.Model): + """Helm Deployment status properties. + + :ivar name: The name of the deployment. + :vartype name: str + :ivar namespace: The namespace of the deployment. + :vartype namespace: str + :ivar desired: Desired number of pods. + :vartype desired: int + :ivar ready: Number of ready pods. + :vartype ready: int + :ivar up_to_date: Number of upto date pods. + :vartype up_to_date: int + :ivar available: Number of available pods. + :vartype available: int + :ivar creation_time: Creation Time of deployment. + :vartype creation_time: ~datetime.datetime + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "desired": {"key": "desired", "type": "int"}, + "ready": {"key": "ready", "type": "int"}, + "up_to_date": {"key": "upToDate", "type": "int"}, + "available": {"key": "available", "type": "int"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + desired: Optional[int] = None, + ready: Optional[int] = None, + up_to_date: Optional[int] = None, + available: Optional[int] = None, + creation_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the deployment. + :paramtype name: str + :keyword namespace: The namespace of the deployment. + :paramtype namespace: str + :keyword desired: Desired number of pods. + :paramtype desired: int + :keyword ready: Number of ready pods. + :paramtype ready: int + :keyword up_to_date: Number of upto date pods. + :paramtype up_to_date: int + :keyword available: Number of available pods. + :paramtype available: int + :keyword creation_time: Creation Time of deployment. + :paramtype creation_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.desired = desired + self.ready = ready + self.up_to_date = up_to_date + self.available = available + self.creation_time = creation_time + + +class DeploymentResourceIdReference(_serialization.Model): + """The azure resource reference which is used for deployment. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + OpenDeploymentResourceReference, SecretDeploymentResourceReference + + All required parameters must be populated in order to send to Azure. + + :ivar id_type: The resource reference arm id type. Known values are: "Unknown", "Open", and + "Secret". + :vartype id_type: str or ~Microsoft.HybridNetwork.models.IdType + """ + + _validation = { + "id_type": {"required": True}, + } + + _attribute_map = { + "id_type": {"key": "idType", "type": "str"}, + } + + _subtype_map = { + "id_type": {"Open": "OpenDeploymentResourceReference", "Secret": "SecretDeploymentResourceReference"} + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id_type: Optional[str] = None + + +class DeploymentStatusProperties(_serialization.Model): + """The deployment status properties of the network function component. + + :ivar status: The status of the component resource. Known values are: "Unknown", "Deployed", + "Uninstalled", "Superseded", "Failed", "Uninstalling", "Pending-Install", "Pending-Upgrade", + "Pending-Rollback", "Downloading", "Installing", "Reinstalling", "Rollingback", and + "Upgrading". + :vartype status: str or ~Microsoft.HybridNetwork.models.Status + :ivar resources: The resource related to the component resource. + :vartype resources: ~Microsoft.HybridNetwork.models.Resources + :ivar next_expected_update_at: The next expected update of deployment status. + :vartype next_expected_update_at: ~datetime.datetime + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "resources": {"key": "resources", "type": "Resources"}, + "next_expected_update_at": {"key": "nextExpectedUpdateAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.Status"]] = None, + resources: Optional["_models.Resources"] = None, + next_expected_update_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: The status of the component resource. Known values are: "Unknown", "Deployed", + "Uninstalled", "Superseded", "Failed", "Uninstalling", "Pending-Install", "Pending-Upgrade", + "Pending-Rollback", "Downloading", "Installing", "Reinstalling", "Rollingback", and + "Upgrading". + :paramtype status: str or ~Microsoft.HybridNetwork.models.Status + :keyword resources: The resource related to the component resource. + :paramtype resources: ~Microsoft.HybridNetwork.models.Resources + :keyword next_expected_update_at: The next expected update of deployment status. + :paramtype next_expected_update_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.status = status + self.resources = resources + self.next_expected_update_at = next_expected_update_at + + +class ErrorAdditionalInfo(_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: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_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[~Microsoft.HybridNetwork.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~Microsoft.HybridNetwork.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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_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.). + + :ivar error: The error object. + :vartype error: ~Microsoft.HybridNetwork.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~Microsoft.HybridNetwork.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ExecuteRequestParameters(_serialization.Model): + """Payload for execute request post call. + + All required parameters must be populated in order to send to Azure. + + :ivar service_endpoint: The endpoint of service to call. Required. + :vartype service_endpoint: str + :ivar request_metadata: The request metadata. Required. + :vartype request_metadata: ~Microsoft.HybridNetwork.models.RequestMetadata + """ + + _validation = { + "service_endpoint": {"required": True}, + "request_metadata": {"required": True}, + } + + _attribute_map = { + "service_endpoint": {"key": "serviceEndpoint", "type": "str"}, + "request_metadata": {"key": "requestMetadata", "type": "RequestMetadata"}, + } + + def __init__(self, *, service_endpoint: str, request_metadata: "_models.RequestMetadata", **kwargs: Any) -> None: + """ + :keyword service_endpoint: The endpoint of service to call. Required. + :paramtype service_endpoint: str + :keyword request_metadata: The request metadata. Required. + :paramtype request_metadata: ~Microsoft.HybridNetwork.models.RequestMetadata + """ + super().__init__(**kwargs) + self.service_endpoint = service_endpoint + self.request_metadata = request_metadata + + +class HelmArtifactProfile(_serialization.Model): + """Helm artifact profile. + + :ivar helm_package_name: Helm package name. + :vartype helm_package_name: str + :ivar helm_package_version_range: Helm package version range. + :vartype helm_package_version_range: str + :ivar registry_values_paths: The registry values path list. + :vartype registry_values_paths: list[str] + :ivar image_pull_secrets_values_paths: The image pull secrets values path list. + :vartype image_pull_secrets_values_paths: list[str] + """ + + _attribute_map = { + "helm_package_name": {"key": "helmPackageName", "type": "str"}, + "helm_package_version_range": {"key": "helmPackageVersionRange", "type": "str"}, + "registry_values_paths": {"key": "registryValuesPaths", "type": "[str]"}, + "image_pull_secrets_values_paths": {"key": "imagePullSecretsValuesPaths", "type": "[str]"}, + } + + def __init__( + self, + *, + helm_package_name: Optional[str] = None, + helm_package_version_range: Optional[str] = None, + registry_values_paths: Optional[List[str]] = None, + image_pull_secrets_values_paths: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword helm_package_name: Helm package name. + :paramtype helm_package_name: str + :keyword helm_package_version_range: Helm package version range. + :paramtype helm_package_version_range: str + :keyword registry_values_paths: The registry values path list. + :paramtype registry_values_paths: list[str] + :keyword image_pull_secrets_values_paths: The image pull secrets values path list. + :paramtype image_pull_secrets_values_paths: list[str] + """ + super().__init__(**kwargs) + self.helm_package_name = helm_package_name + self.helm_package_version_range = helm_package_version_range + self.registry_values_paths = registry_values_paths + self.image_pull_secrets_values_paths = image_pull_secrets_values_paths + + +class HelmInstallOptions(_serialization.Model): + """The helm deployment install options. + + :ivar atomic: The helm deployment atomic options. + :vartype atomic: str + :ivar wait: The helm deployment wait options. + :vartype wait: str + :ivar timeout: The helm deployment timeout options. + :vartype timeout: str + """ + + _attribute_map = { + "atomic": {"key": "atomic", "type": "str"}, + "wait": {"key": "wait", "type": "str"}, + "timeout": {"key": "timeout", "type": "str"}, + } + + def __init__( + self, *, atomic: Optional[str] = None, wait: Optional[str] = None, timeout: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword atomic: The helm deployment atomic options. + :paramtype atomic: str + :keyword wait: The helm deployment wait options. + :paramtype wait: str + :keyword timeout: The helm deployment timeout options. + :paramtype timeout: str + """ + super().__init__(**kwargs) + self.atomic = atomic + self.wait = wait + self.timeout = timeout + + +class HelmMappingRuleProfile(_serialization.Model): + """Helm mapping rule profile. + + :ivar release_namespace: Helm release namespace. + :vartype release_namespace: str + :ivar release_name: Helm release name. + :vartype release_name: str + :ivar helm_package_version: Helm package version. + :vartype helm_package_version: str + :ivar values: Helm release values. + :vartype values: str + :ivar options: The helm deployment options. + :vartype options: ~Microsoft.HybridNetwork.models.HelmMappingRuleProfileOptions + """ + + _attribute_map = { + "release_namespace": {"key": "releaseNamespace", "type": "str"}, + "release_name": {"key": "releaseName", "type": "str"}, + "helm_package_version": {"key": "helmPackageVersion", "type": "str"}, + "values": {"key": "values", "type": "str"}, + "options": {"key": "options", "type": "HelmMappingRuleProfileOptions"}, + } + + def __init__( + self, + *, + release_namespace: Optional[str] = None, + release_name: Optional[str] = None, + helm_package_version: Optional[str] = None, + values: Optional[str] = None, + options: Optional["_models.HelmMappingRuleProfileOptions"] = None, + **kwargs: Any + ) -> None: + """ + :keyword release_namespace: Helm release namespace. + :paramtype release_namespace: str + :keyword release_name: Helm release name. + :paramtype release_name: str + :keyword helm_package_version: Helm package version. + :paramtype helm_package_version: str + :keyword values: Helm release values. + :paramtype values: str + :keyword options: The helm deployment options. + :paramtype options: ~Microsoft.HybridNetwork.models.HelmMappingRuleProfileOptions + """ + super().__init__(**kwargs) + self.release_namespace = release_namespace + self.release_name = release_name + self.helm_package_version = helm_package_version + self.values = values + self.options = options + + +class HelmMappingRuleProfileOptions(_serialization.Model): + """The helm deployment options. + + :ivar install_options: The helm deployment install options. + :vartype install_options: ~Microsoft.HybridNetwork.models.HelmInstallOptions + :ivar upgrade_options: The helm deployment upgrade options. + :vartype upgrade_options: ~Microsoft.HybridNetwork.models.HelmUpgradeOptions + """ + + _attribute_map = { + "install_options": {"key": "installOptions", "type": "HelmInstallOptions"}, + "upgrade_options": {"key": "upgradeOptions", "type": "HelmUpgradeOptions"}, + } + + def __init__( + self, + *, + install_options: Optional["_models.HelmInstallOptions"] = None, + upgrade_options: Optional["_models.HelmUpgradeOptions"] = None, + **kwargs: Any + ) -> None: + """ + :keyword install_options: The helm deployment install options. + :paramtype install_options: ~Microsoft.HybridNetwork.models.HelmInstallOptions + :keyword upgrade_options: The helm deployment upgrade options. + :paramtype upgrade_options: ~Microsoft.HybridNetwork.models.HelmUpgradeOptions + """ + super().__init__(**kwargs) + self.install_options = install_options + self.upgrade_options = upgrade_options + + +class HelmUpgradeOptions(_serialization.Model): + """The helm deployment install options. + + :ivar atomic: The helm deployment atomic options. + :vartype atomic: str + :ivar wait: The helm deployment wait options. + :vartype wait: str + :ivar timeout: The helm deployment timeout options. + :vartype timeout: str + """ + + _attribute_map = { + "atomic": {"key": "atomic", "type": "str"}, + "wait": {"key": "wait", "type": "str"}, + "timeout": {"key": "timeout", "type": "str"}, + } + + def __init__( + self, *, atomic: Optional[str] = None, wait: Optional[str] = None, timeout: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword atomic: The helm deployment atomic options. + :paramtype atomic: str + :keyword wait: The helm deployment wait options. + :paramtype wait: str + :keyword timeout: The helm deployment timeout options. + :paramtype timeout: str + """ + super().__init__(**kwargs) + self.atomic = atomic + self.wait = wait + self.timeout = timeout + + +class ImageArtifactProfile(_serialization.Model): + """Image artifact profile. + + :ivar image_name: Image name. + :vartype image_name: str + :ivar image_version: Image version. + :vartype image_version: str + """ + + _attribute_map = { + "image_name": {"key": "imageName", "type": "str"}, + "image_version": {"key": "imageVersion", "type": "str"}, + } + + def __init__(self, *, image_name: Optional[str] = None, image_version: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword image_name: Image name. + :paramtype image_name: str + :keyword image_version: Image version. + :paramtype image_version: str + """ + super().__init__(**kwargs) + self.image_name = image_name + self.image_version = image_version + + +class ImageMappingRuleProfile(_serialization.Model): + """Image mapping rule profile. + + :ivar user_configuration: List of values. + :vartype user_configuration: str + """ + + _attribute_map = { + "user_configuration": {"key": "userConfiguration", "type": "str"}, + } + + def __init__(self, *, user_configuration: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword user_configuration: List of values. + :paramtype user_configuration: str + """ + super().__init__(**kwargs) + self.user_configuration = user_configuration + + +class ManagedResourceGroupConfiguration(_serialization.Model): + """Managed resource group configuration. + + :ivar name: Managed resource group name. + :vartype name: str + :ivar location: Managed resource group location. + :vartype location: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Managed resource group name. + :paramtype name: str + :keyword location: Managed resource group location. + :paramtype location: str + """ + super().__init__(**kwargs) + self.name = name + self.location = location + + +class ManagedServiceIdentity(_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 + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :vartype type: str or ~Microsoft.HybridNetwork.models.ManagedServiceIdentityType + :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}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~Microsoft.HybridNetwork.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, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :paramtype type: str or ~Microsoft.HybridNetwork.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}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~Microsoft.HybridNetwork.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ManifestArtifactFormat(_serialization.Model): + """Manifest artifact properties. + + :ivar artifact_name: The artifact name. + :vartype artifact_name: str + :ivar artifact_type: The artifact type. Known values are: "Unknown", "OCIArtifact", + "VhdImageFile", "ArmTemplate", and "ImageFile". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.ArtifactType + :ivar artifact_version: The artifact version. + :vartype artifact_version: str + """ + + _attribute_map = { + "artifact_name": {"key": "artifactName", "type": "str"}, + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_version": {"key": "artifactVersion", "type": "str"}, + } + + def __init__( + self, + *, + artifact_name: Optional[str] = None, + artifact_type: Optional[Union[str, "_models.ArtifactType"]] = None, + artifact_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_name: The artifact name. + :paramtype artifact_name: str + :keyword artifact_type: The artifact type. Known values are: "Unknown", "OCIArtifact", + "VhdImageFile", "ArmTemplate", and "ImageFile". + :paramtype artifact_type: str or ~Microsoft.HybridNetwork.models.ArtifactType + :keyword artifact_version: The artifact version. + :paramtype artifact_version: str + """ + super().__init__(**kwargs) + self.artifact_name = artifact_name + self.artifact_type = artifact_type + self.artifact_version = artifact_version + + +class NetworkFunction(TrackedResource): + """Network function resource response. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Network function properties. + :vartype properties: ~Microsoft.HybridNetwork.models.NetworkFunctionPropertiesFormat + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar identity: The managed identity of the network function. + :vartype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NetworkFunctionPropertiesFormat"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NetworkFunctionPropertiesFormat"] = None, + etag: Optional[str] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Network function properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.NetworkFunctionPropertiesFormat + :keyword etag: A unique read-only string that changes whenever the resource is updated. + :paramtype etag: str + :keyword identity: The managed identity of the network function. + :paramtype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + self.etag = etag + self.identity = identity + + +class NetworkFunctionDefinitionGroup(TrackedResource): + """Network function definition group resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Network function definition group properties. + :vartype properties: + ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroupPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NetworkFunctionDefinitionGroupPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NetworkFunctionDefinitionGroupPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Network function definition group properties. + :paramtype properties: + ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroupPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class NetworkFunctionDefinitionGroupListResult(_serialization.Model): + """A list of network function definition group resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of network function definition group. + :vartype value: list[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkFunctionDefinitionGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.NetworkFunctionDefinitionGroup"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of network function definition group. + :paramtype value: list[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class NetworkFunctionDefinitionGroupPropertiesFormat(_serialization.Model): + """Network function definition group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the network function definition groups + resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar description: The network function definition group description. + :vartype description: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword description: The network function definition group description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.description = description + + +class NetworkFunctionDefinitionResourceElementTemplateDetails(ResourceElementTemplate): + """The network function definition resource element template details. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the resource element template. + :vartype name: str + :ivar resource_element_type: The resource element template type. Required. Known values are: + "Unknown", "ArmResourceDefinition", and "NetworkFunctionDefinition". + :vartype resource_element_type: str or ~Microsoft.HybridNetwork.models.Type + :ivar depends_on_profile: The depends on profile. + :vartype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :ivar configuration: The resource element template type. + :vartype configuration: + ~Microsoft.HybridNetwork.models.ArmResourceDefinitionResourceElementTemplate + """ + + _validation = { + "resource_element_type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "resource_element_type": {"key": "type", "type": "str"}, + "depends_on_profile": {"key": "dependsOnProfile", "type": "DependsOnProfile"}, + "configuration": {"key": "configuration", "type": "ArmResourceDefinitionResourceElementTemplate"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + depends_on_profile: Optional["_models.DependsOnProfile"] = None, + configuration: Optional["_models.ArmResourceDefinitionResourceElementTemplate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource element template. + :paramtype name: str + :keyword depends_on_profile: The depends on profile. + :paramtype depends_on_profile: ~Microsoft.HybridNetwork.models.DependsOnProfile + :keyword configuration: The resource element template type. + :paramtype configuration: + ~Microsoft.HybridNetwork.models.ArmResourceDefinitionResourceElementTemplate + """ + super().__init__(name=name, depends_on_profile=depends_on_profile, **kwargs) + self.resource_element_type: str = "NetworkFunctionDefinition" + self.configuration = configuration + + +class NetworkFunctionDefinitionVersion(TrackedResource): + """Network function definition version. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Network function definition version properties. + :vartype properties: + ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NetworkFunctionDefinitionVersionPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NetworkFunctionDefinitionVersionPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Network function definition version properties. + :paramtype properties: + ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class NetworkFunctionDefinitionVersionListResult(_serialization.Model): + """A list of network function definition versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of network function definition versions. + :vartype value: list[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :ivar next_link: The URI to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkFunctionDefinitionVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.NetworkFunctionDefinitionVersion"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of network function definition versions. + :paramtype value: list[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class NetworkFunctionDefinitionVersionUpdateState(_serialization.Model): + """Publisher network function definition version update request definition. + + :ivar version_state: The network function definition version state. Only the 'Active' and + 'Deprecated' states are allowed for updates. Other states are used for internal state + transitioning. Known values are: "Unknown", "Preview", "Active", "Deprecated", "Validating", + and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + + _attribute_map = { + "version_state": {"key": "versionState", "type": "str"}, + } + + def __init__(self, *, version_state: Optional[Union[str, "_models.VersionState"]] = None, **kwargs: Any) -> None: + """ + :keyword version_state: The network function definition version state. Only the 'Active' and + 'Deprecated' states are allowed for updates. Other states are used for internal state + transitioning. Known values are: "Unknown", "Preview", "Active", "Deprecated", "Validating", + and "ValidationFailed". + :paramtype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + super().__init__(**kwargs) + self.version_state = version_state + + +class NetworkFunctionListResult(_serialization.Model): + """Response for network function API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of network function resources in a subscription or resource group. + :vartype value: list[~Microsoft.HybridNetwork.models.NetworkFunction] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkFunction]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.NetworkFunction"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of network function resources in a subscription or resource group. + :paramtype value: list[~Microsoft.HybridNetwork.models.NetworkFunction] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class NetworkFunctionPropertiesFormat(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Network function properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + NetworkFunctionValueWithoutSecrets, NetworkFunctionValueWithSecrets + + 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 provisioning_state: The provisioning state of the network function resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the network function. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar network_function_definition_group_name: The network function definition group name for + the network function. + :vartype network_function_definition_group_name: str + :ivar network_function_definition_version: The network function definition version for the + network function. + :vartype network_function_definition_version: str + :ivar network_function_definition_offering_location: The location of the network function + definition offering. + :vartype network_function_definition_offering_location: str + :ivar network_function_definition_version_resource_reference: The network function definition + version resource reference. + :vartype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar nfvi_id: The nfviId for the network function. + :vartype nfvi_id: str + :ivar allow_software_update: Indicates if software updates are allowed during deployment. + :vartype allow_software_update: bool + :ivar configuration_type: The value which indicates if NF values are secrets. Required. Known + values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.NetworkFunctionConfigurationType + :ivar role_override_values: The role configuration override values from the user. + :vartype role_override_values: list[str] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "network_function_definition_group_name": {"readonly": True}, + "network_function_definition_version": {"readonly": True}, + "network_function_definition_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "network_function_definition_group_name": {"key": "networkFunctionDefinitionGroupName", "type": "str"}, + "network_function_definition_version": {"key": "networkFunctionDefinitionVersion", "type": "str"}, + "network_function_definition_offering_location": { + "key": "networkFunctionDefinitionOfferingLocation", + "type": "str", + }, + "network_function_definition_version_resource_reference": { + "key": "networkFunctionDefinitionVersionResourceReference", + "type": "DeploymentResourceIdReference", + }, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "nfvi_id": {"key": "nfviId", "type": "str"}, + "allow_software_update": {"key": "allowSoftwareUpdate", "type": "bool"}, + "configuration_type": {"key": "configurationType", "type": "str"}, + "role_override_values": {"key": "roleOverrideValues", "type": "[str]"}, + } + + _subtype_map = { + "configuration_type": { + "Open": "NetworkFunctionValueWithoutSecrets", + "Secret": "NetworkFunctionValueWithSecrets", + } + } + + def __init__( + self, + *, + network_function_definition_version_resource_reference: Optional[ + "_models.DeploymentResourceIdReference" + ] = None, + nfvi_type: Optional[Union[str, "_models.NFVIType"]] = None, + nfvi_id: Optional[str] = None, + allow_software_update: Optional[bool] = None, + role_override_values: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_definition_version_resource_reference: The network function + definition version resource reference. + :paramtype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :paramtype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :keyword nfvi_id: The nfviId for the network function. + :paramtype nfvi_id: str + :keyword allow_software_update: Indicates if software updates are allowed during deployment. + :paramtype allow_software_update: bool + :keyword role_override_values: The role configuration override values from the user. + :paramtype role_override_values: list[str] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.publisher_name = None + self.publisher_scope = None + self.network_function_definition_group_name = None + self.network_function_definition_version = None + self.network_function_definition_offering_location = None + self.network_function_definition_version_resource_reference = ( + network_function_definition_version_resource_reference + ) + self.nfvi_type = nfvi_type + self.nfvi_id = nfvi_id + self.allow_software_update = allow_software_update + self.configuration_type: Optional[str] = None + self.role_override_values = role_override_values + + +class NetworkFunctionValueWithoutSecrets( + NetworkFunctionPropertiesFormat +): # pylint: disable=too-many-instance-attributes + """NetworkFunction with no secrets. + + 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 provisioning_state: The provisioning state of the network function resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the network function. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar network_function_definition_group_name: The network function definition group name for + the network function. + :vartype network_function_definition_group_name: str + :ivar network_function_definition_version: The network function definition version for the + network function. + :vartype network_function_definition_version: str + :ivar network_function_definition_offering_location: The location of the network function + definition offering. + :vartype network_function_definition_offering_location: str + :ivar network_function_definition_version_resource_reference: The network function definition + version resource reference. + :vartype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar nfvi_id: The nfviId for the network function. + :vartype nfvi_id: str + :ivar allow_software_update: Indicates if software updates are allowed during deployment. + :vartype allow_software_update: bool + :ivar configuration_type: The value which indicates if NF values are secrets. Required. Known + values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.NetworkFunctionConfigurationType + :ivar role_override_values: The role configuration override values from the user. + :vartype role_override_values: list[str] + :ivar deployment_values: The JSON-serialized deployment values from the user. + :vartype deployment_values: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "network_function_definition_group_name": {"readonly": True}, + "network_function_definition_version": {"readonly": True}, + "network_function_definition_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "network_function_definition_group_name": {"key": "networkFunctionDefinitionGroupName", "type": "str"}, + "network_function_definition_version": {"key": "networkFunctionDefinitionVersion", "type": "str"}, + "network_function_definition_offering_location": { + "key": "networkFunctionDefinitionOfferingLocation", + "type": "str", + }, + "network_function_definition_version_resource_reference": { + "key": "networkFunctionDefinitionVersionResourceReference", + "type": "DeploymentResourceIdReference", + }, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "nfvi_id": {"key": "nfviId", "type": "str"}, + "allow_software_update": {"key": "allowSoftwareUpdate", "type": "bool"}, + "configuration_type": {"key": "configurationType", "type": "str"}, + "role_override_values": {"key": "roleOverrideValues", "type": "[str]"}, + "deployment_values": {"key": "deploymentValues", "type": "str"}, + } + + def __init__( + self, + *, + network_function_definition_version_resource_reference: Optional[ + "_models.DeploymentResourceIdReference" + ] = None, + nfvi_type: Optional[Union[str, "_models.NFVIType"]] = None, + nfvi_id: Optional[str] = None, + allow_software_update: Optional[bool] = None, + role_override_values: Optional[List[str]] = None, + deployment_values: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_definition_version_resource_reference: The network function + definition version resource reference. + :paramtype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :paramtype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :keyword nfvi_id: The nfviId for the network function. + :paramtype nfvi_id: str + :keyword allow_software_update: Indicates if software updates are allowed during deployment. + :paramtype allow_software_update: bool + :keyword role_override_values: The role configuration override values from the user. + :paramtype role_override_values: list[str] + :keyword deployment_values: The JSON-serialized deployment values from the user. + :paramtype deployment_values: str + """ + super().__init__( + network_function_definition_version_resource_reference=network_function_definition_version_resource_reference, + nfvi_type=nfvi_type, + nfvi_id=nfvi_id, + allow_software_update=allow_software_update, + role_override_values=role_override_values, + **kwargs + ) + self.configuration_type: str = "Open" + self.deployment_values = deployment_values + + +class NetworkFunctionValueWithSecrets(NetworkFunctionPropertiesFormat): # pylint: disable=too-many-instance-attributes + """NetworkFunction with secrets. + + 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 provisioning_state: The provisioning state of the network function resource. Known values + are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar publisher_name: The publisher name for the network function. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar network_function_definition_group_name: The network function definition group name for + the network function. + :vartype network_function_definition_group_name: str + :ivar network_function_definition_version: The network function definition version for the + network function. + :vartype network_function_definition_version: str + :ivar network_function_definition_offering_location: The location of the network function + definition offering. + :vartype network_function_definition_offering_location: str + :ivar network_function_definition_version_resource_reference: The network function definition + version resource reference. + :vartype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :vartype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :ivar nfvi_id: The nfviId for the network function. + :vartype nfvi_id: str + :ivar allow_software_update: Indicates if software updates are allowed during deployment. + :vartype allow_software_update: bool + :ivar configuration_type: The value which indicates if NF values are secrets. Required. Known + values are: "Unknown", "Secret", and "Open". + :vartype configuration_type: str or + ~Microsoft.HybridNetwork.models.NetworkFunctionConfigurationType + :ivar role_override_values: The role configuration override values from the user. + :vartype role_override_values: list[str] + :ivar secret_deployment_values: The JSON-serialized secret deployment values from the user. + This contains secrets like passwords,keys etc. + :vartype secret_deployment_values: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "network_function_definition_group_name": {"readonly": True}, + "network_function_definition_version": {"readonly": True}, + "network_function_definition_offering_location": {"readonly": True}, + "configuration_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "network_function_definition_group_name": {"key": "networkFunctionDefinitionGroupName", "type": "str"}, + "network_function_definition_version": {"key": "networkFunctionDefinitionVersion", "type": "str"}, + "network_function_definition_offering_location": { + "key": "networkFunctionDefinitionOfferingLocation", + "type": "str", + }, + "network_function_definition_version_resource_reference": { + "key": "networkFunctionDefinitionVersionResourceReference", + "type": "DeploymentResourceIdReference", + }, + "nfvi_type": {"key": "nfviType", "type": "str"}, + "nfvi_id": {"key": "nfviId", "type": "str"}, + "allow_software_update": {"key": "allowSoftwareUpdate", "type": "bool"}, + "configuration_type": {"key": "configurationType", "type": "str"}, + "role_override_values": {"key": "roleOverrideValues", "type": "[str]"}, + "secret_deployment_values": {"key": "secretDeploymentValues", "type": "str"}, + } + + def __init__( + self, + *, + network_function_definition_version_resource_reference: Optional[ + "_models.DeploymentResourceIdReference" + ] = None, + nfvi_type: Optional[Union[str, "_models.NFVIType"]] = None, + nfvi_id: Optional[str] = None, + allow_software_update: Optional[bool] = None, + role_override_values: Optional[List[str]] = None, + secret_deployment_values: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_function_definition_version_resource_reference: The network function + definition version resource reference. + :paramtype network_function_definition_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword nfvi_type: The nfvi type for the network function. Known values are: "Unknown", + "AzureArcKubernetes", "AzureCore", and "AzureOperatorNexus". + :paramtype nfvi_type: str or ~Microsoft.HybridNetwork.models.NFVIType + :keyword nfvi_id: The nfviId for the network function. + :paramtype nfvi_id: str + :keyword allow_software_update: Indicates if software updates are allowed during deployment. + :paramtype allow_software_update: bool + :keyword role_override_values: The role configuration override values from the user. + :paramtype role_override_values: list[str] + :keyword secret_deployment_values: The JSON-serialized secret deployment values from the user. + This contains secrets like passwords,keys etc. + :paramtype secret_deployment_values: str + """ + super().__init__( + network_function_definition_version_resource_reference=network_function_definition_version_resource_reference, + nfvi_type=nfvi_type, + nfvi_id=nfvi_id, + allow_software_update=allow_software_update, + role_override_values=role_override_values, + **kwargs + ) + self.configuration_type: str = "Secret" + self.secret_deployment_values = secret_deployment_values + + +class NetworkServiceDesignGroup(TrackedResource): + """network service design group resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: network service design group properties. + :vartype properties: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroupPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NetworkServiceDesignGroupPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NetworkServiceDesignGroupPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: network service design group properties. + :paramtype properties: + ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroupPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class NetworkServiceDesignGroupListResult(_serialization.Model): + """A list of network service design group resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of network service design group. + :vartype value: list[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkServiceDesignGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.NetworkServiceDesignGroup"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of network service design group. + :paramtype value: list[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class NetworkServiceDesignGroupPropertiesFormat(_serialization.Model): + """network service design group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the network service design groups resource. + Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", + "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar description: The network service design group description. + :vartype description: str + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword description: The network service design group description. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.description = description + + +class NetworkServiceDesignVersion(TrackedResource): + """network service design version. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: network service design version properties. + :vartype properties: + ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NetworkServiceDesignVersionPropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NetworkServiceDesignVersionPropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: network service design version properties. + :paramtype properties: + ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionPropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class NetworkServiceDesignVersionListResult(_serialization.Model): + """A list of network service design versions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of network service design versions. + :vartype value: list[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :ivar next_link: The URI to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkServiceDesignVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.NetworkServiceDesignVersion"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of network service design versions. + :paramtype value: list[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class NetworkServiceDesignVersionPropertiesFormat(_serialization.Model): + """network service design version properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the network service design version + resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar version_state: The network service design version state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + :ivar description: The network service design version description. + :vartype description: str + :ivar configuration_group_schema_references: The configuration schemas to used to define the + values. + :vartype configuration_group_schema_references: dict[str, + ~Microsoft.HybridNetwork.models.ReferencedResource] + :ivar nfvis_from_site: The nfvis from the site. + :vartype nfvis_from_site: dict[str, ~Microsoft.HybridNetwork.models.NfviDetails] + :ivar resource_element_templates: List of resource element template. + :vartype resource_element_templates: + list[~Microsoft.HybridNetwork.models.ResourceElementTemplate] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "configuration_group_schema_references": { + "key": "configurationGroupSchemaReferences", + "type": "{ReferencedResource}", + }, + "nfvis_from_site": {"key": "nfvisFromSite", "type": "{NfviDetails}"}, + "resource_element_templates": {"key": "resourceElementTemplates", "type": "[ResourceElementTemplate]"}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + configuration_group_schema_references: Optional[Dict[str, "_models.ReferencedResource"]] = None, + nfvis_from_site: Optional[Dict[str, "_models.NfviDetails"]] = None, + resource_element_templates: Optional[List["_models.ResourceElementTemplate"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: The network service design version description. + :paramtype description: str + :keyword configuration_group_schema_references: The configuration schemas to used to define the + values. + :paramtype configuration_group_schema_references: dict[str, + ~Microsoft.HybridNetwork.models.ReferencedResource] + :keyword nfvis_from_site: The nfvis from the site. + :paramtype nfvis_from_site: dict[str, ~Microsoft.HybridNetwork.models.NfviDetails] + :keyword resource_element_templates: List of resource element template. + :paramtype resource_element_templates: + list[~Microsoft.HybridNetwork.models.ResourceElementTemplate] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.version_state = None + self.description = description + self.configuration_group_schema_references = configuration_group_schema_references + self.nfvis_from_site = nfvis_from_site + self.resource_element_templates = resource_element_templates + + +class NetworkServiceDesignVersionUpdateState(_serialization.Model): + """Publisher network service design version update request definition. + + :ivar version_state: The network service design version state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + + _attribute_map = { + "version_state": {"key": "versionState", "type": "str"}, + } + + def __init__(self, *, version_state: Optional[Union[str, "_models.VersionState"]] = None, **kwargs: Any) -> None: + """ + :keyword version_state: The network service design version state. Known values are: "Unknown", + "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :paramtype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + """ + super().__init__(**kwargs) + self.version_state = version_state + + +class NfviDetails(_serialization.Model): + """The nfvi details. + + :ivar name: The nfvi name. + :vartype name: str + :ivar type: The nfvi type. + :vartype type: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: The nfvi name. + :paramtype name: str + :keyword type: The nfvi type. + :paramtype type: str + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class NSDArtifactProfile(_serialization.Model): + """Artifact profile properties. + + :ivar artifact_store_reference: The artifact store resource id. + :vartype artifact_store_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar artifact_name: Artifact name. + :vartype artifact_name: str + :ivar artifact_version: Artifact version. + :vartype artifact_version: str + """ + + _attribute_map = { + "artifact_store_reference": {"key": "artifactStoreReference", "type": "ReferencedResource"}, + "artifact_name": {"key": "artifactName", "type": "str"}, + "artifact_version": {"key": "artifactVersion", "type": "str"}, + } + + def __init__( + self, + *, + artifact_store_reference: Optional["_models.ReferencedResource"] = None, + artifact_name: Optional[str] = None, + artifact_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_store_reference: The artifact store resource id. + :paramtype artifact_store_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword artifact_name: Artifact name. + :paramtype artifact_name: str + :keyword artifact_version: Artifact version. + :paramtype artifact_version: str + """ + super().__init__(**kwargs) + self.artifact_store_reference = artifact_store_reference + self.artifact_name = artifact_name + self.artifact_version = artifact_version + + +class OpenDeploymentResourceReference(DeploymentResourceIdReference): + """Non secret deployment resource id reference. + + All required parameters must be populated in order to send to Azure. + + :ivar id_type: The resource reference arm id type. Known values are: "Unknown", "Open", and + "Secret". + :vartype id_type: str or ~Microsoft.HybridNetwork.models.IdType + :ivar id: Resource ID. + :vartype id: str + """ + + _validation = { + "id_type": {"required": True}, + } + + _attribute_map = { + "id_type": {"key": "idType", "type": "str"}, + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id_type: str = "Open" + self.id = id + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~Microsoft.HybridNetwork.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~Microsoft.HybridNetwork.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~Microsoft.HybridNetwork.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~Microsoft.HybridNetwork.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~Microsoft.HybridNetwork.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Pod(_serialization.Model): + """Helm Pod status properties. + + :ivar name: The name of the Pod. + :vartype name: str + :ivar namespace: The namespace of the Pod. + :vartype namespace: str + :ivar desired: Desired number of containers. + :vartype desired: int + :ivar ready: Number of ready containers. + :vartype ready: int + :ivar status: The status of a pod. Known values are: "Unknown", "Succeeded", "Failed", + "Running", "Pending", "Terminating", and "NotReady". + :vartype status: str or ~Microsoft.HybridNetwork.models.PodStatus + :ivar creation_time: Creation Time of Pod. + :vartype creation_time: ~datetime.datetime + :ivar events: Last 5 Pod events. + :vartype events: list[~Microsoft.HybridNetwork.models.PodEvent] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "desired": {"key": "desired", "type": "int"}, + "ready": {"key": "ready", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "events": {"key": "events", "type": "[PodEvent]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + desired: Optional[int] = None, + ready: Optional[int] = None, + status: Optional[Union[str, "_models.PodStatus"]] = None, + creation_time: Optional[datetime.datetime] = None, + events: Optional[List["_models.PodEvent"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the Pod. + :paramtype name: str + :keyword namespace: The namespace of the Pod. + :paramtype namespace: str + :keyword desired: Desired number of containers. + :paramtype desired: int + :keyword ready: Number of ready containers. + :paramtype ready: int + :keyword status: The status of a pod. Known values are: "Unknown", "Succeeded", "Failed", + "Running", "Pending", "Terminating", and "NotReady". + :paramtype status: str or ~Microsoft.HybridNetwork.models.PodStatus + :keyword creation_time: Creation Time of Pod. + :paramtype creation_time: ~datetime.datetime + :keyword events: Last 5 Pod events. + :paramtype events: list[~Microsoft.HybridNetwork.models.PodEvent] + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.desired = desired + self.ready = ready + self.status = status + self.creation_time = creation_time + self.events = events + + +class PodEvent(_serialization.Model): + """Pod Event properties. + + :ivar type: The type of pod event. Known values are: "Normal" and "Warning". + :vartype type: str or ~Microsoft.HybridNetwork.models.PodEventType + :ivar reason: Event reason. + :vartype reason: str + :ivar message: Event message. + :vartype message: str + :ivar last_seen_time: Event Last seen. + :vartype last_seen_time: ~datetime.datetime + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "last_seen_time": {"key": "lastSeenTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.PodEventType"]] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + last_seen_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of pod event. Known values are: "Normal" and "Warning". + :paramtype type: str or ~Microsoft.HybridNetwork.models.PodEventType + :keyword reason: Event reason. + :paramtype reason: str + :keyword message: Event message. + :paramtype message: str + :keyword last_seen_time: Event Last seen. + :paramtype last_seen_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.type = type + self.reason = reason + self.message = message + self.last_seen_time = last_seen_time + + +class ProxyArtifactListOverview(ProxyResource): + """The proxy artifact overview. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + """ + + +class ProxyArtifactOverview(ProxyResource): + """The proxy artifact overview. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar properties: Proxy Artifact properties overview. + :vartype properties: ~Microsoft.HybridNetwork.models.ProxyArtifactOverviewPropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ProxyArtifactOverviewPropertiesFormat"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.properties = None + + +class ProxyArtifactOverviewListResult(_serialization.Model): + """The proxy artifact list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of available proxy artifacts. + :vartype value: list[~Microsoft.HybridNetwork.models.ProxyArtifactListOverview] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ProxyArtifactListOverview]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ProxyArtifactListOverview"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of available proxy artifacts. + :paramtype value: list[~Microsoft.HybridNetwork.models.ProxyArtifactListOverview] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ProxyArtifactOverviewPropertiesFormat(_serialization.Model): + """Proxy Artifact overview properties. + + :ivar artifact_versions: The proxy artifact overview properties. + :vartype artifact_versions: + list[~Microsoft.HybridNetwork.models.ProxyArtifactOverviewPropertiesValue] + """ + + _attribute_map = { + "artifact_versions": {"key": "artifactVersions", "type": "[ProxyArtifactOverviewPropertiesValue]"}, + } + + def __init__( + self, *, artifact_versions: Optional[List["_models.ProxyArtifactOverviewPropertiesValue"]] = None, **kwargs: Any + ) -> None: + """ + :keyword artifact_versions: The proxy artifact overview properties. + :paramtype artifact_versions: + list[~Microsoft.HybridNetwork.models.ProxyArtifactOverviewPropertiesValue] + """ + super().__init__(**kwargs) + self.artifact_versions = artifact_versions + + +class ProxyArtifactOverviewPropertiesValue(_serialization.Model): + """ProxyArtifactOverviewPropertiesValue. + + :ivar artifact_type: The artifact type. Known values are: "Unknown", "OCIArtifact", + "VhdImageFile", "ArmTemplate", and "ImageFile". + :vartype artifact_type: str or ~Microsoft.HybridNetwork.models.ArtifactType + :ivar artifact_version: The artifact version. + :vartype artifact_version: str + :ivar artifact_state: The artifact state. Known values are: "Unknown", "Preview", "Active", and + "Deprecated". + :vartype artifact_state: str or ~Microsoft.HybridNetwork.models.ArtifactState + """ + + _attribute_map = { + "artifact_type": {"key": "artifactType", "type": "str"}, + "artifact_version": {"key": "artifactVersion", "type": "str"}, + "artifact_state": {"key": "artifactState", "type": "str"}, + } + + def __init__( + self, + *, + artifact_type: Optional[Union[str, "_models.ArtifactType"]] = None, + artifact_version: Optional[str] = None, + artifact_state: Optional[Union[str, "_models.ArtifactState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword artifact_type: The artifact type. Known values are: "Unknown", "OCIArtifact", + "VhdImageFile", "ArmTemplate", and "ImageFile". + :paramtype artifact_type: str or ~Microsoft.HybridNetwork.models.ArtifactType + :keyword artifact_version: The artifact version. + :paramtype artifact_version: str + :keyword artifact_state: The artifact state. Known values are: "Unknown", "Preview", "Active", + and "Deprecated". + :paramtype artifact_state: str or ~Microsoft.HybridNetwork.models.ArtifactState + """ + super().__init__(**kwargs) + self.artifact_type = artifact_type + self.artifact_version = artifact_version + self.artifact_state = artifact_state + + +class ProxyArtifactVersionsListOverview(ProxyResource): + """The proxy artifact overview. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar properties: Proxy Artifact overview properties. + :vartype properties: ~Microsoft.HybridNetwork.models.ProxyArtifactOverviewPropertiesValue + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ProxyArtifactOverviewPropertiesValue"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.properties = None + + +class ProxyArtifactVersionsOverviewListResult(_serialization.Model): + """The proxy artifact list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of available proxy artifacts. + :vartype value: list[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ProxyArtifactVersionsListOverview]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ProxyArtifactVersionsListOverview"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of available proxy artifacts. + :paramtype value: list[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class Publisher(TrackedResource): + """publisher resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Publisher properties. + :vartype properties: ~Microsoft.HybridNetwork.models.PublisherPropertiesFormat + :ivar identity: The managed identity of the publisher, if configured. + :vartype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "PublisherPropertiesFormat"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.PublisherPropertiesFormat"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Publisher properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.PublisherPropertiesFormat + :keyword identity: The managed identity of the publisher, if configured. + :paramtype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + self.identity = identity + + +class PublisherListResult(_serialization.Model): + """A list of publishers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of publishers. + :vartype value: list[~Microsoft.HybridNetwork.models.Publisher] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Publisher]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Publisher"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of publishers. + :paramtype value: list[~Microsoft.HybridNetwork.models.Publisher] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class PublisherPropertiesFormat(_serialization.Model): + """publisher properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the publisher resource. Known values are: + "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", and + "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar scope: The publisher scope. Known values are: "Unknown" and "Private". + :vartype scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + } + + def __init__(self, *, scope: Optional[Union[str, "_models.PublisherScope"]] = None, **kwargs: Any) -> None: + """ + :keyword scope: The publisher scope. Known values are: "Unknown" and "Private". + :paramtype scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.scope = scope + + +class ReferencedResource(_serialization.Model): + """Reference to another resource. + + :ivar id: Resource ID. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class ReplicaSet(_serialization.Model): + """Helm ReplicaSet status properties. + + :ivar name: The name of the replicaSet. + :vartype name: str + :ivar namespace: The namespace of the replicaSet. + :vartype namespace: str + :ivar desired: Desired number of pods. + :vartype desired: int + :ivar ready: Number of ready pods. + :vartype ready: int + :ivar current: Number of current pods. + :vartype current: int + :ivar creation_time: Creation Time of replicaSet. + :vartype creation_time: ~datetime.datetime + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "desired": {"key": "desired", "type": "int"}, + "ready": {"key": "ready", "type": "int"}, + "current": {"key": "current", "type": "int"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + desired: Optional[int] = None, + ready: Optional[int] = None, + current: Optional[int] = None, + creation_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the replicaSet. + :paramtype name: str + :keyword namespace: The namespace of the replicaSet. + :paramtype namespace: str + :keyword desired: Desired number of pods. + :paramtype desired: int + :keyword ready: Number of ready pods. + :paramtype ready: int + :keyword current: Number of current pods. + :paramtype current: int + :keyword creation_time: Creation Time of replicaSet. + :paramtype creation_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.desired = desired + self.ready = ready + self.current = current + self.creation_time = creation_time + + +class RequestMetadata(_serialization.Model): + """Request metadata of execute request post call payload. + + All required parameters must be populated in order to send to Azure. + + :ivar relative_path: The relative path of the request. Required. + :vartype relative_path: str + :ivar http_method: The http method of the request. Required. Known values are: "Unknown", + "Post", "Put", "Get", "Patch", and "Delete". + :vartype http_method: str or ~Microsoft.HybridNetwork.models.HttpMethod + :ivar serialized_body: The serialized body of the request. Required. + :vartype serialized_body: str + :ivar api_version: The api version of the request. + :vartype api_version: str + """ + + _validation = { + "relative_path": {"required": True}, + "http_method": {"required": True}, + "serialized_body": {"required": True}, + } + + _attribute_map = { + "relative_path": {"key": "relativePath", "type": "str"}, + "http_method": {"key": "httpMethod", "type": "str"}, + "serialized_body": {"key": "serializedBody", "type": "str"}, + "api_version": {"key": "apiVersion", "type": "str"}, + } + + def __init__( + self, + *, + relative_path: str, + http_method: Union[str, "_models.HttpMethod"], + serialized_body: str, + api_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword relative_path: The relative path of the request. Required. + :paramtype relative_path: str + :keyword http_method: The http method of the request. Required. Known values are: "Unknown", + "Post", "Put", "Get", "Patch", and "Delete". + :paramtype http_method: str or ~Microsoft.HybridNetwork.models.HttpMethod + :keyword serialized_body: The serialized body of the request. Required. + :paramtype serialized_body: str + :keyword api_version: The api version of the request. + :paramtype api_version: str + """ + super().__init__(**kwargs) + self.relative_path = relative_path + self.http_method = http_method + self.serialized_body = serialized_body + self.api_version = api_version + + +class Resources(_serialization.Model): + """The resources of the network function component. + + :ivar deployments: Deployments that are related to component resource. + :vartype deployments: list[~Microsoft.HybridNetwork.models.Deployment] + :ivar pods: Pods related to component resource. + :vartype pods: list[~Microsoft.HybridNetwork.models.Pod] + :ivar replica_sets: Replica sets related to component resource. + :vartype replica_sets: list[~Microsoft.HybridNetwork.models.ReplicaSet] + :ivar stateful_sets: Stateful sets related to component resource. + :vartype stateful_sets: list[~Microsoft.HybridNetwork.models.StatefulSet] + :ivar daemon_sets: Daemonsets related to component resource. + :vartype daemon_sets: list[~Microsoft.HybridNetwork.models.DaemonSet] + """ + + _attribute_map = { + "deployments": {"key": "deployments", "type": "[Deployment]"}, + "pods": {"key": "pods", "type": "[Pod]"}, + "replica_sets": {"key": "replicaSets", "type": "[ReplicaSet]"}, + "stateful_sets": {"key": "statefulSets", "type": "[StatefulSet]"}, + "daemon_sets": {"key": "daemonSets", "type": "[DaemonSet]"}, + } + + def __init__( + self, + *, + deployments: Optional[List["_models.Deployment"]] = None, + pods: Optional[List["_models.Pod"]] = None, + replica_sets: Optional[List["_models.ReplicaSet"]] = None, + stateful_sets: Optional[List["_models.StatefulSet"]] = None, + daemon_sets: Optional[List["_models.DaemonSet"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword deployments: Deployments that are related to component resource. + :paramtype deployments: list[~Microsoft.HybridNetwork.models.Deployment] + :keyword pods: Pods related to component resource. + :paramtype pods: list[~Microsoft.HybridNetwork.models.Pod] + :keyword replica_sets: Replica sets related to component resource. + :paramtype replica_sets: list[~Microsoft.HybridNetwork.models.ReplicaSet] + :keyword stateful_sets: Stateful sets related to component resource. + :paramtype stateful_sets: list[~Microsoft.HybridNetwork.models.StatefulSet] + :keyword daemon_sets: Daemonsets related to component resource. + :paramtype daemon_sets: list[~Microsoft.HybridNetwork.models.DaemonSet] + """ + super().__init__(**kwargs) + self.deployments = deployments + self.pods = pods + self.replica_sets = replica_sets + self.stateful_sets = stateful_sets + self.daemon_sets = daemon_sets + + +class SecretDeploymentResourceReference(DeploymentResourceIdReference): + """Secret deployment resource id reference. + + All required parameters must be populated in order to send to Azure. + + :ivar id_type: The resource reference arm id type. Known values are: "Unknown", "Open", and + "Secret". + :vartype id_type: str or ~Microsoft.HybridNetwork.models.IdType + :ivar id: Resource ID. + :vartype id: str + """ + + _validation = { + "id_type": {"required": True}, + } + + _attribute_map = { + "id_type": {"key": "idType", "type": "str"}, + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource ID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id_type: str = "Secret" + self.id = id + + +class Site(TrackedResource): + """Site resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Site properties. + :vartype properties: ~Microsoft.HybridNetwork.models.SitePropertiesFormat + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "SitePropertiesFormat"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.SitePropertiesFormat"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Site properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.SitePropertiesFormat + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class SiteListResult(_serialization.Model): + """Response for sites API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of sites in a resource group. + :vartype value: list[~Microsoft.HybridNetwork.models.Site] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Site]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Site"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of sites in a resource group. + :paramtype value: list[~Microsoft.HybridNetwork.models.Site] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class SiteNetworkService(TrackedResource): + """Site network service resource. + + 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}. # pylint: disable=line-too-long + :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 + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~Microsoft.HybridNetwork.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Site network service properties. + :vartype properties: ~Microsoft.HybridNetwork.models.SiteNetworkServicePropertiesFormat + :ivar identity: The managed identity of the Site network service, if configured. + :vartype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + :ivar sku: Sku of the site network service. + :vartype sku: ~Microsoft.HybridNetwork.models.Sku + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "SiteNetworkServicePropertiesFormat"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "sku": {"key": "sku", "type": "Sku"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.SiteNetworkServicePropertiesFormat"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + sku: Optional["_models.Sku"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Site network service properties. + :paramtype properties: ~Microsoft.HybridNetwork.models.SiteNetworkServicePropertiesFormat + :keyword identity: The managed identity of the Site network service, if configured. + :paramtype identity: ~Microsoft.HybridNetwork.models.ManagedServiceIdentity + :keyword sku: Sku of the site network service. + :paramtype sku: ~Microsoft.HybridNetwork.models.Sku + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + self.identity = identity + self.sku = sku + + +class SiteNetworkServiceListResult(_serialization.Model): + """Response for site network services API service call. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A list of site network services in a resource group. + :vartype value: list[~Microsoft.HybridNetwork.models.SiteNetworkService] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SiteNetworkService]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.SiteNetworkService"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of site network services in a resource group. + :paramtype value: list[~Microsoft.HybridNetwork.models.SiteNetworkService] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class SiteNetworkServicePropertiesFormat(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Site network service properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the site network service resource. Known + values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", "Canceled", "Deleted", + and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar managed_resource_group_configuration: Managed resource group configuration. + :vartype managed_resource_group_configuration: + ~Microsoft.HybridNetwork.models.ManagedResourceGroupConfiguration + :ivar site_reference: The site details. + :vartype site_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + :ivar publisher_name: The publisher name for the site network service. + :vartype publisher_name: str + :ivar publisher_scope: The scope of the publisher. Known values are: "Unknown" and "Private". + :vartype publisher_scope: str or ~Microsoft.HybridNetwork.models.PublisherScope + :ivar network_service_design_group_name: The network service design group name for the site + network service. + :vartype network_service_design_group_name: str + :ivar network_service_design_version_name: The network service design version for the site + network service. + :vartype network_service_design_version_name: str + :ivar network_service_design_version_offering_location: The location of the network service + design offering. + :vartype network_service_design_version_offering_location: str + :ivar network_service_design_version_resource_reference: The network service design version + resource reference. + :vartype network_service_design_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :ivar desired_state_configuration_group_value_references: The goal state of the site network + service resource. This has references to the configuration group value objects that describe + the desired state of the site network service. + :vartype desired_state_configuration_group_value_references: dict[str, + ~Microsoft.HybridNetwork.models.ReferencedResource] + :ivar last_state_network_service_design_version_name: The network service design version for + the site network service. + :vartype last_state_network_service_design_version_name: str + :ivar last_state_configuration_group_value_references: The last state of the site network + service resource. + :vartype last_state_configuration_group_value_references: dict[str, + ~Microsoft.HybridNetwork.models.ReferencedResource] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "publisher_name": {"readonly": True}, + "publisher_scope": {"readonly": True}, + "network_service_design_group_name": {"readonly": True}, + "network_service_design_version_name": {"readonly": True}, + "network_service_design_version_offering_location": {"readonly": True}, + "last_state_network_service_design_version_name": {"readonly": True}, + "last_state_configuration_group_value_references": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "managed_resource_group_configuration": { + "key": "managedResourceGroupConfiguration", + "type": "ManagedResourceGroupConfiguration", + }, + "site_reference": {"key": "siteReference", "type": "ReferencedResource"}, + "publisher_name": {"key": "publisherName", "type": "str"}, + "publisher_scope": {"key": "publisherScope", "type": "str"}, + "network_service_design_group_name": {"key": "networkServiceDesignGroupName", "type": "str"}, + "network_service_design_version_name": {"key": "networkServiceDesignVersionName", "type": "str"}, + "network_service_design_version_offering_location": { + "key": "networkServiceDesignVersionOfferingLocation", + "type": "str", + }, + "network_service_design_version_resource_reference": { + "key": "networkServiceDesignVersionResourceReference", + "type": "DeploymentResourceIdReference", + }, + "desired_state_configuration_group_value_references": { + "key": "desiredStateConfigurationGroupValueReferences", + "type": "{ReferencedResource}", + }, + "last_state_network_service_design_version_name": { + "key": "lastStateNetworkServiceDesignVersionName", + "type": "str", + }, + "last_state_configuration_group_value_references": { + "key": "lastStateConfigurationGroupValueReferences", + "type": "{ReferencedResource}", + }, + } + + def __init__( + self, + *, + managed_resource_group_configuration: Optional["_models.ManagedResourceGroupConfiguration"] = None, + site_reference: Optional["_models.ReferencedResource"] = None, + network_service_design_version_resource_reference: Optional["_models.DeploymentResourceIdReference"] = None, + desired_state_configuration_group_value_references: Optional[Dict[str, "_models.ReferencedResource"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword managed_resource_group_configuration: Managed resource group configuration. + :paramtype managed_resource_group_configuration: + ~Microsoft.HybridNetwork.models.ManagedResourceGroupConfiguration + :keyword site_reference: The site details. + :paramtype site_reference: ~Microsoft.HybridNetwork.models.ReferencedResource + :keyword network_service_design_version_resource_reference: The network service design version + resource reference. + :paramtype network_service_design_version_resource_reference: + ~Microsoft.HybridNetwork.models.DeploymentResourceIdReference + :keyword desired_state_configuration_group_value_references: The goal state of the site network + service resource. This has references to the configuration group value objects that describe + the desired state of the site network service. + :paramtype desired_state_configuration_group_value_references: dict[str, + ~Microsoft.HybridNetwork.models.ReferencedResource] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.managed_resource_group_configuration = managed_resource_group_configuration + self.site_reference = site_reference + self.publisher_name = None + self.publisher_scope = None + self.network_service_design_group_name = None + self.network_service_design_version_name = None + self.network_service_design_version_offering_location = None + self.network_service_design_version_resource_reference = network_service_design_version_resource_reference + self.desired_state_configuration_group_value_references = desired_state_configuration_group_value_references + self.last_state_network_service_design_version_name = None + self.last_state_configuration_group_value_references = None + + +class SitePropertiesFormat(_serialization.Model): + """Site properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The provisioning state of the site resource. **TODO**\ : Confirm if + this is needed. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar nfvis: List of NFVIs. + :vartype nfvis: list[~Microsoft.HybridNetwork.models.NFVIs] + :ivar site_network_service_references: The list of site network services on the site. + :vartype site_network_service_references: + list[~Microsoft.HybridNetwork.models.ReferencedResource] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "site_network_service_references": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "nfvis": {"key": "nfvis", "type": "[NFVIs]"}, + "site_network_service_references": {"key": "siteNetworkServiceReferences", "type": "[ReferencedResource]"}, + } + + def __init__(self, *, nfvis: Optional[List["_models.NFVIs"]] = None, **kwargs: Any) -> None: + """ + :keyword nfvis: List of NFVIs. + :paramtype nfvis: list[~Microsoft.HybridNetwork.models.NFVIs] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.nfvis = nfvis + self.site_network_service_references = None + + +class Sku(_serialization.Model): + """Sku, to be associated with a SiteNetworkService. + + 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 name: Name of this Sku. Required. Known values are: "Basic" and "Standard". + :vartype name: str or ~Microsoft.HybridNetwork.models.SkuName + :ivar tier: The SKU tier based on the SKU name. Known values are: "Basic" and "Standard". + :vartype tier: str or ~Microsoft.HybridNetwork.models.SkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: + """ + :keyword name: Name of this Sku. Required. Known values are: "Basic" and "Standard". + :paramtype name: str or ~Microsoft.HybridNetwork.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class StatefulSet(_serialization.Model): + """Helm StatefulSet status properties. + + :ivar name: The name of the statefulset. + :vartype name: str + :ivar namespace: The namespace of the statefulset. + :vartype namespace: str + :ivar desired: Desired number of pods. + :vartype desired: int + :ivar ready: Number of ready pods. + :vartype ready: int + :ivar creation_time: Creation Time of statefulset. + :vartype creation_time: ~datetime.datetime + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "desired": {"key": "desired", "type": "int"}, + "ready": {"key": "ready", "type": "int"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + desired: Optional[int] = None, + ready: Optional[int] = None, + creation_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the statefulset. + :paramtype name: str + :keyword namespace: The namespace of the statefulset. + :paramtype namespace: str + :keyword desired: Desired number of pods. + :paramtype desired: int + :keyword ready: Number of ready pods. + :paramtype ready: int + :keyword creation_time: Creation Time of statefulset. + :paramtype creation_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.desired = desired + self.ready = ready + self.creation_time = creation_time + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :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. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~Microsoft.HybridNetwork.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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~Microsoft.HybridNetwork.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype 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, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :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. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~Microsoft.HybridNetwork.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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~Microsoft.HybridNetwork.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsObject(_serialization.Model): + """Tags object for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class UserAssignedIdentity(_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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class VhdImageArtifactProfile(_serialization.Model): + """Vhd artifact profile. + + :ivar vhd_name: Vhd name. + :vartype vhd_name: str + :ivar vhd_version: Vhd version. + :vartype vhd_version: str + """ + + _attribute_map = { + "vhd_name": {"key": "vhdName", "type": "str"}, + "vhd_version": {"key": "vhdVersion", "type": "str"}, + } + + def __init__(self, *, vhd_name: Optional[str] = None, vhd_version: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword vhd_name: Vhd name. + :paramtype vhd_name: str + :keyword vhd_version: Vhd version. + :paramtype vhd_version: str + """ + super().__init__(**kwargs) + self.vhd_name = vhd_name + self.vhd_version = vhd_version + + +class VhdImageMappingRuleProfile(_serialization.Model): + """Vhd mapping rule profile. + + :ivar user_configuration: List of values. + :vartype user_configuration: str + """ + + _attribute_map = { + "user_configuration": {"key": "userConfiguration", "type": "str"}, + } + + def __init__(self, *, user_configuration: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword user_configuration: List of values. + :paramtype user_configuration: str + """ + super().__init__(**kwargs) + self.user_configuration = user_configuration + + +class VirtualNetworkFunctionDefinitionVersion(NetworkFunctionDefinitionVersionPropertiesFormat): + """Virtual network function network function definition version properties. + + 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 provisioning_state: The provisioning state of the network function definition version + resource. Known values are: "Unknown", "Succeeded", "Accepted", "Deleting", "Failed", + "Canceled", "Deleted", and "Converging". + :vartype provisioning_state: str or ~Microsoft.HybridNetwork.models.ProvisioningState + :ivar version_state: The network function definition version state. Known values are: + "Unknown", "Preview", "Active", "Deprecated", "Validating", and "ValidationFailed". + :vartype version_state: str or ~Microsoft.HybridNetwork.models.VersionState + :ivar description: The network function definition version description. + :vartype description: str + :ivar deploy_parameters: The deployment parameters of the network function definition version. + :vartype deploy_parameters: str + :ivar network_function_type: The network function type. Required. Known values are: "Unknown", + "VirtualNetworkFunction", and "ContainerizedNetworkFunction". + :vartype network_function_type: str or ~Microsoft.HybridNetwork.models.NetworkFunctionType + :ivar network_function_template: Virtual network function template. + :vartype network_function_template: + ~Microsoft.HybridNetwork.models.VirtualNetworkFunctionTemplate + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "version_state": {"readonly": True}, + "network_function_type": {"required": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "version_state": {"key": "versionState", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "deploy_parameters": {"key": "deployParameters", "type": "str"}, + "network_function_type": {"key": "networkFunctionType", "type": "str"}, + "network_function_template": {"key": "networkFunctionTemplate", "type": "VirtualNetworkFunctionTemplate"}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + deploy_parameters: Optional[str] = None, + network_function_template: Optional["_models.VirtualNetworkFunctionTemplate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword description: The network function definition version description. + :paramtype description: str + :keyword deploy_parameters: The deployment parameters of the network function definition + version. + :paramtype deploy_parameters: str + :keyword network_function_template: Virtual network function template. + :paramtype network_function_template: + ~Microsoft.HybridNetwork.models.VirtualNetworkFunctionTemplate + """ + super().__init__(description=description, deploy_parameters=deploy_parameters, **kwargs) + self.network_function_type: str = "VirtualNetworkFunction" + self.network_function_template = network_function_template diff --git a/src/aosm/azext_aosm/vendored_sdks/models/_patch.py b/src/aosm/azext_aosm/vendored_sdks/models/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/aosm/azext_aosm/vendored_sdks/operations/__init__.py b/src/aosm/azext_aosm/vendored_sdks/operations/__init__.py new file mode 100644 index 00000000000..a874bdde6c9 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/operations/__init__.py @@ -0,0 +1,47 @@ +# 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 ._operations import ConfigurationGroupSchemasOperations +from ._operations import ConfigurationGroupValuesOperations +from ._operations import NetworkFunctionsOperations +from ._operations import ComponentsOperations +from ._operations import NetworkFunctionDefinitionGroupsOperations +from ._operations import NetworkFunctionDefinitionVersionsOperations +from ._operations import NetworkServiceDesignGroupsOperations +from ._operations import NetworkServiceDesignVersionsOperations +from ._operations import Operations +from ._operations import PublishersOperations +from ._operations import ArtifactStoresOperations +from ._operations import ArtifactManifestsOperations +from ._operations import ProxyArtifactOperations +from ._operations import SitesOperations +from ._operations import SiteNetworkServicesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ConfigurationGroupSchemasOperations", + "ConfigurationGroupValuesOperations", + "NetworkFunctionsOperations", + "ComponentsOperations", + "NetworkFunctionDefinitionGroupsOperations", + "NetworkFunctionDefinitionVersionsOperations", + "NetworkServiceDesignGroupsOperations", + "NetworkServiceDesignVersionsOperations", + "Operations", + "PublishersOperations", + "ArtifactStoresOperations", + "ArtifactManifestsOperations", + "ProxyArtifactOperations", + "SitesOperations", + "SiteNetworkServicesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/src/aosm/azext_aosm/vendored_sdks/operations/_operations.py b/src/aosm/azext_aosm/vendored_sdks/operations/_operations.py new file mode 100644 index 00000000000..40e0052ee6f --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/operations/_operations.py @@ -0,0 +1,13313 @@ +# pylint: disable=too-many-lines +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_configuration_group_schemas_list_by_publisher_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_schemas_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas/{configurationGroupSchemaName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "configurationGroupSchemaName": _SERIALIZER.url( + "configuration_group_schema_name", + configuration_group_schema_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_schemas_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas/{configurationGroupSchemaName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "configurationGroupSchemaName": _SERIALIZER.url( + "configuration_group_schema_name", + configuration_group_schema_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_schemas_get_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas/{configurationGroupSchemaName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "configurationGroupSchemaName": _SERIALIZER.url( + "configuration_group_schema_name", + configuration_group_schema_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_schemas_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas/{configurationGroupSchemaName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "configurationGroupSchemaName": _SERIALIZER.url( + "configuration_group_schema_name", + configuration_group_schema_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_schemas_update_state_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/configurationGroupSchemas/{configurationGroupSchemaName}/updateState" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "configurationGroupSchemaName": _SERIALIZER.url( + "configuration_group_schema_name", + configuration_group_schema_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_delete_request( # pylint: disable=name-too-long + resource_group_name: str, configuration_group_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/configurationGroupValues/{configurationGroupValueName}" # pylint: disable=line-too-long + 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 + ), + "configurationGroupValueName": _SERIALIZER.url( + "configuration_group_value_name", + configuration_group_value_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_get_request( # pylint: disable=name-too-long + resource_group_name: str, configuration_group_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/configurationGroupValues/{configurationGroupValueName}" # pylint: disable=line-too-long + 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 + ), + "configurationGroupValueName": _SERIALIZER.url( + "configuration_group_value_name", + configuration_group_value_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, configuration_group_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/configurationGroupValues/{configurationGroupValueName}" # pylint: disable=line-too-long + 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 + ), + "configurationGroupValueName": _SERIALIZER.url( + "configuration_group_value_name", + configuration_group_value_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_update_tags_request( # pylint: disable=name-too-long + resource_group_name: str, configuration_group_value_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/configurationGroupValues/{configurationGroupValueName}" # pylint: disable=line-too-long + 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 + ), + "configurationGroupValueName": _SERIALIZER.url( + "configuration_group_value_name", + configuration_group_value_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/configurationGroupValues" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_configuration_group_values_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/configurationGroupValues" # pylint: disable=line-too-long + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_delete_request( + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url( + "network_function_name", network_function_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_get_request( + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_update_tags_request( # pylint: disable=name-too-long + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url("network_function_name", network_function_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/networkFunctions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions" # pylint: disable=line-too-long + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_functions_execute_request_request( # pylint: disable=name-too-long + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/executeRequest" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url( + "network_function_name", network_function_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_components_get_request( + resource_group_name: str, network_function_name: str, component_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/components/{componentName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "networkFunctionName": _SERIALIZER.url( + "network_function_name", network_function_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "componentName": _SERIALIZER.url( + "component_name", component_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_components_list_by_network_function_request( # pylint: disable=name-too-long + resource_group_name: str, network_function_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/networkFunctions/{networkFunctionName}/components" # pylint: disable=line-too-long + 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), + "networkFunctionName": _SERIALIZER.url( + "network_function_name", network_function_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_groups_list_by_publisher_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_groups_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions/{networkFunctionDefinitionVersionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkFunctionDefinitionVersionName": _SERIALIZER.url( + "network_function_definition_version_name", + network_function_definition_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions/{networkFunctionDefinitionVersionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkFunctionDefinitionVersionName": _SERIALIZER.url( + "network_function_definition_version_name", + network_function_definition_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions/{networkFunctionDefinitionVersionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkFunctionDefinitionVersionName": _SERIALIZER.url( + "network_function_definition_version_name", + network_function_definition_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions/{networkFunctionDefinitionVersionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkFunctionDefinitionVersionName": _SERIALIZER.url( + "network_function_definition_version_name", + network_function_definition_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_list_by_network_function_definition_group_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_function_definition_versions_update_state_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkFunctionDefinitionGroups/{networkFunctionDefinitionGroupName}/networkFunctionDefinitionVersions/{networkFunctionDefinitionVersionName}/updateState" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkFunctionDefinitionGroupName": _SERIALIZER.url( + "network_function_definition_group_name", + network_function_definition_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkFunctionDefinitionVersionName": _SERIALIZER.url( + "network_function_definition_version_name", + network_function_definition_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_groups_list_by_publisher_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_groups_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions/{networkServiceDesignVersionName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkServiceDesignVersionName": _SERIALIZER.url( + "network_service_design_version_name", + network_service_design_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions/{networkServiceDesignVersionName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkServiceDesignVersionName": _SERIALIZER.url( + "network_service_design_version_name", + network_service_design_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions/{networkServiceDesignVersionName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkServiceDesignVersionName": _SERIALIZER.url( + "network_service_design_version_name", + network_service_design_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions/{networkServiceDesignVersionName}" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkServiceDesignVersionName": _SERIALIZER.url( + "network_service_design_version_name", + network_service_design_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_list_by_network_service_design_group_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_service_design_versions_update_state_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/networkServiceDesignGroups/{networkServiceDesignGroupName}/networkServiceDesignVersions/{networkServiceDesignVersionName}/updateState" # pylint: disable=line-too-long + 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 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "networkServiceDesignGroupName": _SERIALIZER.url( + "network_service_design_group_name", + network_service_design_group_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + "networkServiceDesignVersionName": _SERIALIZER.url( + "network_service_design_version_name", + network_service_design_version_name, + "str", + max_length=64, + pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operations_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.HybridNetwork/operations" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/publishers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers" + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_delete_request( + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_get_request( + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_publishers_update_request( + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_stores_list_by_publisher_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_stores_delete_request( + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_stores_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_stores_get_request( + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_stores_update_request( + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_list_by_artifact_store_request( # pylint: disable=name-too-long + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_delete_request( + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_get_request( + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_update_request( + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_list_credential_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}/listCredential" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_artifact_manifests_update_state_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactManifests/{artifactManifestName}/updateState" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactManifestName": _SERIALIZER.url( + "artifact_manifest_name", artifact_manifest_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_proxy_artifact_list_request( + resource_group_name: str, publisher_name: str, artifact_store_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifacts" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_proxy_artifact_get_request( + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + subscription_id: str, + *, + artifact_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactVersions" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["artifactName"] = _SERIALIZER.query( + "artifact_name", artifact_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_proxy_artifact_update_state_request( # pylint: disable=name-too-long + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + subscription_id: str, + *, + artifact_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/publishers/{publisherName}/artifactStores/{artifactStoreName}/artifactVersions/{artifactVersionName}" # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publisherName": _SERIALIZER.url( + "publisher_name", publisher_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactStoreName": _SERIALIZER.url( + "artifact_store_name", artifact_store_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + "artifactVersionName": _SERIALIZER.url( + "artifact_version_name", artifact_version_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["artifactName"] = _SERIALIZER.query( + "artifact_name", artifact_name, "str", max_length=64, pattern=r"^[^\s]*[^\s]+[^\s]*$" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_delete_request( + resource_group_name: str, site_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/sites/{siteName}" # pylint: disable=line-too-long + 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 + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_get_request( + resource_group_name: str, site_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/sites/{siteName}" # pylint: disable=line-too-long + 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 + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_create_or_update_request( + resource_group_name: str, site_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/sites/{siteName}" # pylint: disable=line-too-long + 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 + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_update_tags_request( + resource_group_name: str, site_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/sites/{siteName}" # pylint: disable=line-too-long + 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 + ), + "siteName": _SERIALIZER.url( + "site_name", site_name, "str", max_length=64, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/sites" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sites_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/sites" + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_delete_request( # pylint: disable=name-too-long + resource_group_name: str, site_network_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/siteNetworkServices/{siteNetworkServiceName}" # pylint: disable=line-too-long + 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 + ), + "siteNetworkServiceName": _SERIALIZER.url( + "site_network_service_name", + site_network_service_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_get_request( + resource_group_name: str, site_network_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/siteNetworkServices/{siteNetworkServiceName}" # pylint: disable=line-too-long + 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 + ), + "siteNetworkServiceName": _SERIALIZER.url( + "site_network_service_name", + site_network_service_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, site_network_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/siteNetworkServices/{siteNetworkServiceName}" # pylint: disable=line-too-long + 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 + ), + "siteNetworkServiceName": _SERIALIZER.url( + "site_network_service_name", + site_network_service_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_update_tags_request( # pylint: disable=name-too-long + resource_group_name: str, site_network_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/siteNetworkServices/{siteNetworkServiceName}" # pylint: disable=line-too-long + 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 + ), + "siteNetworkServiceName": _SERIALIZER.url( + "site_network_service_name", + site_network_service_name, + "str", + max_length=64, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9_-]*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/siteNetworkServices" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_site_network_services_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/siteNetworkServices" # pylint: disable=line-too-long + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigurationGroupSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`configuration_group_schemas` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationGroupSchema"]: + """Gets information of the configuration group schemas under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of ConfigurationGroupSchema + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupSchemaListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_schemas_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupSchemaListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_configuration_group_schemas_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specified configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchema, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupSchema") + + request = build_configuration_group_schemas_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.ConfigurationGroupSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchema + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchema + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchema, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchema]: + """Creates or updates a configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update configuration group schema + resource. Is either a ConfigurationGroupSchema type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchema + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, publisher_name: str, configuration_group_schema_name: str, **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Gets information about the specified configuration group schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + request = build_configuration_group_schemas_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupSchema: + """Updates a configuration group schema resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ConfigurationGroupSchema + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_configuration_group_schemas_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupSchema", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchemaVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.ConfigurationGroupSchemaVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ConfigurationGroupSchemaVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupSchemaVersionUpdateState") + + request = build_configuration_group_schemas_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupSchemaVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: _models.ConfigurationGroupSchemaVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + configuration_group_schema_name: str, + parameters: Union[_models.ConfigurationGroupSchemaVersionUpdateState, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupSchemaVersionUpdateState]: + """Update configuration group schema state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param configuration_group_schema_name: The name of the configuration group schema. Required. + :type configuration_group_schema_name: str + :param parameters: Parameters supplied to update the state of configuration group schema. Is + either a ConfigurationGroupSchemaVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupSchemaVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupSchemaVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupSchemaVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + configuration_group_schema_name=configuration_group_schema_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupSchemaVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ConfigurationGroupValuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`configuration_group_values` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_configuration_group_values_delete_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, configuration_group_value_name: str, **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Gets information about the specified hybrid configuration group values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + request = build_configuration_group_values_get_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _create_or_update_initial( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.ConfigurationGroupValue, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ConfigurationGroupValue") + + request = build_configuration_group_values_create_or_update_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: _models.ConfigurationGroupValue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupValue + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupValue + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.ConfigurationGroupValue, IO], + **kwargs: Any + ) -> LROPoller[_models.ConfigurationGroupValue]: + """Creates or updates a hybrid configuration group value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to the create or update configuration group value + resource. Is either a ConfigurationGroupValue type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ConfigurationGroupValue + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + configuration_group_value_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ConfigurationGroupValue: + """Updates a hybrid configuration group tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param configuration_group_value_name: The name of the configuration group value. Required. + :type configuration_group_value_name: str + :param parameters: Parameters supplied to update configuration group values tags. Is either a + TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ConfigurationGroupValue + :rtype: ~Microsoft.HybridNetwork.models.ConfigurationGroupValue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConfigurationGroupValue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_configuration_group_values_update_tags_request( + resource_group_name=resource_group_name, + configuration_group_value_name=configuration_group_value_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ConfigurationGroupValue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ConfigurationGroupValue"]: + """Lists all sites in the configuration group value in a subscription. + + :return: An iterator like instance of ConfigurationGroupValue + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupValueListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_values_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupValueListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ConfigurationGroupValue"]: + """Lists all the hybrid network configurationGroupValues in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of ConfigurationGroupValue + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ConfigurationGroupValue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ConfigurationGroupValueListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_configuration_group_values_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ConfigurationGroupValueListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + +class NetworkFunctionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`network_functions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, network_function_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_functions_delete_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete(self, resource_group_name: str, network_function_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, network_function_name: str, **kwargs: Any) -> _models.NetworkFunction: + """Gets information about the specified network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function resource. Required. + :type network_function_name: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + request = build_network_functions_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _create_or_update_initial( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.NetworkFunction, IO], + **kwargs: Any + ) -> _models.NetworkFunction: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunction") + + request = build_network_functions_create_or_update_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.NetworkFunction, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunction + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.NetworkFunction, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkFunction]: + """Creates or updates a network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied in the body to the create or update network function + operation. Is either a NetworkFunction type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunction or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunction + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunction", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunction: + """Updates the tags for the network function resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: Resource name for the network function resource. Required. + :type network_function_name: str + :param parameters: Parameters supplied to the update network function tags operation. Is either + a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunction + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunction] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_functions_update_tags_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunction", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NetworkFunction"]: + """Lists all the network functions in a subscription. + + :return: An iterator like instance of NetworkFunction + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.NetworkFunctionListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_functions_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NetworkFunction"]: + """Lists all the network function resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of NetworkFunction + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkFunction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.NetworkFunctionListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_functions_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _execute_request_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.ExecuteRequestParameters, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExecuteRequestParameters") + + request = build_network_functions_execute_request_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @overload + def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: _models.ExecuteRequestParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ExecuteRequestParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_execute_request( + self, + resource_group_name: str, + network_function_name: str, + parameters: Union[_models.ExecuteRequestParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Execute a request to services on a containerized network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param parameters: Payload for execute request post call. Is either a ExecuteRequestParameters + type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ExecuteRequestParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._execute_request_initial( # type: ignore + resource_group_name=resource_group_name, + network_function_name=network_function_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, network_function_name: str, component_name: str, **kwargs: Any + ) -> _models.Component: + """Gets information about the specified application instance resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :param component_name: The name of the component. Required. + :type component_name: str + :return: Component + :rtype: ~Microsoft.HybridNetwork.models.Component + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Component] = kwargs.pop("cls", None) + + request = build_components_get_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Component", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_function( + self, resource_group_name: str, network_function_name: str, **kwargs: Any + ) -> Iterable["_models.Component"]: + """Lists all the component resources in a network function. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param network_function_name: The name of the network function. Required. + :type network_function_name: str + :return: An iterator like instance of Component + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Component] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ComponentListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_components_list_by_network_function_request( + resource_group_name=resource_group_name, + network_function_name=network_function_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ComponentListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + +class NetworkFunctionDefinitionGroupsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`network_function_definition_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkFunctionDefinitionGroup"]: + """Gets information of the network function definition groups under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkFunctionDefinitionGroupListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_function_definition_groups_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionDefinitionGroupListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_function_definition_groups_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specified network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.NetworkFunctionDefinitionGroup, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionGroup") + + request = build_network_function_definition_groups_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: _models.NetworkFunctionDefinitionGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.NetworkFunctionDefinitionGroup, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionGroup]: + """Creates or updates a network function definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Is either a NetworkFunctionDefinitionGroup type or a IO type. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Gets information about the specified networkFunctionDefinition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + request = build_network_function_definition_groups_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionGroup: + """Updates a network function definition group resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param parameters: Parameters supplied to the create or update publisher network function + definition group operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunctionDefinitionGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_function_definition_groups_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NetworkFunctionDefinitionVersionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`network_function_definition_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_function_definition_versions_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersion, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionVersion") + + request = build_network_function_definition_versions_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.NetworkFunctionDefinitionVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersion, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersion]: + """Creates or updates a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Is either a NetworkFunctionDefinitionVersion type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Gets information about a network function definition version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + request = build_network_function_definition_versions_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkFunctionDefinitionVersion: + """Updates a network function definition version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to the create or update network function definition + version operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkFunctionDefinitionVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_function_definition_versions_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkFunctionDefinitionVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_function_definition_group( # pylint: disable=name-too-long + self, resource_group_name: str, publisher_name: str, network_function_definition_group_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkFunctionDefinitionVersion"]: + """Gets information about a list of network function definition versions under a network function + definition group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :return: An iterator like instance of NetworkFunctionDefinitionVersion + :rtype: + ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkFunctionDefinitionVersionListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_function_definition_versions_list_by_network_function_definition_group_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkFunctionDefinitionVersionListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.NetworkFunctionDefinitionVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NetworkFunctionDefinitionVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkFunctionDefinitionVersionUpdateState") + + request = build_network_function_definition_versions_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("NetworkFunctionDefinitionVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: _models.NetworkFunctionDefinitionVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_function_definition_group_name: str, + network_function_definition_version_name: str, + parameters: Union[_models.NetworkFunctionDefinitionVersionUpdateState, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkFunctionDefinitionVersionUpdateState]: + """Update network function definition version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_function_definition_group_name: The name of the network function definition + group. Required. + :type network_function_definition_group_name: str + :param network_function_definition_version_name: The name of the network function definition + version. The name should conform to the SemVer 2.0.0 specification: + https://semver.org/spec/v2.0.0.html. Required. + :type network_function_definition_version_name: str + :param parameters: Parameters supplied to update the state of network function definition + version. Is either a NetworkFunctionDefinitionVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkFunctionDefinitionVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkFunctionDefinitionVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkFunctionDefinitionVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_function_definition_group_name=network_function_definition_group_name, + network_function_definition_version_name=network_function_definition_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkFunctionDefinitionVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class NetworkServiceDesignGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`network_service_design_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkServiceDesignGroup"]: + """Gets information of the network service design groups under a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of NetworkServiceDesignGroup + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkServiceDesignGroupListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_service_design_groups_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkServiceDesignGroupListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_service_design_groups_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a specified network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.NetworkServiceDesignGroup, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignGroup") + + request = build_network_service_design_groups_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: _models.NetworkServiceDesignGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.NetworkServiceDesignGroup, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignGroup]: + """Creates or updates a network service design group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Is either a NetworkServiceDesignGroup type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignGroup + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Gets information about the specified networkServiceDesign group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + request = build_network_service_design_groups_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignGroup: + """Updates a network service design groups resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param parameters: Parameters supplied to the create or update publisher network service design + group operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkServiceDesignGroup + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_service_design_groups_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NetworkServiceDesignVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`network_service_design_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_network_service_design_versions_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersion, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignVersion") + + request = build_network_service_design_versions_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.NetworkServiceDesignVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersion, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersion]: + """Creates or updates a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a NetworkServiceDesignVersion type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersion + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Gets information about a network service design version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + request = build_network_service_design_versions_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.NetworkServiceDesignVersion: + """Updates a network service design version resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to the create or update network service design version + operation. Is either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: NetworkServiceDesignVersion + :rtype: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_network_service_design_versions_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("NetworkServiceDesignVersion", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_network_service_design_group( + self, resource_group_name: str, publisher_name: str, network_service_design_group_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkServiceDesignVersion"]: + """Gets information about a list of network service design versions under a network service design + group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :return: An iterator like instance of NetworkServiceDesignVersion + :rtype: + ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.NetworkServiceDesignVersionListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_network_service_design_versions_list_by_network_service_design_group_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.NetworkServiceDesignVersionListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersionUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.NetworkServiceDesignVersionUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NetworkServiceDesignVersionUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkServiceDesignVersionUpdateState") + + request = build_network_service_design_versions_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("NetworkServiceDesignVersionUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: _models.NetworkServiceDesignVersionUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + network_service_design_group_name: str, + network_service_design_version_name: str, + parameters: Union[_models.NetworkServiceDesignVersionUpdateState, IO], + **kwargs: Any + ) -> LROPoller[_models.NetworkServiceDesignVersionUpdateState]: + """Update network service design version state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param network_service_design_group_name: The name of the network service design group. + Required. + :type network_service_design_group_name: str + :param network_service_design_version_name: The name of the network service design version. The + name should conform to the SemVer 2.0.0 specification: https://semver.org/spec/v2.0.0.html. + Required. + :type network_service_design_version_name: str + :param parameters: Parameters supplied to update the state of network service design version. + Is either a NetworkServiceDesignVersionUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns NetworkServiceDesignVersionUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.NetworkServiceDesignVersionUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkServiceDesignVersionUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + network_service_design_group_name=network_service_design_group_name, + network_service_design_version_name=network_service_design_version_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkServiceDesignVersionUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Gets a list of the operations. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.OperationListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.OperationListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + +class PublishersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`publishers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Publisher"]: + """Lists all the publishers in a subscription. + + :return: An iterator like instance of Publisher + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.PublisherListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_publishers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.PublisherListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Publisher"]: + """Lists all the publishers in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Publisher + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.PublisherListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_publishers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.PublisherListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_publishers_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete(self, resource_group_name: str, publisher_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, publisher_name: str, **kwargs: Any) -> _models.Publisher: + """Gets information about the specified publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + request = build_publishers_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.Publisher, IO]] = None, + **kwargs: Any + ) -> _models.Publisher: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Publisher") + else: + _json = None + + request = build_publishers_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("Publisher", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[_models.Publisher] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: ~Microsoft.HybridNetwork.models.Publisher + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Publisher + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Publisher + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.Publisher, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.Publisher]: + """Creates or updates a publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Is either a Publisher + type or a IO type. Default value is None. + :type parameters: ~Microsoft.HybridNetwork.models.Publisher or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Publisher + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Publisher", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[_models.TagsObject] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Default value is + None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + parameters: Optional[Union[_models.TagsObject, IO]] = None, + **kwargs: Any + ) -> _models.Publisher: + """Update a publisher resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param parameters: Parameters supplied to the create publisher operation. Is either a + TagsObject type or a IO type. Default value is None. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: Publisher + :rtype: ~Microsoft.HybridNetwork.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "TagsObject") + else: + _json = None + + request = build_publishers_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Publisher", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ArtifactStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`artifact_stores` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, resource_group_name: str, publisher_name: str, **kwargs: Any + ) -> Iterable["_models.ArtifactStore"]: + """Gets information of the ArtifactStores under publisher. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :return: An iterator like instance of ArtifactStore + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ArtifactStoreListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_artifact_stores_list_by_publisher_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ArtifactStoreListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_artifact_stores_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.ArtifactStore, IO], + **kwargs: Any + ) -> _models.ArtifactStore: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactStore") + + request = build_artifact_stores_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: _models.ArtifactStore, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactStore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.ArtifactStore, IO], + **kwargs: Any + ) -> LROPoller[_models.ArtifactStore]: + """Creates or updates a artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. Is + either a ArtifactStore type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactStore or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactStore + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactStore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactStore", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> _models.ArtifactStore: + """Gets information about the specified artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + request = build_artifact_stores_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ArtifactStore: + """Update artifact store resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param parameters: Parameters supplied to the create or update application group operation. Is + either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ArtifactStore + :rtype: ~Microsoft.HybridNetwork.models.ArtifactStore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactStore] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_artifact_stores_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactStore", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ArtifactManifestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`artifact_manifests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_artifact_store( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> Iterable["_models.ArtifactManifest"]: + """Gets information about the artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: An iterator like instance of ArtifactManifest + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ArtifactManifestListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_artifact_manifests_list_by_artifact_store_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ArtifactManifestListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_artifact_manifests_delete_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifest, IO], + **kwargs: Any + ) -> _models.ArtifactManifest: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactManifest") + + request = build_artifact_manifests_create_or_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.ArtifactManifest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifest, IO], + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifest]: + """Creates or updates a artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. Is + either a ArtifactManifest type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifest + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> _models.ArtifactManifest: + """Gets information about a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + request = build_artifact_manifests_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.ArtifactManifest: + """Updates a artifact manifest resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to the create or update artifact manifest operation. Is + either a TagsObject type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: ArtifactManifest + :rtype: ~Microsoft.HybridNetwork.models.ArtifactManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_artifact_manifests_update_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactManifest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_credential( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + **kwargs: Any + ) -> _models.ArtifactAccessCredential: + """List credential for publishing artifacts defined in artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :return: ArtifactAccessCredential + :rtype: ~Microsoft.HybridNetwork.models.ArtifactAccessCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ArtifactAccessCredential] = kwargs.pop("cls", None) + + request = build_artifact_manifests_list_credential_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("ArtifactAccessCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifestUpdateState, IO], + **kwargs: Any + ) -> Optional[_models.ArtifactManifestUpdateState]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArtifactManifestUpdateState]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactManifestUpdateState") + + request = build_artifact_manifests_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ArtifactManifestUpdateState", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: _models.ArtifactManifestUpdateState, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_manifest_name: str, + parameters: Union[_models.ArtifactManifestUpdateState, IO], + **kwargs: Any + ) -> LROPoller[_models.ArtifactManifestUpdateState]: + """Update state for artifact manifest. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_manifest_name: The name of the artifact manifest. Required. + :type artifact_manifest_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Is either a + ArtifactManifestUpdateState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ArtifactManifestUpdateState + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ArtifactManifestUpdateState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArtifactManifestUpdateState] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_manifest_name=artifact_manifest_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArtifactManifestUpdateState", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ProxyArtifactOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`proxy_artifact` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, publisher_name: str, artifact_store_name: str, **kwargs: Any + ) -> Iterable["_models.ProxyArtifactListOverview"]: + """Lists all the available artifacts in the parent Artifact Store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :return: An iterator like instance of ProxyArtifactListOverview + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ProxyArtifactListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.ProxyArtifactOverviewListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_proxy_artifact_list_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ProxyArtifactOverviewListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def get( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + *, + artifact_name: str, + **kwargs: Any + ) -> Iterable["_models.ProxyArtifactVersionsListOverview"]: + """Get a Artifact overview information. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :return: An iterator like instance of ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[ + _models._models.ProxyArtifactVersionsOverviewListResult + ] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_proxy_artifact_get_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + subscription_id=self._config.subscription_id, + artifact_name=artifact_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.ProxyArtifactVersionsOverviewListResult, # pylint: disable=protected-access + pipeline_response, + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + def _update_state_initial( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: Union[_models.ArtifactChangeState, IO], + *, + artifact_name: str, + **kwargs: Any + ) -> Optional[_models.ProxyArtifactVersionsListOverview]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ProxyArtifactVersionsListOverview]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArtifactChangeState") + + request = build_proxy_artifact_update_state_request( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_version_name=artifact_version_name, + subscription_id=self._config.subscription_id, + artifact_name=artifact_name, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ProxyArtifactVersionsListOverview", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: _models.ArtifactChangeState, + *, + artifact_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactChangeState + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: IO, + *, + artifact_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Required. + :type parameters: IO + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_state( + self, + resource_group_name: str, + publisher_name: str, + artifact_store_name: str, + artifact_version_name: str, + parameters: Union[_models.ArtifactChangeState, IO], + *, + artifact_name: str, + **kwargs: Any + ) -> LROPoller[_models.ProxyArtifactVersionsListOverview]: + """Change artifact state defined in artifact store. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param publisher_name: The name of the publisher. Required. + :type publisher_name: str + :param artifact_store_name: The name of the artifact store. Required. + :type artifact_store_name: str + :param artifact_version_name: The name of the artifact version. Required. + :type artifact_version_name: str + :param parameters: Parameters supplied to update the state of artifact manifest. Is either a + ArtifactChangeState type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.ArtifactChangeState or IO + :keyword artifact_name: The name of the artifact. Required. + :paramtype artifact_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns ProxyArtifactVersionsListOverview + :rtype: + ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.ProxyArtifactVersionsListOverview] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProxyArtifactVersionsListOverview] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_state_initial( + resource_group_name=resource_group_name, + publisher_name=publisher_name, + artifact_store_name=artifact_store_name, + artifact_version_name=artifact_version_name, + parameters=parameters, + artifact_name=artifact_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ProxyArtifactVersionsListOverview", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SitesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`sites` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, site_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_sites_delete_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete(self, resource_group_name: str, site_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + site_name=site_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, site_name: str, **kwargs: Any) -> _models.Site: + """Gets information about the specified network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + request = build_sites_get_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _create_or_update_initial( + self, resource_group_name: str, site_name: str, parameters: Union[_models.Site, IO], **kwargs: Any + ) -> _models.Site: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Site") + + request = build_sites_create_or_update_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("Site", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + site_name: str, + parameters: _models.Site, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.Site + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Site + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Site + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, site_name: str, parameters: Union[_models.Site, IO], **kwargs: Any + ) -> LROPoller[_models.Site]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to the create or update network site operation. Is + either a Site type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.Site or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns Site + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + site_name=site_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Site", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + site_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + site_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, resource_group_name: str, site_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + ) -> _models.Site: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_name: The name of the network service site. Required. + :type site_name: str + :param parameters: Parameters supplied to update network site tags. Is either a TagsObject type + or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: Site + :rtype: ~Microsoft.HybridNetwork.models.Site + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Site] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_sites_update_tags_request( + resource_group_name=resource_group_name, + site_name=site_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("Site", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Site"]: + """Lists all sites in the network service in a subscription. + + :return: An iterator like instance of Site + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_sites_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Site"]: + """Lists all sites in the network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Site + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.Site] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteListResult] = kwargs.pop("cls", None) # pylint: disable=protected-access + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_sites_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + +class SiteNetworkServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~Microsoft.HybridNetwork.HybridNetworkManagementClient`'s + :attr:`site_network_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, site_network_service_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_site_network_services_delete_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + @distributed_trace + def begin_delete(self, resource_group_name: str, site_network_service_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified site network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, site_network_service_name: str, **kwargs: Any + ) -> _models.SiteNetworkService: + """Gets information about the specified site network service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + request = build_site_network_services_get_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + def _create_or_update_initial( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.SiteNetworkService, IO], + **kwargs: Any + ) -> _models.SiteNetworkService: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SiteNetworkService") + + request = build_site_network_services_create_or_update_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + if response.status_code == 200: + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: _models.SiteNetworkService, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Required. + :type parameters: ~Microsoft.HybridNetwork.models.SiteNetworkService + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.SiteNetworkService, IO], + **kwargs: Any + ) -> LROPoller[_models.SiteNetworkService]: + """Creates or updates a network site. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to the create or update site network service operation. + Is either a SiteNetworkService type or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.SiteNetworkService or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns SiteNetworkService + :rtype: ~azure.core.polling.LROPoller[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + site_network_service_name: str, + parameters: Union[_models.TagsObject, IO], + **kwargs: Any + ) -> _models.SiteNetworkService: + """Updates a site update tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param site_network_service_name: The name of the site network service. Required. + :type site_network_service_name: str + :param parameters: Parameters supplied to update network site tags. Is either a TagsObject type + or a IO type. Required. + :type parameters: ~Microsoft.HybridNetwork.models.TagsObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: SiteNetworkService + :rtype: ~Microsoft.HybridNetwork.models.SiteNetworkService + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SiteNetworkService] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + request = build_site_network_services_update_tags_request( + resource_group_name=resource_group_name, + site_network_service_name=site_network_service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + deserialized = self._deserialize("SiteNetworkService", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SiteNetworkService"]: + """Lists all sites in the network service in a subscription. + + :return: An iterator like instance of SiteNetworkService + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteNetworkServiceListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_site_network_services_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteNetworkServiceListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SiteNetworkService"]: + """Lists all site network services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of SiteNetworkService + :rtype: ~azure.core.paging.ItemPaged[~Microsoft.HybridNetwork.models.SiteNetworkService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models._models.SiteNetworkServiceListResult] = kwargs.pop( # pylint: disable=protected-access + "cls", None + ) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_site_network_services_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request.url = self._client.format_url(request.url) + + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize( + _models._models.SiteNetworkServiceListResult, pipeline_response # pylint: disable=protected-access + ) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + response.read() # Load the body in memory and close the socket + 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/src/aosm/azext_aosm/vendored_sdks/operations/_patch.py b/src/aosm/azext_aosm/vendored_sdks/operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/aosm/azext_aosm/vendored_sdks/py.typed b/src/aosm/azext_aosm/vendored_sdks/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/aosm/azext_aosm/vendored_sdks/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/aosm/pyproject.toml b/src/aosm/pyproject.toml new file mode 100644 index 00000000000..e4bbc5837c4 --- /dev/null +++ b/src/aosm/pyproject.toml @@ -0,0 +1,7 @@ +[tool.mypy] +ignore_missing_imports = true +no_namespace_packages = true + +[[tool.mypy.overrides]] +module = ["azext_aosm.vendored_sdks.*"] +ignore_errors = true diff --git a/src/aosm/setup.cfg b/src/aosm/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/aosm/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/aosm/setup.py b/src/aosm/setup.py new file mode 100644 index 00000000000..1ade10c9b8c --- /dev/null +++ b/src/aosm/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +from codecs import open +from setuptools import find_packages, setup + +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = "1.0.0b1" + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "License :: OSI Approved :: MIT License", +] + +DEPENDENCIES = ["oras~=0.1.19", "azure-storage-blob>=12.15.0", "jinja2>=3.1.2"] + +with open("README.md", "r", encoding="utf-8") as f: + README = f.read() +with open("HISTORY.rst", "r", encoding="utf-8") as f: + HISTORY = f.read() + +setup( + name="aosm", + version=VERSION, + description="Microsoft Azure Command-Line Tools Aosm Extension", + author="Microsoft Corporation", + author_email="azpycli@microsoft.com", + url="https://github.com/Azure/azure-cli-extensions/tree/master/src/aosm", + long_description=README + "\n\n" + HISTORY, + license="MIT", + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={ + "azext_aosm": [ + "azext_metadata.json", + "generate_nfd/templates/*", + "generate_nsd/templates/*", + ] + }, +) diff --git a/src/service_name.json b/src/service_name.json index 2c6fd4fd149..238d91d4897 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -34,6 +34,11 @@ "AzureServiceName": "Azure CLI", "URL": "" }, + { + "Command": "az aosm", + "AzureServiceName": "Azure Operator Service Manager", + "URL": "https://learn.microsoft.com/azure/operator-service-manager" + }, { "Command": "az appservice", "AzureServiceName": "App Services",