diff --git a/src/apic-extension/azext_apic_extension/_help.py b/src/apic-extension/azext_apic_extension/_help.py index a738f149549..e54d90efc36 100644 --- a/src/apic-extension/azext_apic_extension/_help.py +++ b/src/apic-extension/azext_apic_extension/_help.py @@ -12,7 +12,7 @@ helps['apic api register'] = """ type: command - short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth. + short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth. For now we only support OpenAPI JSON/YAML format. parameters: - name: --api-location -l type: string diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py index 78ad3818b04..fe4a8419ee0 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py @@ -19,6 +19,9 @@ class List(AAZCommand): :example: List APIs az apic api list -g contoso-resources -s contoso + + :example: List APIs with filter + az apic api list -g contoso-resources -s contoso --filter "kind eq 'rest'" """ _aaz_info = { diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_examples_list_apis_with_filter.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_examples_list_apis_with_filter.yaml new file mode 100644 index 00000000000..aece3872c92 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_examples_list_apis_with_filter.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api list + Connection: + - keep-alive + ParameterSetName: + - -g -s --filter + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis?$filter=kind%20eq%20%27rest%27&api-version=2024-03-01 + response: + body: + string: '{"value":[{"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-05-27T03:36:06.086997Z","lastModifiedAt":"2024-05-27T03:36:06.0869958Z"}},{"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/clitest000004","name":"clitest000004","systemData":{"createdAt":"2024-05-27T03:36:08.8849381Z","lastModifiedAt":"2024-05-27T03:36:08.8849374Z"}}]}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01, 2024-03-15-preview + cache-control: + - no-cache + content-length: + - '956' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 27 May 2024 03:36:11 GMT + 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: + - '3749' + x-msedge-ref: + - 'Ref A: 8DF30CDEB07A4750A8C3AFFA1E37F951 Ref B: MAA201060513029 Ref C: 2024-05-27T03:36:10Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/test_api_commands.py b/src/apic-extension/azext_apic_extension/tests/latest/test_api_commands.py index 8e0ca26094c..a4639d4b7a2 100644 --- a/src/apic-extension/azext_apic_extension/tests/latest/test_api_commands.py +++ b/src/apic-extension/azext_apic_extension/tests/latest/test_api_commands.py @@ -193,4 +193,15 @@ def test_examples_update_custom_properties(self, metadata_name): }) self.cmd('az apic api update -g {rg} -s {s} --api-id {api} --custom-properties \'{customProperties}\'', checks=[ self.check('customProperties.{}'.format(metadata_name), True), + ]) + + @ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32) + @ApicServicePreparer() + @ApicApiPreparer(parameter_name='api_id1') + @ApicApiPreparer(parameter_name='api_id2') + def test_examples_list_apis_with_filter(self, api_id1, api_id2): + self.cmd('az apic api list -g {rg} -s {s} --filter "kind eq \'rest\'"', checks=[ + self.check('length(@)', 2), + self.check('@[0].name', api_id1), + self.check('@[1].name', api_id2) ]) \ No newline at end of file