Refactor azure-keyvault-secrets to patch-based structure #44348
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Restructures
azure-keyvault-secretsfrom handwritten-wrapper-on-generated to patch-based customization pattern, matchingazure-keyvault-securitydomainreference implementation.Changes
New Structure
_patch.py- Root patch containing:ApiVersionenum (migrated from_shared/client_base.py)SecretClientimplementation with challenge auth, custom polling, and all secret operationsmodels/_patch.py- Handwritten models (SecretProperties,KeyVaultSecret,DeletedSecret,KeyVaultSecretIdentifier)_internal/__init__.py- Internal utilities bridge (challenge auth, polling, ID parsing)_operations/_patch.py- Operations patch (minimal)aio/_patch.py- Async patch (minimal, preserves existing_client.py)Updated Import Pattern
All
__init__.pyfiles now use patch-based imports withTYPE_CHECKINGguards:Backward Compatibility
Public API unchanged - all classes, methods, and signatures identical. Old
_client.pyand_models.pypreserved for transition.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
pypi.org/home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/pip pip install isodate -q(dns block)/home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/lib/python3.9/site-packages/pip/__pip-REDACTED__.py install --ignore-installed --no-user --prefix /tmp/pip-build-env-37382dib/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i REDACTED -- setuptools>=40.8.0(dns block)/home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/lib/python3.9/site-packages/pip/__pip-REDACTED__.py install --ignore-installed --no-user --prefix /tmp/pip-build-env-36i5iycv/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i REDACTED -- setuptools>=40.8.0(dns block)scanning-api.github.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Objective
Refactor
azure-keyvault-secretsfrom the old handwritten-layer-on-generated-code structure to the new generation-focused structure with a_patch.pypatching layer. Useazure-keyvault-securitydomainas the reference implementation for the target structure.Background
Current Structure (Old Format):
_generated/directory_generated/subdirectory_client.pywraps generated client_models.pywraps generated models__init__.pyTarget Structure (New Format - based on securitydomain):
_generated/subdirectory)_patch.pyfiles at various levels modify/extend generated code_internal/directory for handwritten utilities that patches import__init__.pyuses automatic patch-based importsmodels/directory (not_generated/models/) with its own_patch.pyDetailed Refactoring Requirements
1. Root Package Structure (
azure/keyvault/secrets/)Update
__init__.py_patchwith try/except pattern_patch_sdk()at module initializationCreate
_patch.pyThis is the main handwritten customization file. It should include:
Imports:
SecretClientas base class_internal/(challenge auth, polling, etc.)models/ApiVersion enum:
_shared/client_base.pyEnhanced SecretClient class:
__init__to add:send_requestwith API version formattingHelper functions:
_format_api_version()function (similar to securitydomain)Export list:
2. Models Refactoring (
azure/keyvault/secrets/models/)The current
_generated/directory should be restructured:Create
models/__init__.py_models.py_enums.pyif any_patchCreate
models/_patch.pyMove handwritten models from the current
_models.py:SecretProperties- with all its properties and_from_secret_bundle,_from_secret_itemclass methodsKeyVaultSecret- with_from_secret_bundleclass methodKeyVaultSecretIdentifier- parser for secret IDsDeletedSecret- with deletion-related propertiesExport them:
Keep
models/_models.pyThis should contain generated model classes (currently in
_generated/models/):SecretBundleDeletedSecretBundleSecretItemDeletedSecretItemSecretAttributesSecretSetParametersSecretUpdateParametersSecretRestoreParametersThese models are referenced by handwritten code but not directly exposed to users.
3. Internal Utilities (
azure/keyvault/secrets/_internal/)Create this directory to house handwritten utilities that `_patch....
This pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.