Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add apic api update example #63

Merged
merged 8 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Update(AAZCommand):

:example: Update custom properties
az apic api update -g contoso-resources -n contoso --api-id echo-api --custom-properties '{\"public-facing\":true}'

:example: Update single custom metadata
az apic api update -g contoso-resources -n contoso --api-id echo-api --set customProperties.internal=false
"""

_aaz_info = {
Expand Down
1 change: 1 addition & 0 deletions src/apic-extension/azext_apic_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
encoding = result['encoding']

# TODO - read other file types later
value = None
if str(api_location).endswith('.yaml') or str(api_location).endswith('.yml'):
with open(str(api_location), 'r', encoding=encoding) as f:
content = f.read()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- apic api update
Connection:
- keep-alive
ParameterSetName:
- -g -n --api-id --set
User-Agent:
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003?api-version=2024-03-01
response:
body:
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"Echo
API","kind":"rest","externalDocumentation":[],"contacts":[],"customProperties":{}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003","name":"clitest000003","systemData":{"createdAt":"2024-09-18T09:02:41.073034Z","lastModifiedAt":"2024-09-18T09:02:41.0730326Z"}}'
headers:
api-supported-versions:
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
cache-control:
- no-cache
content-length:
- '471'
content-type:
- application/json; charset=utf-8
date:
- Wed, 18 Sep 2024 09:02:44 GMT
etag:
- 6a024d5a-0000-0100-0000-66ea97310000
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
vary:
- Accept-Encoding
x-cache:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-reads:
- '7499'
x-msedge-ref:
- 'Ref A: E1A7B7E81D9E4E0D8E08D1C83BFC4A6B Ref B: MAA201060516053 Ref C: 2024-09-18T09:02:43Z'
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
- request:
body: '{"properties": {"contacts": [], "customProperties": {"clitest000004": false},
"externalDocumentation": [], "kind": "rest", "title": "Echo API"}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- apic api update
Connection:
- keep-alive
Content-Length:
- '144'
Content-Type:
- application/json
ParameterSetName:
- -g -n --api-id --set
User-Agent:
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003?api-version=2024-03-01
response:
body:
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"Echo
API","kind":"rest","externalDocumentation":[],"contacts":[],"customProperties":{"clitest000004":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003","name":"clitest000003","systemData":{"lastModifiedAt":"2024-09-18T09:02:46.6945921Z"}}'
headers:
api-supported-versions:
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
cache-control:
- no-cache
content-length:
- '450'
content-type:
- application/json; charset=utf-8
date:
- Wed, 18 Sep 2024 09:02:46 GMT
etag:
- 6a025f5a-0000-0100-0000-66ea97360000
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
vary:
- Accept-Encoding
x-cache:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-writes:
- '5999'
x-ms-ratelimit-remaining-subscription-writes:
- '399'
x-msedge-ref:
- 'Ref A: F3760B3FC31843EA92F7CAE00B680867 Ref B: MAA201060516053 Ref C: 2024-09-18T09:02:45Z'
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ def test_examples_update_api(self):
self.check('summary', 'Basic REST API service'),
])

@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
@ApicMetadataPreparer()
def test_examples_update_single_custom_metadata(self):
self.cmd('az apic api update -g {rg} -n {s} --api-id {api} --set customProperties.{m}=false', checks=[
self.check('customProperties.{m}', False),
])

@ResourceGroupPreparer(name_prefix="clirg", location=TEST_REGION, random_name_length=32)
@ApicServicePreparer()
@ApicApiPreparer()
Expand Down
Loading