From 33bbf029fc3c0b33fafe58997e4324281f9d31c3 Mon Sep 17 00:00:00 2001 From: Arpi Shah <120400150+arpishahmsft@users.noreply.github.com> Date: Tue, 28 Nov 2023 23:27:16 -0600 Subject: [PATCH] APICenter Extension Initial Release (#6918) * create extension, update examples, remove import/export commands for api center --- .github/CODEOWNERS | 2 + src/apic-extension/HISTORY.rst | 8 + src/apic-extension/README.md | 286 ++ .../azext_apic_extension/__init__.py | 42 + .../azext_apic_extension/_help.py | 33 + .../azext_apic_extension/_params.py | 38 + .../azext_apic_extension/aaz/__init__.py | 6 + .../aaz/latest/__init__.py | 6 + .../aaz/latest/apic/__cmd_group.py | 23 + .../aaz/latest/apic/__init__.py | 11 + .../aaz/latest/apic/api/__cmd_group.py | 23 + .../aaz/latest/apic/api/__init__.py | 17 + .../aaz/latest/apic/api/_create.py | 485 +++ .../aaz/latest/apic/api/_delete.py | 172 + .../aaz/latest/apic/api/_head.py | 163 + .../aaz/latest/apic/api/_list.py | 290 ++ .../aaz/latest/apic/api/_show.py | 285 ++ .../aaz/latest/apic/api/_update.py | 652 +++ .../latest/apic/api/definition/__cmd_group.py | 23 + .../latest/apic/api/definition/__init__.py | 19 + .../aaz/latest/apic/api/definition/_create.py | 306 ++ .../aaz/latest/apic/api/definition/_delete.py | 200 + .../api/definition/_export_specification.py | 244 ++ .../aaz/latest/apic/api/definition/_head.py | 191 + .../api/definition/_import_specification.py | 271 ++ .../aaz/latest/apic/api/definition/_list.py | 277 ++ .../aaz/latest/apic/api/definition/_show.py | 274 ++ .../aaz/latest/apic/api/definition/_update.py | 467 +++ .../latest/apic/api/deployment/__cmd_group.py | 23 + .../latest/apic/api/deployment/__init__.py | 17 + .../aaz/latest/apic/api/deployment/_create.py | 359 ++ .../aaz/latest/apic/api/deployment/_delete.py | 186 + .../aaz/latest/apic/api/deployment/_head.py | 177 + .../aaz/latest/apic/api/deployment/_list.py | 274 ++ .../aaz/latest/apic/api/deployment/_show.py | 270 ++ .../aaz/latest/apic/api/deployment/_update.py | 523 +++ .../latest/apic/api/version/__cmd_group.py | 23 + .../aaz/latest/apic/api/version/__init__.py | 17 + .../aaz/latest/apic/api/version/_create.py | 290 ++ .../aaz/latest/apic/api/version/_delete.py | 186 + .../aaz/latest/apic/api/version/_head.py | 177 + .../aaz/latest/apic/api/version/_list.py | 260 ++ .../aaz/latest/apic/api/version/_show.py | 256 ++ .../aaz/latest/apic/api/version/_update.py | 445 +++ .../latest/apic/environment/__cmd_group.py | 23 + .../aaz/latest/apic/environment/__init__.py | 17 + .../aaz/latest/apic/environment/_create.py | 367 ++ .../aaz/latest/apic/environment/_delete.py | 172 + .../aaz/latest/apic/environment/_head.py | 163 + .../aaz/latest/apic/environment/_list.py | 270 ++ .../aaz/latest/apic/environment/_show.py | 265 ++ .../aaz/latest/apic/environment/_update.py | 529 +++ .../apic/metadata_schema/__cmd_group.py | 23 + .../latest/apic/metadata_schema/__init__.py | 18 + .../latest/apic/metadata_schema/_create.py | 290 ++ .../latest/apic/metadata_schema/_delete.py | 160 + .../_export_metadata_schema.py | 217 + .../aaz/latest/apic/metadata_schema/_head.py | 148 + .../aaz/latest/apic/metadata_schema/_list.py | 240 ++ .../aaz/latest/apic/metadata_schema/_show.py | 237 ++ .../latest/apic/metadata_schema/_update.py | 442 ++ .../aaz/latest/apic/service/__cmd_group.py | 23 + .../aaz/latest/apic/service/__init__.py | 16 + .../aaz/latest/apic/service/_create.py | 319 ++ .../aaz/latest/apic/service/_delete.py | 143 + .../aaz/latest/apic/service/_list.py | 420 ++ .../aaz/latest/apic/service/_show.py | 249 ++ .../aaz/latest/apic/service/_update.py | 462 +++ .../aaz/latest/apic/workspace/__cmd_group.py | 23 + .../aaz/latest/apic/workspace/__init__.py | 17 + .../aaz/latest/apic/workspace/_create.py | 260 ++ .../aaz/latest/apic/workspace/_delete.py | 158 + .../aaz/latest/apic/workspace/_head.py | 149 + .../aaz/latest/apic/workspace/_list.py | 230 ++ .../aaz/latest/apic/workspace/_show.py | 225 ++ .../aaz/latest/apic/workspace/_update.py | 406 ++ .../azext_apic_extension/azext_metadata.json | 4 + .../azext_apic_extension/commands.py | 28 + .../azext_apic_extension/custom.py | 476 +++ .../azext_apic_extension/tests/__init__.py | 6 + .../tests/latest/__init__.py | 6 + .../latest/data/exported_md_schema_api.json | 177 + .../data/exported_md_schema_deployment.json | 56 + .../latest/data/exported_md_schema_env.json | 66 + .../tests/latest/data/exported_spec.json | 36 + .../data/import_metadataschema_input.json | 5 + .../latest/data/import_spec_payload.json | 36 + .../data/register_quickadd_openai_spec.json | 3193 +++++++++++++++ .../recordings/test_apic_scenarios.yaml | 3540 +++++++++++++++++ .../tests/latest/test_apic_extension.py | 266 ++ src/apic-extension/setup.cfg | 1 + src/apic-extension/setup.py | 49 + src/service_name.json | 5 + 93 files changed, 22928 insertions(+) create mode 100644 src/apic-extension/HISTORY.rst create mode 100644 src/apic-extension/README.md create mode 100644 src/apic-extension/azext_apic_extension/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/_help.py create mode 100644 src/apic-extension/azext_apic_extension/_params.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__cmd_group.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_create.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_delete.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_head.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_list.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_show.py create mode 100644 src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_update.py create mode 100644 src/apic-extension/azext_apic_extension/azext_metadata.json create mode 100644 src/apic-extension/azext_apic_extension/commands.py create mode 100644 src/apic-extension/azext_apic_extension/custom.py create mode 100644 src/apic-extension/azext_apic_extension/tests/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/__init__.py create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_api.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_deployment.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_env.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/exported_spec.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/import_metadataschema_input.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/import_spec_payload.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/data/register_quickadd_openai_spec.json create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/recordings/test_apic_scenarios.yaml create mode 100644 src/apic-extension/azext_apic_extension/tests/latest/test_apic_extension.py create mode 100644 src/apic-extension/setup.cfg create mode 100644 src/apic-extension/setup.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 892c55974df..75b3ac9ff30 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -14,6 +14,8 @@ /src/subscription/ @wilcobmsft +/src/apic-extension/ @arpishahmsft + /src/alias/ @Juliehzl /src/managementpartner/ @jeffrey-ace diff --git a/src/apic-extension/HISTORY.rst b/src/apic-extension/HISTORY.rst new file mode 100644 index 00000000000..abbff5a61a7 --- /dev/null +++ b/src/apic-extension/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/apic-extension/README.md b/src/apic-extension/README.md new file mode 100644 index 00000000000..a3c17e2279e --- /dev/null +++ b/src/apic-extension/README.md @@ -0,0 +1,286 @@ +# Azure CLI APICenter Extension + +This extension can help create and manage APICenter Resources + +### How to use +Install this extension using the below CLI command +``` +az extension add --name apic-extension +``` + +### API Center Extension Info +APICenter documentation: https://learn.microsoft.com/en-us/azure/api-center/ + +List Service Examples +``` +az apic service show --resource-group api-center-test +``` +``` +az apic service show -g api-center-test +``` + +Show service Examples +``` +az apic service show --resource-group api-center-test --service-name contosoeuap +``` +``` +az apic service show -g api-center-test -s contosoeuap +``` + +Delete Service Examples +``` +az apic service delete --resource-group api-center-test --service-name contosoeuap +``` +``` +az apic service delete --resource-group arpi-test-rg1 -s apictestcli3 +``` + +Show Workspace Example +``` +Az apic workspace show -g api-center-test -s contosoeuap --name devdiv +``` + +Create API Examples +``` +az apic api create -g api-center-test -s contosoeuap --name echo-api --title "Echo API" --kind "rest" +``` +``` +az apic api create --resource-group api-center-test --service-name contosoeuap --api-name echo-api2 --description "CLI Test" --kind rest --title "Echo API" +``` + +Update API Examples +``` +az apic api update -g api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" -w default +``` +``` +az apic api update --resource-group api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" --workspace-name default +``` + +LIST Api Example +``` +az apic api list --resource-group api-center-test --service-name contosoeuap +``` +``` +az apic api list -g api-center-test -s contosoeuap +``` + +SHOW Api Examples +``` +az apic api show -g api-center-test -s contosoeuap --name echo-api +``` +``` +az apic api show --resource-group api-center-test --service-name contosoeuap -w default --api echo-api +``` + +Delete API Examples +``` +az apic api delete -g api-center-test -s contosoeuap --name echo-api +``` +``` +az apic api delete --resource-group contoso-resources --service-name contosoeuap --name echo-api +``` + +CREATE Api Version Examples +``` +az apic api version create -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" +``` +``` +az apic api version create --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" +``` + +UPDATE Api Version Examples +``` +Az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" -w default +``` +``` +az apic api version update --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" --workspace-name default +``` + +LIST Api Version Examples +``` +az apic api version list -g api-center-test -s contosoeuap --api-name echo-api +``` +``` +az apic api version list --resource-group api-center-test --service-name contosoeuap --api-name echo-api +``` + +SHOW Api Version Example +``` +az apic api version show -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 +``` +``` +az apic api version show --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 +``` + +DELETE Api Version Example +``` +az apic api version delete -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 +``` +``` +az apic api version delete --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 +``` + +CREATE API Definition Example +``` +az apic api definition create -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" +``` + +UPDATE API Definition Example +``` +az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" -w default +``` + +SHOW API Definition Example +``` +az apic api definition show -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" +``` + +LIST API Definition Example +``` +az apic api definition list -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 +``` + +DELETE API Definition Example +``` +az apic api definition delete -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" +``` + +IMPORT Specification Examples +Import Specification inline option +``` +az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api --version-name 2023-01-01 --definition-name openapi--format "inline" --value '{"openapi":"3.0.1","info":{"title":"httpbin.org","description":"API Management facade for a very handy and free online HTTP tool.","version":"1.0"}}' --specification '{"name":"openapi","version":"3.0.0"}' +``` + +Import Specification Inline option where spec is provided by sending a file +``` +az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api --version-name 2023-01-01 --definition-name openapi --format inline --specification '{"name":"openapi","version":"3.0.0"}' --file-name C:\Users\arpishah\examples\cli-examples\spec-examples\cat-facts-api.json +``` + +Import Specification Link option where spec is provided via a link +``` +az apic api definition import-specification -g api-center-test -s contosoeuap - --api-name echo-api --version-name 2023-01-01 --definition-name openapi --format "link" --value https://alzaslonaztest.blob.core.windows.net/arpitestblobs/cat-facts-api.json --specification '{"name":"openapi","version":"3.0.0"}' +``` + +Export Specification Examples +Export Spec to a file +``` +az apic api definition export-specification -g api-center-test -s contosoeuap --api-name echo-api-10 --version-name 2023-11-08 --definition-name arpitest4 --file-name C:\Users\arpishah\examples\cli-examples\exported-results\exported-spec-inline.json +``` + +CREATE Api Deployment + +``` +az apic api deployment create -g api-center-test -s contosoeuap --name production --title "Production deployment" --description "Public cloud production deployment." --api echo-api --server C:/Users/arpishah/examples/cli-examples/payload-examples/deplcreate.json --environment-id "/workspaces/default/environments/production" --definition-id "/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi" +where examples/deplcreate.json contains +{"runtime-uri": ["https://api.contoso.com"]} +``` + +UPDATE Api Deployment +``` +az apic api deployment update -g api-center-test -s contosoeuap --name production --title "Production deployment 10" --api echo-api –w default +``` + +LIST Api Deployment +``` +az apic api deployment list -g api-center-test -s contosoeuap --api-name echo-api +``` + +SHOW Api Deployment +``` +az apic api deployment show -g api-center-test -s contosoeuap --name production --api-name echo-api +``` + +DELETE Api Deployment +``` +Az apic api deployment delete -g api-center-test -s contosoeuap --name production --api-name echo-api +``` + +CREATE Environment +``` +az apic environment create -g api-center-test -s contosoeuap --name public-3 --title "Public cloud" --kind "development" --server "C:\Users\arpishah\examples\cli-examples\payload-examples\envcreate1.json" +Where envcreate1.json contains +{ + "type": "Azure API Management", + "managementPortalUri": [ + "management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service" + ] +} +``` + +UPDATE Environment +``` +az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" -w default +``` + +LIST Environment +``` +az apic environment list -g api-center-test -s contosoeuap +``` + +SHOW Environment +``` +az apic environment show -g api-center-test -s contosoeuap --name public +``` + +DELETE Environment +``` +az apic environment delete -g api-center-test -s contosoeuap --name public +``` + +CREATE Metadata Schema +``` +az apic metadata-schema create --resource-group api-center-test --service-name contosoeuap --name "test1" --file-name "C:\Users\arpishah\examples\cli-examples\payload-examples\schemacreate.json" +Where schemacreate.json contains metadata schema +{ + "type": "string", + "title": "First name", + "pattern": "^[a-zA-Z0-9 ]+$" +} +``` + +UPDATE Metadata Schema +``` +az apic metadata-schema update --resource-group api-center-test --service-name contosoeuap --name "test1" --file-name "C:\Users\arpishah\examples\cli-examples\payload-examples\schemaupdate.json" +Where schemaupdate.json contains metadata schema +{ + "type": "string", + "title": "Last name", + "pattern": "^[a-zA-Z0-9 ]+$" +} +``` + +LIST Metadata Schema +``` +az apic metadata-schema list -g api-center-test -s contosoeuap +``` + +SHOW Metadata Schema +``` +az apic metadata-schema show --resource-group api-center-test --service-name contosoeuap --name "test1" +``` + +DELETE Metadata Schema +``` +az apic metadata-schema delete --resource-group api-center-test --service-name contosoeuap --name "test1" +``` + +EXPORT Metadata Schema +EXPORT Metadata Schema assigned to an API +``` +az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to api --file-name C:\Users\arpishah\examples\cli-examples\exported-results\exported-schema-3.json +``` + +EXPORT Metadata Schema assigned to a Deployment +``` +az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to deployment --file-name C:\Users\arpishah\examples\cli-examples\exported-results\exported-schema-5.json +``` + +EXPORT Metadata Schema assigned to an Environment +``` +az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to environment --file-name C:\Users\arpishah\examples\cli-examples\exported-results\exported-schema-6.json +``` + +Register API or Quick Add +``` +az apic api register -g api-center-test -s contosoeuap --api-location "C:/Users/arpishah/examples/cli-examples/spec-examples/openai.json" --environment-name public +``` \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/__init__.py b/src/apic-extension/azext_apic_extension/__init__.py new file mode 100644 index 00000000000..487554e612a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/__init__.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. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_apic_extension._help import helps # pylint: disable=unused-import + + +class ApicExtensionCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_apic_extension.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_apic_extension.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_apic_extension._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = ApicExtensionCommandsLoader diff --git a/src/apic-extension/azext_apic_extension/_help.py b/src/apic-extension/azext_apic_extension/_help.py new file mode 100644 index 00000000000..b6bd068b769 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/_help.py @@ -0,0 +1,33 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import + +helps['apic api register'] = """ + type: command + short-summary: Single Command for registering api, api version, api definition, import spec, create deployment provided a spec file. + parameters: + - name: --api-location -l + type: string + short-summary: Location of spec file . + - name: --resource-group -g + type: string + short-summary: Resource group name. + - name: --service -s + type: string + short-summary: APICenter Catalog or Service name. + - name: --environment-name -e + type: string + short-summary: Name of environment created before. + examples: + - name: Register api by providing spec file. + text: | + az apic api register -g api-center-test -s contosoeuap --api-location "examples/cli-examples/spec-examples/openai.json" --environment-name public +""" diff --git a/src/apic-extension/azext_apic_extension/_params.py b/src/apic-extension/azext_apic_extension/_params.py new file mode 100644 index 00000000000..3ac94ef8195 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/_params.py @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + + with self.argument_context("apic api register") as c: + c.argument( + "api_location", + options_list=['--api-location', '-l'], + help="Specification file", + required=True, + ) + c.argument( + "resource_group", + options_list=['--resource-group', '-g'], + help="Resource group name", + required=True, + ) + c.argument( + "service_name", + options_list=['--service', '-s'], + help="Service name", + required=True, + ) + c.argument( + "environment_name", + options_list=['--environment-name', '-e'], + help="Environemnt name", + required=False + ) diff --git a/src/apic-extension/azext_apic_extension/aaz/__init__.py b/src/apic-extension/azext_apic_extension/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/__cmd_group.py new file mode 100644 index 00000000000..58da38743e9 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic", +) +class __CMDGroup(AAZCommandGroup): + """API Center + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__cmd_group.py new file mode 100644 index 00000000000..eff8f691a34 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic api", +) +class __CMDGroup(AAZCommandGroup): + """API + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py new file mode 100644 index 00000000000..a6ed8b6688f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py new file mode 100644 index 00000000000..71e6bb7741a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py @@ -0,0 +1,485 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api create", +) +class Create(AAZCommand): + """Create new or updates existing API. + + :example: Create API + az apic api create -g contoso-resources -s contoso --name echo-api --title "Echo API" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--name", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.contacts = AAZListArg( + options=["--contacts"], + arg_group="Properties", + help="The contact information for the API.", + ) + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + blank={}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description of the API.", + fmt=AAZStrArgFormat( + max_length=1000, + ), + ) + _args_schema.external_documentation = AAZListArg( + options=["--external-documentation"], + arg_group="Properties", + help="Additional, external documentation for the API.", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="Properties", + help="Kind of API. For example, REST or GraphQL.", + enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"}, + ) + _args_schema.license = AAZObjectArg( + options=["--license"], + arg_group="Properties", + help="The license information for the API.", + ) + _args_schema.summary = AAZStrArg( + options=["--summary"], + arg_group="Properties", + help="Short description of the API.", + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + _args_schema.terms_of_service = AAZObjectArg( + options=["--terms-of-service"], + arg_group="Properties", + help="Terms of service for the API.", + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API title.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + contacts = cls._args_schema.contacts + contacts.Element = AAZObjectArg() + + _element = cls._args_schema.contacts.Element + _element.email = AAZStrArg( + options=["email"], + help="Email address of the contact.", + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the contact.", + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + _element.url = AAZStrArg( + options=["url"], + help="URL for the contact.", + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + external_documentation = cls._args_schema.external_documentation + external_documentation.Element = AAZObjectArg() + + _element = cls._args_schema.external_documentation.Element + _element.description = AAZStrArg( + options=["description"], + help="Description of the documentation.", + fmt=AAZStrArgFormat( + max_length=500, + ), + ) + _element.title = AAZStrArg( + options=["title"], + help="Title of the documentation.", + fmt=AAZStrArgFormat( + max_length=50, + ), + ) + _element.url = AAZStrArg( + options=["url"], + help="URL pointing to the documentation.", + required=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + license = cls._args_schema.license + license.identifier = AAZStrArg( + options=["identifier"], + help="SPDX license information for the API. The identifier field is mutually exclusive of the URL field.", + fmt=AAZStrArgFormat( + max_length=50, + ), + ) + license.name = AAZStrArg( + options=["name"], + help="Name of the license.", + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + license.url = AAZStrArg( + options=["url"], + help="URL pointing to the license details. The URL field is mutually exclusive of the identifier field.", + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + terms_of_service = cls._args_schema.terms_of_service + terms_of_service.url = AAZStrArg( + options=["url"], + help="URL pointing to the terms of service.", + required=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApisCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("contacts", AAZListType, ".contacts") + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("externalDocumentation", AAZListType, ".external_documentation") + properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("license", AAZObjectType, ".license") + properties.set_prop("summary", AAZStrType, ".summary") + properties.set_prop("termsOfService", AAZObjectType, ".terms_of_service") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + contacts = _builder.get(".properties.contacts") + if contacts is not None: + contacts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.contacts[]") + if _elements is not None: + _elements.set_prop("email", AAZStrType, ".email") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("url", AAZStrType, ".url") + + external_documentation = _builder.get(".properties.externalDocumentation") + if external_documentation is not None: + external_documentation.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.externalDocumentation[]") + if _elements is not None: + _elements.set_prop("description", AAZStrType, ".description") + _elements.set_prop("title", AAZStrType, ".title") + _elements.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + license = _builder.get(".properties.license") + if license is not None: + license.set_prop("identifier", AAZStrType, ".identifier") + license.set_prop("name", AAZStrType, ".name") + license.set_prop("url", AAZStrType, ".url") + + terms_of_service = _builder.get(".properties.termsOfService") + if terms_of_service is not None: + terms_of_service.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.contacts = AAZListType() + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.external_documentation = AAZListType( + serialized_name="externalDocumentation", + ) + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.license = AAZObjectType() + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + ) + properties.summary = AAZStrType() + properties.terms_of_service = AAZObjectType( + serialized_name="termsOfService", + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + contacts = cls._schema_on_200_201.properties.contacts + contacts.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.contacts.Element + _element.email = AAZStrType() + _element.name = AAZStrType() + _element.url = AAZStrType() + + external_documentation = cls._schema_on_200_201.properties.external_documentation + external_documentation.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.external_documentation.Element + _element.description = AAZStrType() + _element.title = AAZStrType() + _element.url = AAZStrType( + flags={"required": True}, + ) + + license = cls._schema_on_200_201.properties.license + license.identifier = AAZStrType() + license.name = AAZStrType() + license.url = AAZStrType() + + terms_of_service = cls._schema_on_200_201.properties.terms_of_service + terms_of_service.url = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py new file mode 100644 index 00000000000..9ffe5f1ceac --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py @@ -0,0 +1,172 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete specified API. + + :example: Delete API + az apic api delete -g contoso-resources -s contoso --name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--name", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApisDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py new file mode 100644 index 00000000000..2f5ea67d21a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py @@ -0,0 +1,163 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api head", +) +class Head(AAZCommand): + """Checks if specified API exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--name", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApisHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] 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 new file mode 100644 index 00000000000..ad82509e6d5 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py @@ -0,0 +1,290 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api list", +) +class List(AAZCommand): + """List a collection of APIs. + + :example: List APIs + az apic api list -g contoso-resources -s contoso + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ApisList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.contacts = AAZListType() + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.external_documentation = AAZListType( + serialized_name="externalDocumentation", + ) + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.license = AAZObjectType() + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + ) + properties.summary = AAZStrType() + properties.terms_of_service = AAZObjectType( + serialized_name="termsOfService", + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + contacts = cls._schema_on_200.value.Element.properties.contacts + contacts.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.contacts.Element + _element.email = AAZStrType() + _element.name = AAZStrType() + _element.url = AAZStrType() + + external_documentation = cls._schema_on_200.value.Element.properties.external_documentation + external_documentation.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.external_documentation.Element + _element.description = AAZStrType() + _element.title = AAZStrType() + _element.url = AAZStrType( + flags={"required": True}, + ) + + license = cls._schema_on_200.value.Element.properties.license + license.identifier = AAZStrType() + license.name = AAZStrType() + license.url = AAZStrType() + + terms_of_service = cls._schema_on_200.value.Element.properties.terms_of_service + terms_of_service.url = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py new file mode 100644 index 00000000000..bfccf1bb126 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py @@ -0,0 +1,285 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api show", +) +class Show(AAZCommand): + """Get details of the API. + + :example: Show API details + az apic api show -g contoso-resources -s contoso --name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--name", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApisGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.contacts = AAZListType() + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.external_documentation = AAZListType( + serialized_name="externalDocumentation", + ) + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.license = AAZObjectType() + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + ) + properties.summary = AAZStrType() + properties.terms_of_service = AAZObjectType( + serialized_name="termsOfService", + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + contacts = cls._schema_on_200.properties.contacts + contacts.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.contacts.Element + _element.email = AAZStrType() + _element.name = AAZStrType() + _element.url = AAZStrType() + + external_documentation = cls._schema_on_200.properties.external_documentation + external_documentation.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.external_documentation.Element + _element.description = AAZStrType() + _element.title = AAZStrType() + _element.url = AAZStrType( + flags={"required": True}, + ) + + license = cls._schema_on_200.properties.license + license.identifier = AAZStrType() + license.name = AAZStrType() + license.url = AAZStrType() + + terms_of_service = cls._schema_on_200.properties.terms_of_service + terms_of_service.url = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py new file mode 100644 index 00000000000..bec77541160 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py @@ -0,0 +1,652 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api update", +) +class Update(AAZCommand): + """Update new or updates existing API. + + :example: Update API + az apic api update -g contoso-resources -s contoso --name echo-api --summary "Basic REST API service" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--name", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.contacts = AAZListArg( + options=["--contacts"], + arg_group="Properties", + help="The contact information for the API.", + nullable=True, + ) + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + nullable=True, + blank={}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description of the API.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=1000, + ), + ) + _args_schema.external_documentation = AAZListArg( + options=["--external-documentation"], + arg_group="Properties", + help="Additional, external documentation for the API.", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="Properties", + help="Kind of API. For example, REST or GraphQL.", + enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"}, + ) + _args_schema.license = AAZObjectArg( + options=["--license"], + arg_group="Properties", + help="The license information for the API.", + nullable=True, + ) + _args_schema.summary = AAZStrArg( + options=["--summary"], + arg_group="Properties", + help="Short description of the API.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + _args_schema.terms_of_service = AAZObjectArg( + options=["--terms-of-service"], + arg_group="Properties", + help="Terms of service for the API.", + nullable=True, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API title.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + contacts = cls._args_schema.contacts + contacts.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.contacts.Element + _element.email = AAZStrArg( + options=["email"], + help="Email address of the contact.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the contact.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + _element.url = AAZStrArg( + options=["url"], + help="URL for the contact.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + external_documentation = cls._args_schema.external_documentation + external_documentation.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.external_documentation.Element + _element.description = AAZStrArg( + options=["description"], + help="Description of the documentation.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=500, + ), + ) + _element.title = AAZStrArg( + options=["title"], + help="Title of the documentation.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=50, + ), + ) + _element.url = AAZStrArg( + options=["url"], + help="URL pointing to the documentation.", + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + license = cls._args_schema.license + license.identifier = AAZStrArg( + options=["identifier"], + help="SPDX license information for the API. The identifier field is mutually exclusive of the URL field.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=50, + ), + ) + license.name = AAZStrArg( + options=["name"], + help="Name of the license.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=100, + ), + ) + license.url = AAZStrArg( + options=["url"], + help="URL pointing to the license details. The URL field is mutually exclusive of the identifier field.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + + terms_of_service = cls._args_schema.terms_of_service + terms_of_service.url = AAZStrArg( + options=["url"], + help="URL pointing to the terms of service.", + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApisGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ApisCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApisGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_api_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ApisCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_api_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("contacts", AAZListType, ".contacts") + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("externalDocumentation", AAZListType, ".external_documentation") + properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("license", AAZObjectType, ".license") + properties.set_prop("summary", AAZStrType, ".summary") + properties.set_prop("termsOfService", AAZObjectType, ".terms_of_service") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + contacts = _builder.get(".properties.contacts") + if contacts is not None: + contacts.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.contacts[]") + if _elements is not None: + _elements.set_prop("email", AAZStrType, ".email") + _elements.set_prop("name", AAZStrType, ".name") + _elements.set_prop("url", AAZStrType, ".url") + + external_documentation = _builder.get(".properties.externalDocumentation") + if external_documentation is not None: + external_documentation.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.externalDocumentation[]") + if _elements is not None: + _elements.set_prop("description", AAZStrType, ".description") + _elements.set_prop("title", AAZStrType, ".title") + _elements.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + license = _builder.get(".properties.license") + if license is not None: + license.set_prop("identifier", AAZStrType, ".identifier") + license.set_prop("name", AAZStrType, ".name") + license.set_prop("url", AAZStrType, ".url") + + terms_of_service = _builder.get(".properties.termsOfService") + if terms_of_service is not None: + terms_of_service.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_api_read = None + + @classmethod + def _build_schema_api_read(cls, _schema): + if cls._schema_api_read is not None: + _schema.id = cls._schema_api_read.id + _schema.name = cls._schema_api_read.name + _schema.properties = cls._schema_api_read.properties + _schema.system_data = cls._schema_api_read.system_data + _schema.type = cls._schema_api_read.type + return + + cls._schema_api_read = _schema_api_read = AAZObjectType() + + api_read = _schema_api_read + api_read.id = AAZStrType( + flags={"read_only": True}, + ) + api_read.name = AAZStrType( + flags={"read_only": True}, + ) + api_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + api_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + api_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_api_read.properties + properties.contacts = AAZListType() + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.external_documentation = AAZListType( + serialized_name="externalDocumentation", + ) + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.license = AAZObjectType() + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + ) + properties.summary = AAZStrType() + properties.terms_of_service = AAZObjectType( + serialized_name="termsOfService", + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + contacts = _schema_api_read.properties.contacts + contacts.Element = AAZObjectType() + + _element = _schema_api_read.properties.contacts.Element + _element.email = AAZStrType() + _element.name = AAZStrType() + _element.url = AAZStrType() + + external_documentation = _schema_api_read.properties.external_documentation + external_documentation.Element = AAZObjectType() + + _element = _schema_api_read.properties.external_documentation.Element + _element.description = AAZStrType() + _element.title = AAZStrType() + _element.url = AAZStrType( + flags={"required": True}, + ) + + license = _schema_api_read.properties.license + license.identifier = AAZStrType() + license.name = AAZStrType() + license.url = AAZStrType() + + terms_of_service = _schema_api_read.properties.terms_of_service + terms_of_service.url = AAZStrType( + flags={"required": True}, + ) + + system_data = _schema_api_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_api_read.id + _schema.name = cls._schema_api_read.name + _schema.properties = cls._schema_api_read.properties + _schema.system_data = cls._schema_api_read.system_data + _schema.type = cls._schema_api_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py new file mode 100644 index 00000000000..5f95202e0df --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic api definition", +) +class __CMDGroup(AAZCommandGroup): + """API definition + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py new file mode 100644 index 00000000000..831005a1398 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._export_specification import * +from ._head import * +from ._import_specification import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py new file mode 100644 index 00000000000..176b0972967 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py @@ -0,0 +1,306 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition create", +) +class Create(AAZCommand): + """Create new or updates existing API definition. + + :example: Create API definition + az apic api definition create -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="API definition description.", + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API version.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiDefinitionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.description = AAZStrType() + properties.specification = AAZObjectType( + flags={"read_only": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + specification = cls._schema_on_200_201.properties.specification + specification.name = AAZStrType() + specification.version = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py new file mode 100644 index 00000000000..5c508834a41 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py @@ -0,0 +1,200 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete specified API definition. + + :example: Delete API definition + az apic api definition delete -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApiDefinitionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py new file mode 100644 index 00000000000..b738c8cf9f0 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py @@ -0,0 +1,244 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition export-specification", +) +class ExportSpecification(AAZCommand): + """Exports the API specification. + + :example: Export Specification + az apic api version definition export-specification -g api-center-test -s contosoeuap --api-name echo-api --version-name 2023-01-01 --definition-name default + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}/exportspecification", "2024-03-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ApiDefinitionsExportSpecification(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiDefinitionsExportSpecification(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.format = AAZStrType() + _schema_on_200.value = AAZStrType() + + return cls._schema_on_200 + + +class _ExportSpecificationHelper: + """Helper class for ExportSpecification""" + + +__all__ = ["ExportSpecification"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py new file mode 100644 index 00000000000..53d99fabe0d --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py @@ -0,0 +1,191 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition head", +) +class Head(AAZCommand): + """Checks if specified API definition exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApiDefinitionsHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py new file mode 100644 index 00000000000..943e3258a3a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py @@ -0,0 +1,271 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition import-specification", +) +class ImportSpecification(AAZCommand): + """Imports the API specification. + + :example: Import Sepecification + az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api-2 --version-name 2023-08-01 --definition-name openapi3 --format "inline" --value '{"openapi":"3.0.1","info":{"title":"httpbin.org","description":"API Management facade for a very handy and free online HTTP tool.","version":"1.0"}}' --specification '{"name":"openapi","version":"3.0.0"}' + + :example: Import Specification from a file + az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api-2 --version-name 2023-11-01 --definition-name openapi8 --format "link" --value 'https://alzaslonaztest.blob.core.windows.net/arpitestblobs/importspec4.txt' --specification '{"name":"openapi","version":"3.0.0"}' + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}/importspecification", "2024-03-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Payload" + + _args_schema = cls._args_schema + _args_schema.format = AAZStrArg( + options=["--format"], + arg_group="Payload", + help="Format of the API specification source.", + enum={"inline": "inline", "link": "link"}, + ) + _args_schema.specification = AAZObjectArg( + options=["--specification"], + arg_group="Payload", + help="API specification details.", + ) + _args_schema.value = AAZStrArg( + options=["--value"], + arg_group="Payload", + help="Value of the API specification source.", + ) + + specification = cls._args_schema.specification + specification.name = AAZStrArg( + options=["name"], + help="Specification name.", + ) + specification.version = AAZStrArg( + options=["version"], + help="Specification version.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ApiDefinitionsImportSpecification(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApiDefinitionsImportSpecification(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("format", AAZStrType, ".format") + _builder.set_prop("specification", AAZObjectType, ".specification") + _builder.set_prop("value", AAZStrType, ".value") + + specification = _builder.get(".specification") + if specification is not None: + specification.set_prop("name", AAZStrType, ".name") + specification.set_prop("version", AAZStrType, ".version") + + return self.serialize_content(_content_value) + + def on_200(self, session): + pass + + +class _ImportSpecificationHelper: + """Helper class for ImportSpecification""" + + +__all__ = ["ImportSpecification"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py new file mode 100644 index 00000000000..5d1740729b3 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py @@ -0,0 +1,277 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition list", +) +class List(AAZCommand): + """List a collection of API definitions. + + :example: List API definitions + az apic api definition list -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ApiDefinitionsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType() + properties.specification = AAZObjectType( + flags={"read_only": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + specification = cls._schema_on_200.value.Element.properties.specification + specification.name = AAZStrType() + specification.version = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py new file mode 100644 index 00000000000..41b9ac3cd4d --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py @@ -0,0 +1,274 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition show", +) +class Show(AAZCommand): + """Get details of the API definition. + + :example: Show API definition details + az apic api definition show -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiDefinitionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType() + properties.specification = AAZObjectType( + flags={"read_only": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + specification = cls._schema_on_200.properties.specification + specification.name = AAZStrType() + specification.version = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py new file mode 100644 index 00000000000..f56031b5794 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py @@ -0,0 +1,467 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api definition update", +) +class Update(AAZCommand): + """Update new or updates existing API definition. + + :example: Update API definition + az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.definition_name = AAZStrArg( + options=["--name", "--definition", "--definition-name"], + help="The name of the API definition.", + required=True, + id_part="child_name_4", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="API definition description.", + nullable=True, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API version title.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiDefinitionsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ApiDefinitionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiDefinitionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_api_definition_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ApiDefinitionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_api_definition_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_api_definition_read = None + + @classmethod + def _build_schema_api_definition_read(cls, _schema): + if cls._schema_api_definition_read is not None: + _schema.id = cls._schema_api_definition_read.id + _schema.name = cls._schema_api_definition_read.name + _schema.properties = cls._schema_api_definition_read.properties + _schema.system_data = cls._schema_api_definition_read.system_data + _schema.type = cls._schema_api_definition_read.type + return + + cls._schema_api_definition_read = _schema_api_definition_read = AAZObjectType() + + api_definition_read = _schema_api_definition_read + api_definition_read.id = AAZStrType( + flags={"read_only": True}, + ) + api_definition_read.name = AAZStrType( + flags={"read_only": True}, + ) + api_definition_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + api_definition_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + api_definition_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_api_definition_read.properties + properties.description = AAZStrType() + properties.specification = AAZObjectType( + flags={"read_only": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + specification = _schema_api_definition_read.properties.specification + specification.name = AAZStrType() + specification.version = AAZStrType() + + system_data = _schema_api_definition_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_api_definition_read.id + _schema.name = cls._schema_api_definition_read.name + _schema.properties = cls._schema_api_definition_read.properties + _schema.system_data = cls._schema_api_definition_read.system_data + _schema.type = cls._schema_api_definition_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__cmd_group.py new file mode 100644 index 00000000000..79d9942f958 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic api deployment", +) +class __CMDGroup(AAZCommandGroup): + """API deployment + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py new file mode 100644 index 00000000000..a6ed8b6688f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py new file mode 100644 index 00000000000..4dab39f92b5 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py @@ -0,0 +1,359 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment create", +) +class Create(AAZCommand): + """Create new or updates existing API deployment. + + :example: Create deployment + az apic api deployment create -g api-center-test -s contoso --name production --title "Production deployment" --description "Public cloud production deployment." --api echo-api --environmentId "/workspaces/default/environments/production" --definitionId "/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.deployment_name = AAZStrArg( + options=["--name", "--deployment", "--deployment-name"], + help="The name of the API deployment.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + blank={}, + ) + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + arg_group="Properties", + help="API center-scoped definition resource ID.", + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description of the deployment.", + fmt=AAZStrArgFormat( + max_length=500, + ), + ) + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + arg_group="Properties", + help="API center-scoped environment resource ID.", + ) + _args_schema.server = AAZObjectArg( + options=["--server"], + arg_group="Properties", + help="Server", + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="State of API deployment.", + enum={"active": "active", "inactive": "inactive"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Deployment title", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + server = cls._args_schema.server + server.runtime_uri = AAZListArg( + options=["runtime-uri"], + help="Base runtime URLs for this deployment.", + ) + + runtime_uri = cls._args_schema.server.runtime_uri + runtime_uri.Element = AAZStrArg( + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DeploymentsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("definitionId", AAZStrType, ".definition_id") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("environmentId", AAZStrType, ".environment_id") + properties.set_prop("server", AAZObjectType, ".server") + properties.set_prop("state", AAZStrType, ".state") + properties.set_prop("title", AAZStrType, ".title") + + server = _builder.get(".properties.server") + if server is not None: + server.set_prop("runtimeUri", AAZListType, ".runtime_uri") + + runtime_uri = _builder.get(".properties.server.runtimeUri") + if runtime_uri is not None: + runtime_uri.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.definition_id = AAZStrType( + serialized_name="definitionId", + ) + properties.description = AAZStrType() + properties.environment_id = AAZStrType( + serialized_name="environmentId", + ) + properties.server = AAZObjectType() + properties.state = AAZStrType() + properties.title = AAZStrType() + + server = cls._schema_on_200_201.properties.server + server.runtime_uri = AAZListType( + serialized_name="runtimeUri", + ) + + runtime_uri = cls._schema_on_200_201.properties.server.runtime_uri + runtime_uri.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py new file mode 100644 index 00000000000..6584964b542 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py @@ -0,0 +1,186 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete API deployment. + + :example: Delete API deployment + az apic api deployment delete -g api-center-test -s contoso --name production --api-name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.deployment_name = AAZStrArg( + options=["--name", "--deployment", "--deployment-name"], + help="The name of the API deployment.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DeploymentsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py new file mode 100644 index 00000000000..6b24bbf7cb2 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py @@ -0,0 +1,177 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment head", +) +class Head(AAZCommand): + """Checks if specified API deployment exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.deployment_name = AAZStrArg( + options=["--name", "--deployment", "--deployment-name"], + help="The name of the API deployment.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DeploymentsHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py new file mode 100644 index 00000000000..1df71cf6cba --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py @@ -0,0 +1,274 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment list", +) +class List(AAZCommand): + """List a collection of API deployments. + + :example: List API deployments + az apic api deployment list -g api-center-test -s contoso --api-name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class DeploymentsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.definition_id = AAZStrType( + serialized_name="definitionId", + ) + properties.description = AAZStrType() + properties.environment_id = AAZStrType( + serialized_name="environmentId", + ) + properties.server = AAZObjectType() + properties.state = AAZStrType() + properties.title = AAZStrType() + + server = cls._schema_on_200.value.Element.properties.server + server.runtime_uri = AAZListType( + serialized_name="runtimeUri", + ) + + runtime_uri = cls._schema_on_200.value.Element.properties.server.runtime_uri + runtime_uri.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py new file mode 100644 index 00000000000..3e7484335ba --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py @@ -0,0 +1,270 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment show", +) +class Show(AAZCommand): + """Get details of the API deployment. + + :example: Show API deployment details + az apic api deployment show -g api-center-test -s contoso --name production --api-name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.deployment_name = AAZStrArg( + options=["--name", "--deployment", "--deployment-name"], + help="The name of the API deployment.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DeploymentsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.definition_id = AAZStrType( + serialized_name="definitionId", + ) + properties.description = AAZStrType() + properties.environment_id = AAZStrType( + serialized_name="environmentId", + ) + properties.server = AAZObjectType() + properties.state = AAZStrType() + properties.title = AAZStrType() + + server = cls._schema_on_200.properties.server + server.runtime_uri = AAZListType( + serialized_name="runtimeUri", + ) + + runtime_uri = cls._schema_on_200.properties.server.runtime_uri + runtime_uri.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py new file mode 100644 index 00000000000..5d7975177c9 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py @@ -0,0 +1,523 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api deployment update", +) +class Update(AAZCommand): + """Update new or updates existing API deployment. + + :example: Update API deployment + az apic api deployment update -g api-center-test -s contoso --name production --title "Production deployment" --api echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.deployment_name = AAZStrArg( + options=["--name", "--deployment", "--deployment-name"], + help="The name of the API deployment.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + nullable=True, + blank={}, + ) + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + arg_group="Properties", + help="Service-scoped definition resource ID.", + nullable=True, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description of the deployment.", + nullable=True, + fmt=AAZStrArgFormat( + max_length=500, + ), + ) + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + arg_group="Properties", + help="Service-scoped environment resource ID.", + nullable=True, + ) + _args_schema.server = AAZObjectArg( + options=["--server"], + arg_group="Properties", + help="Server", + nullable=True, + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="State of API deployment.", + nullable=True, + enum={"active": "active", "inactive": "inactive"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Title", + nullable=True, + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + server = cls._args_schema.server + server.runtime_uri = AAZListArg( + options=["runtime-uri"], + help="Base runtime URLs for this deployment.", + nullable=True, + ) + + runtime_uri = cls._args_schema.server.runtime_uri + runtime_uri.Element = AAZStrArg( + nullable=True, + fmt=AAZStrArgFormat( + max_length=200, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DeploymentsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.DeploymentsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class DeploymentsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_deployment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class DeploymentsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "deploymentName", self.ctx.args.deployment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_deployment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("definitionId", AAZStrType, ".definition_id") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("environmentId", AAZStrType, ".environment_id") + properties.set_prop("server", AAZObjectType, ".server") + properties.set_prop("state", AAZStrType, ".state") + properties.set_prop("title", AAZStrType, ".title") + + server = _builder.get(".properties.server") + if server is not None: + server.set_prop("runtimeUri", AAZListType, ".runtime_uri") + + runtime_uri = _builder.get(".properties.server.runtimeUri") + if runtime_uri is not None: + runtime_uri.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_deployment_read = None + + @classmethod + def _build_schema_deployment_read(cls, _schema): + if cls._schema_deployment_read is not None: + _schema.id = cls._schema_deployment_read.id + _schema.name = cls._schema_deployment_read.name + _schema.properties = cls._schema_deployment_read.properties + _schema.system_data = cls._schema_deployment_read.system_data + _schema.type = cls._schema_deployment_read.type + return + + cls._schema_deployment_read = _schema_deployment_read = AAZObjectType() + + deployment_read = _schema_deployment_read + deployment_read.id = AAZStrType( + flags={"read_only": True}, + ) + deployment_read.name = AAZStrType( + flags={"read_only": True}, + ) + deployment_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + deployment_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + deployment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_deployment_read.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.definition_id = AAZStrType( + serialized_name="definitionId", + ) + properties.description = AAZStrType() + properties.environment_id = AAZStrType( + serialized_name="environmentId", + ) + properties.server = AAZObjectType() + properties.state = AAZStrType() + properties.title = AAZStrType() + + server = _schema_deployment_read.properties.server + server.runtime_uri = AAZListType( + serialized_name="runtimeUri", + ) + + runtime_uri = _schema_deployment_read.properties.server.runtime_uri + runtime_uri.Element = AAZStrType() + + system_data = _schema_deployment_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_deployment_read.id + _schema.name = cls._schema_deployment_read.name + _schema.properties = cls._schema_deployment_read.properties + _schema.system_data = cls._schema_deployment_read.system_data + _schema.type = cls._schema_deployment_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py new file mode 100644 index 00000000000..9fdf76f0a5f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic api version", +) +class __CMDGroup(AAZCommandGroup): + """API version + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py new file mode 100644 index 00000000000..a6ed8b6688f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py new file mode 100644 index 00000000000..da640e69e57 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py @@ -0,0 +1,290 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version create", +) +class Create(AAZCommand): + """Create new or update existing API version. + + :example: Create API version + az apic api version create -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--name", "--version", "--version-name"], + help="The name of the API version.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.lifecycle_stage = AAZStrArg( + options=["--lifecycle-stage"], + arg_group="Properties", + help="Current lifecycle stage of the API.", + enum={"deprecated": "deprecated", "design": "design", "development": "development", "preview": "preview", "production": "production", "retired": "retired", "testing": "testing"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API version.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiVersionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("lifecycleStage", AAZStrType, ".lifecycle_stage", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py new file mode 100644 index 00000000000..f5d088936fa --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py @@ -0,0 +1,186 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete specified API version + + :example: Delete API version + az apic api version delete -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--name", "--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApiVersionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py new file mode 100644 index 00000000000..342fe97d095 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py @@ -0,0 +1,177 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version head", +) +class Head(AAZCommand): + """Checks if specified API version exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ApiVersionsHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py new file mode 100644 index 00000000000..1df7b2cbb31 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py @@ -0,0 +1,260 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version list", +) +class List(AAZCommand): + """List a collection of API versions. + + :example: List API versions + az apic api version list -g api-center-test -s contosoeuap --api-name echo-api + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ApiVersionsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py new file mode 100644 index 00000000000..ee2fa6e309a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py @@ -0,0 +1,256 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version show", +) +class Show(AAZCommand): + """Get details of the API version. + + :example: Show API version details + az apic api version show -g api-center-test -s contoso --api-name echo-api --name 2023-01-01 + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--name", "--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiVersionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py new file mode 100644 index 00000000000..9af4e2602cd --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py @@ -0,0 +1,445 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic api version update", +) +class Update(AAZCommand): + """Update new or updates existing API version. + + :example: Update API version + az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.api_name = AAZStrArg( + options=["--api", "--api-name"], + help="The name of the API.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.version_name = AAZStrArg( + options=["--name", "--version", "--version-name"], + help="The name of the API version.", + required=True, + id_part="child_name_3", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.lifecycle_stage = AAZStrArg( + options=["--lifecycle-stage"], + arg_group="Properties", + help="Current lifecycle stage of the API.", + enum={"deprecated": "deprecated", "design": "design", "development": "development", "preview": "preview", "production": "production", "retired": "retired", "testing": "testing"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="API version.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ApiVersionsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ApiVersionsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ApiVersionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_api_version_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ApiVersionsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "apiName", self.ctx.args.api_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "versionName", self.ctx.args.version_name, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_api_version_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("lifecycleStage", AAZStrType, ".lifecycle_stage", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_api_version_read = None + + @classmethod + def _build_schema_api_version_read(cls, _schema): + if cls._schema_api_version_read is not None: + _schema.id = cls._schema_api_version_read.id + _schema.name = cls._schema_api_version_read.name + _schema.properties = cls._schema_api_version_read.properties + _schema.system_data = cls._schema_api_version_read.system_data + _schema.type = cls._schema_api_version_read.type + return + + cls._schema_api_version_read = _schema_api_version_read = AAZObjectType() + + api_version_read = _schema_api_version_read + api_version_read.id = AAZStrType( + flags={"read_only": True}, + ) + api_version_read.name = AAZStrType( + flags={"read_only": True}, + ) + api_version_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + api_version_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + api_version_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_api_version_read.properties + properties.lifecycle_stage = AAZStrType( + serialized_name="lifecycleStage", + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = _schema_api_version_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_api_version_read.id + _schema.name = cls._schema_api_version_read.name + _schema.properties = cls._schema_api_version_read.properties + _schema.system_data = cls._schema_api_version_read.system_data + _schema.type = cls._schema_api_version_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py new file mode 100644 index 00000000000..8011cf0897f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic environment", +) +class __CMDGroup(AAZCommandGroup): + """Environment + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py new file mode 100644 index 00000000000..a6ed8b6688f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py new file mode 100644 index 00000000000..0c398be20a8 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py @@ -0,0 +1,367 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment create", +) +class Create(AAZCommand): + """Create new or updates existing environment. + + :example: Create environment + az apic environment create -g api-center-test -s contosoeuap --name public --title "Public cloud" --kind "development" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--name", "--environment", "--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + blank={}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description.", + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="Properties", + help="Environment kind.", + enum={"development": "development", "production": "production", "staging": "staging", "testing": "testing"}, + ) + _args_schema.onboarding = AAZObjectArg( + options=["--onboarding"], + arg_group="Properties", + ) + _args_schema.server = AAZObjectArg( + options=["--server"], + arg_group="Properties", + help="Server information of the environment.", + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Environment title.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + onboarding = cls._args_schema.onboarding + onboarding.developer_portal_uri = AAZListArg( + options=["developer-portal-uri"], + ) + onboarding.instructions = AAZStrArg( + options=["instructions"], + help="Onboarding guide.", + ) + + developer_portal_uri = cls._args_schema.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrArg() + + server = cls._args_schema.server + server.management_portal_uri = AAZListArg( + options=["management-portal-uri"], + ) + server.type = AAZStrArg( + options=["type"], + help="Type of the server that represents the environment.", + enum={"AWS API Gateway": "AWS API Gateway", "Apigee API Management": "Apigee API Management", "Azure API Management": "Azure API Management", "Azure compute service": "Azure compute service", "Kong API Gateway": "Kong API Gateway", "Kubernetes": "Kubernetes", "MuleSoft API Management": "MuleSoft API Management"}, + ) + + management_portal_uri = cls._args_schema.server.management_portal_uri + management_portal_uri.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class EnvironmentsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("onboarding", AAZObjectType, ".onboarding") + properties.set_prop("server", AAZObjectType, ".server") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + onboarding = _builder.get(".properties.onboarding") + if onboarding is not None: + onboarding.set_prop("developerPortalUri", AAZListType, ".developer_portal_uri") + onboarding.set_prop("instructions", AAZStrType, ".instructions") + + developer_portal_uri = _builder.get(".properties.onboarding.developerPortalUri") + if developer_portal_uri is not None: + developer_portal_uri.set_elements(AAZStrType, ".") + + server = _builder.get(".properties.server") + if server is not None: + server.set_prop("managementPortalUri", AAZListType, ".management_portal_uri") + server.set_prop("type", AAZStrType, ".type") + + management_portal_uri = _builder.get(".properties.server.managementPortalUri") + if management_portal_uri is not None: + management_portal_uri.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.onboarding = AAZObjectType() + properties.server = AAZObjectType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + onboarding = cls._schema_on_200_201.properties.onboarding + onboarding.developer_portal_uri = AAZListType( + serialized_name="developerPortalUri", + ) + onboarding.instructions = AAZStrType() + + developer_portal_uri = cls._schema_on_200_201.properties.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrType() + + server = cls._schema_on_200_201.properties.server + server.management_portal_uri = AAZListType( + serialized_name="managementPortalUri", + ) + server.type = AAZStrType() + + management_portal_uri = cls._schema_on_200_201.properties.server.management_portal_uri + management_portal_uri.Element = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py new file mode 100644 index 00000000000..f13fa95c16d --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py @@ -0,0 +1,172 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete the environment. + + :example: Delete environment + az apic environment delete -g api-center-test -s contosoeuap --name public + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--name", "--environment", "--environment-name"], + help="The name of the environment.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class EnvironmentsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py new file mode 100644 index 00000000000..714acd4191d --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py @@ -0,0 +1,163 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment head", +) +class Head(AAZCommand): + """Checks if specified environment exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--name", "--environment", "--environment-name"], + help="The name of the environment.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class EnvironmentsHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py new file mode 100644 index 00000000000..158e9480dfe --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py @@ -0,0 +1,270 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment list", +) +class List(AAZCommand): + """List a collection of environments. + + :example: List environments + az apic environment list -g api-center-test -s contosoeuap + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class EnvironmentsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.onboarding = AAZObjectType() + properties.server = AAZObjectType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + onboarding = cls._schema_on_200.value.Element.properties.onboarding + onboarding.developer_portal_uri = AAZListType( + serialized_name="developerPortalUri", + ) + onboarding.instructions = AAZStrType() + + developer_portal_uri = cls._schema_on_200.value.Element.properties.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrType() + + server = cls._schema_on_200.value.Element.properties.server + server.management_portal_uri = AAZListType( + serialized_name="managementPortalUri", + ) + server.type = AAZStrType() + + management_portal_uri = cls._schema_on_200.value.Element.properties.server.management_portal_uri + management_portal_uri.Element = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py new file mode 100644 index 00000000000..7334504d1a9 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py @@ -0,0 +1,265 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment show", +) +class Show(AAZCommand): + """Get details of the environment. + + :example: Show environment details + az apic environment show -g api-center-test -s contosoeuap --name public + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--name", "--environment", "--environment-name"], + help="The name of the environment.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class EnvironmentsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.onboarding = AAZObjectType() + properties.server = AAZObjectType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + onboarding = cls._schema_on_200.properties.onboarding + onboarding.developer_portal_uri = AAZListType( + serialized_name="developerPortalUri", + ) + onboarding.instructions = AAZStrType() + + developer_portal_uri = cls._schema_on_200.properties.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrType() + + server = cls._schema_on_200.properties.server + server.management_portal_uri = AAZListType( + serialized_name="managementPortalUri", + ) + server.type = AAZStrType() + + management_portal_uri = cls._schema_on_200.properties.server.management_portal_uri + management_portal_uri.Element = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py new file mode 100644 index 00000000000..f10e33f301e --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py @@ -0,0 +1,529 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic environment update", +) +class Update(AAZCommand): + """Update new or updates existing environment. + + :example: Update environment + az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--name", "--environment", "--environment-name"], + help="The name of the environment.", + required=True, + id_part="child_name_2", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.custom_properties = AAZObjectArg( + options=["--custom-properties"], + arg_group="Properties", + help="The custom metadata defined for API catalog entities.", + nullable=True, + blank={}, + ) + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Description.", + nullable=True, + ) + _args_schema.kind = AAZStrArg( + options=["--kind"], + arg_group="Properties", + help="Environment kind.", + enum={"development": "development", "production": "production", "staging": "staging", "testing": "testing"}, + ) + _args_schema.onboarding = AAZObjectArg( + options=["--onboarding"], + arg_group="Properties", + nullable=True, + ) + _args_schema.server = AAZObjectArg( + options=["--server"], + arg_group="Properties", + help="Server information of the environment.", + nullable=True, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Environment title.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + + onboarding = cls._args_schema.onboarding + onboarding.developer_portal_uri = AAZListArg( + options=["developer-portal-uri"], + nullable=True, + ) + onboarding.instructions = AAZStrArg( + options=["instructions"], + help="Onboarding guide.", + nullable=True, + ) + + developer_portal_uri = cls._args_schema.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrArg( + nullable=True, + ) + + server = cls._args_schema.server + server.management_portal_uri = AAZListArg( + options=["management-portal-uri"], + nullable=True, + ) + server.type = AAZStrArg( + options=["type"], + help="Type of the server that represents the environment.", + nullable=True, + enum={"AWS API Gateway": "AWS API Gateway", "Apigee API Management": "Apigee API Management", "Azure API Management": "Azure API Management", "Azure compute service": "Azure compute service", "Kong API Gateway": "Kong API Gateway", "Kubernetes": "Kubernetes", "MuleSoft API Management": "MuleSoft API Management"}, + ) + + management_portal_uri = cls._args_schema.server.management_portal_uri + management_portal_uri.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.EnvironmentsCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class EnvironmentsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_environment_read(cls._schema_on_200) + + return cls._schema_on_200 + + class EnvironmentsCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_environment_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("onboarding", AAZObjectType, ".onboarding") + properties.set_prop("server", AAZObjectType, ".server") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + onboarding = _builder.get(".properties.onboarding") + if onboarding is not None: + onboarding.set_prop("developerPortalUri", AAZListType, ".developer_portal_uri") + onboarding.set_prop("instructions", AAZStrType, ".instructions") + + developer_portal_uri = _builder.get(".properties.onboarding.developerPortalUri") + if developer_portal_uri is not None: + developer_portal_uri.set_elements(AAZStrType, ".") + + server = _builder.get(".properties.server") + if server is not None: + server.set_prop("managementPortalUri", AAZListType, ".management_portal_uri") + server.set_prop("type", AAZStrType, ".type") + + management_portal_uri = _builder.get(".properties.server.managementPortalUri") + if management_portal_uri is not None: + management_portal_uri.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_environment_read = None + + @classmethod + def _build_schema_environment_read(cls, _schema): + if cls._schema_environment_read is not None: + _schema.id = cls._schema_environment_read.id + _schema.name = cls._schema_environment_read.name + _schema.properties = cls._schema_environment_read.properties + _schema.system_data = cls._schema_environment_read.system_data + _schema.type = cls._schema_environment_read.type + return + + cls._schema_environment_read = _schema_environment_read = AAZObjectType() + + environment_read = _schema_environment_read + environment_read.id = AAZStrType( + flags={"read_only": True}, + ) + environment_read.name = AAZStrType( + flags={"read_only": True}, + ) + environment_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + environment_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + environment_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_environment_read.properties + properties.custom_properties = AAZObjectType( + serialized_name="customProperties", + ) + properties.description = AAZStrType() + properties.kind = AAZStrType( + flags={"required": True}, + ) + properties.onboarding = AAZObjectType() + properties.server = AAZObjectType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + onboarding = _schema_environment_read.properties.onboarding + onboarding.developer_portal_uri = AAZListType( + serialized_name="developerPortalUri", + ) + onboarding.instructions = AAZStrType() + + developer_portal_uri = _schema_environment_read.properties.onboarding.developer_portal_uri + developer_portal_uri.Element = AAZStrType() + + server = _schema_environment_read.properties.server + server.management_portal_uri = AAZListType( + serialized_name="managementPortalUri", + ) + server.type = AAZStrType() + + management_portal_uri = _schema_environment_read.properties.server.management_portal_uri + management_portal_uri.Element = AAZStrType() + + system_data = _schema_environment_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_environment_read.id + _schema.name = cls._schema_environment_read.name + _schema.properties = cls._schema_environment_read.properties + _schema.system_data = cls._schema_environment_read.system_data + _schema.type = cls._schema_environment_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py new file mode 100644 index 00000000000..dc9dc8ecea3 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic metadata-schema", +) +class __CMDGroup(AAZCommandGroup): + """Metadata schema + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py new file mode 100644 index 00000000000..6d0e5820c01 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._export_metadata_schema import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py new file mode 100644 index 00000000000..44833b8ee3a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py @@ -0,0 +1,290 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema create", +) +class Create(AAZCommand): + """Create new or updates existing metadata schema. + + :example: Create schema + az az apic metadata-schema create --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"First name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.metadata_schema_name = AAZStrArg( + options=["--name", "--metadata-schema", "--metadata-schema-name"], + help="The name of the metadata schema.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.assigned_to = AAZListArg( + options=["--assigned-to"], + arg_group="Properties", + ) + _args_schema.schema = AAZStrArg( + options=["--schema"], + arg_group="Properties", + help="JSON schema defining the type.", + ) + + assigned_to = cls._args_schema.assigned_to + assigned_to.Element = AAZObjectArg() + + _element = cls._args_schema.assigned_to.Element + _element.deprecated = AAZBoolArg( + options=["deprecated"], + ) + _element.entity = AAZStrArg( + options=["entity"], + help="The entities this metadata schema component gets applied to.", + enum={"api": "api", "deployment": "deployment", "environment": "environment"}, + ) + _element.required = AAZBoolArg( + options=["required"], + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class MetadataSchemasCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("assignedTo", AAZListType, ".assigned_to") + properties.set_prop("schema", AAZStrType, ".schema", typ_kwargs={"flags": {"required": True}}) + + assigned_to = _builder.get(".properties.assignedTo") + if assigned_to is not None: + assigned_to.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.assignedTo[]") + if _elements is not None: + _elements.set_prop("deprecated", AAZBoolType, ".deprecated") + _elements.set_prop("entity", AAZStrType, ".entity") + _elements.set_prop("required", AAZBoolType, ".required") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.assigned_to = AAZListType( + serialized_name="assignedTo", + ) + properties.schema = AAZStrType( + flags={"required": True}, + ) + + assigned_to = cls._schema_on_200_201.properties.assigned_to + assigned_to.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.assigned_to.Element + _element.deprecated = AAZBoolType() + _element.entity = AAZStrType() + _element.required = AAZBoolType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py new file mode 100644 index 00000000000..f43943f8e96 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py @@ -0,0 +1,160 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete specified metadata schema. + + :example: Delete Metadata Schema + az az apic metadata-schema delete --resource-group api-center-test --service-name contoso --name "test1" + + :example: Delete schema + az apic metadata-schema delete -g api-center-test -s contosoeuap --name "approver" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.metadata_schema_name = AAZStrArg( + options=["--name", "--metadata-schema", "--metadata-schema-name"], + help="The name of the metadata schema.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class MetadataSchemasDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py new file mode 100644 index 00000000000..c70a73a0aea --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py @@ -0,0 +1,217 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema export-metadata-schema", +) +class ExportMetadataSchema(AAZCommand): + """Exports the effective metadata schema. + + :example: Export Metadata Schema assigned to api + az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to api --file-name filepath + + :example: Export Metadata Schema assigned to deployment + az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to deployment --file-name filepath + + :example: Export Metadata Schema assigned to environment + az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to environment --file-name filepath + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/exportmetadataschema", "2024-03-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--name", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Payload" + + _args_schema = cls._args_schema + _args_schema.assigned_to = AAZStrArg( + options=["--assigned-to"], + arg_group="Payload", + help="An entity the metadata schema is requested for.", + enum={"api": "api", "deployment": "deployment", "environment": "environment"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.ServicesExportMetadataSchema(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ServicesExportMetadataSchema(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("assignedTo", AAZStrType, ".assigned_to") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.format = AAZStrType() + _schema_on_200.value = AAZStrType() + + return cls._schema_on_200 + + +class _ExportMetadataSchemaHelper: + """Helper class for ExportMetadataSchema""" + + +__all__ = ["ExportMetadataSchema"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py new file mode 100644 index 00000000000..e711e70be17 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py @@ -0,0 +1,148 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema head", +) +class Head(AAZCommand): + """Checks if specified metadata schema exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.metadata_schema_name = AAZStrArg( + options=["--name", "--metadata-schema", "--metadata-schema-name"], + help="The name of the metadata schema.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class MetadataSchemasHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py new file mode 100644 index 00000000000..9c37ddd3c5a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema list", +) +class List(AAZCommand): + """List a collection of metadata schemas. + + :example: List schemas + az apic metadata-schema list -g api-center-test -s contosoeuap + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class MetadataSchemasList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.assigned_to = AAZListType( + serialized_name="assignedTo", + ) + properties.schema = AAZStrType( + flags={"required": True}, + ) + + assigned_to = cls._schema_on_200.value.Element.properties.assigned_to + assigned_to.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.assigned_to.Element + _element.deprecated = AAZBoolType() + _element.entity = AAZStrType() + _element.required = AAZBoolType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py new file mode 100644 index 00000000000..1a5cc17a037 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py @@ -0,0 +1,237 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema show", +) +class Show(AAZCommand): + """Get details of the metadata schema. + + :example: Show schema details 1 + az apic metadata-schema show -g api-center-test -s contosoeuap --name approver + + :example: Show schema details 2 + az az apic metadata-schema show --resource-group api-center-test --service-name contoso --name "testchoices" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.metadata_schema_name = AAZStrArg( + options=["--name", "--metadata-schema", "--metadata-schema-name"], + help="The name of the metadata schema.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class MetadataSchemasGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.assigned_to = AAZListType( + serialized_name="assignedTo", + ) + properties.schema = AAZStrType( + flags={"required": True}, + ) + + assigned_to = cls._schema_on_200.properties.assigned_to + assigned_to.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.assigned_to.Element + _element.deprecated = AAZBoolType() + _element.entity = AAZStrType() + _element.required = AAZBoolType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py new file mode 100644 index 00000000000..77987d7e7ff --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py @@ -0,0 +1,442 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic metadata-schema update", +) +class Update(AAZCommand): + """Update new or updates existing metadata schema. + + :example: Update schema + az az apic metadata-schema update --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"Last name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.metadata_schema_name = AAZStrArg( + options=["--name", "--metadata-schema", "--metadata-schema-name"], + help="The name of the metadata schema.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.assigned_to = AAZListArg( + options=["--assigned-to"], + arg_group="Properties", + nullable=True, + ) + _args_schema.schema = AAZStrArg( + options=["--schema"], + arg_group="Properties", + help="YAML schema defining the type.", + ) + + assigned_to = cls._args_schema.assigned_to + assigned_to.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.assigned_to.Element + _element.deprecated = AAZBoolArg( + options=["deprecated"], + nullable=True, + ) + _element.entity = AAZStrArg( + options=["entity"], + help="The entities this metadata schema component gets applied to.", + nullable=True, + enum={"api": "api", "deployment": "deployment", "environment": "environment"}, + ) + _element.required = AAZBoolArg( + options=["required"], + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetadataSchemasGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.MetadataSchemasCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class MetadataSchemasGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_metadata_schema_read(cls._schema_on_200) + + return cls._schema_on_200 + + class MetadataSchemasCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "metadataSchemaName", self.ctx.args.metadata_schema_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_metadata_schema_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("assignedTo", AAZListType, ".assigned_to") + properties.set_prop("schema", AAZStrType, ".schema", typ_kwargs={"flags": {"required": True}}) + + assigned_to = _builder.get(".properties.assignedTo") + if assigned_to is not None: + assigned_to.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.assignedTo[]") + if _elements is not None: + _elements.set_prop("deprecated", AAZBoolType, ".deprecated") + _elements.set_prop("entity", AAZStrType, ".entity") + _elements.set_prop("required", AAZBoolType, ".required") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_metadata_schema_read = None + + @classmethod + def _build_schema_metadata_schema_read(cls, _schema): + if cls._schema_metadata_schema_read is not None: + _schema.id = cls._schema_metadata_schema_read.id + _schema.name = cls._schema_metadata_schema_read.name + _schema.properties = cls._schema_metadata_schema_read.properties + _schema.system_data = cls._schema_metadata_schema_read.system_data + _schema.type = cls._schema_metadata_schema_read.type + return + + cls._schema_metadata_schema_read = _schema_metadata_schema_read = AAZObjectType() + + metadata_schema_read = _schema_metadata_schema_read + metadata_schema_read.id = AAZStrType( + flags={"read_only": True}, + ) + metadata_schema_read.name = AAZStrType( + flags={"read_only": True}, + ) + metadata_schema_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + metadata_schema_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + metadata_schema_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_metadata_schema_read.properties + properties.assigned_to = AAZListType( + serialized_name="assignedTo", + ) + properties.schema = AAZStrType( + flags={"required": True}, + ) + + assigned_to = _schema_metadata_schema_read.properties.assigned_to + assigned_to.Element = AAZObjectType() + + _element = _schema_metadata_schema_read.properties.assigned_to.Element + _element.deprecated = AAZBoolType() + _element.entity = AAZStrType() + _element.required = AAZBoolType() + + system_data = _schema_metadata_schema_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_metadata_schema_read.id + _schema.name = cls._schema_metadata_schema_read.name + _schema.properties = cls._schema_metadata_schema_read.properties + _schema.system_data = cls._schema_metadata_schema_read.system_data + _schema.type = cls._schema_metadata_schema_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py new file mode 100644 index 00000000000..2b089d505b9 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic service", +) +class __CMDGroup(AAZCommandGroup): + """API Center service + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py new file mode 100644 index 00000000000..882d6e628e4 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py @@ -0,0 +1,319 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic service create", +) +class Create(AAZCommand): + """Create an instance of Azure API Center service. + + :example: Create service + az apic create -g contoso-resources -s contoso + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--name", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Payload" + + _args_schema = cls._args_schema + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="Payload", + help="Managed service identity (system assigned and/or user assigned identities)", + ) + _args_schema.location = AAZResourceLocationArg( + arg_group="Payload", + help="The geo-location where the resource lives", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Payload", + help="Resource tags.", + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ServicesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ServicesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"client_flatten": True}} + ) + _builder.set_prop("identity", AAZObjectType, ".identity") + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.identity = AAZObjectType() + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py new file mode 100644 index 00000000000..59236ef72eb --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py @@ -0,0 +1,143 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic service delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete service + + :example: Delete service + az apic service delete -s contoso -g contoso-resources + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--name", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ServicesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class ServicesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py new file mode 100644 index 00000000000..eabdc18a9da --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py @@ -0,0 +1,420 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic service list", +) +class List(AAZCommand): + """List services within an Azure subscription. + + :example: List services in resource group + az apic list -g contoso-resources + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.apicenter/services", "2024-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.ServicesListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.ServicesListBySubscription(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class ServicesListByResourceGroup(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class ServicesListBySubscription(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/services", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.identity = AAZObjectType() + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py new file mode 100644 index 00000000000..3cb8512041b --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py @@ -0,0 +1,249 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic service show", +) +class Show(AAZCommand): + """Show service details + + :example: Show service details + az apic service show -g contoso-resources -s contoso + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--name", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ServicesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ServicesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py new file mode 100644 index 00000000000..325353c3a0e --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py @@ -0,0 +1,462 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic service update", +) +class Update(AAZCommand): + """Update service + + :example: Update service details + az apic update -g contoso-resources -s contoso + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--name", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Payload" + + _args_schema = cls._args_schema + _args_schema.identity = AAZObjectArg( + options=["--identity"], + arg_group="Payload", + help="Managed service identity (system assigned and/or user assigned identities)", + nullable=True, + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Payload", + help="Resource tags.", + nullable=True, + ) + + identity = cls._args_schema.identity + identity.type = AAZStrArg( + options=["type"], + help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, + ) + identity.user_assigned_identities = AAZDictArg( + options=["user-assigned-identities"], + help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", + nullable=True, + ) + + user_assigned_identities = cls._args_schema.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectArg( + nullable=True, + blank={}, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ServicesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.ServicesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class ServicesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_service_read(cls._schema_on_200) + + return cls._schema_on_200 + + class ServicesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_service_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("identity", AAZObjectType, ".identity") + _builder.set_prop("tags", AAZDictType, ".tags") + + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) + identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities") + + user_assigned_identities = _builder.get(".identity.userAssignedIdentities") + if user_assigned_identities is not None: + user_assigned_identities.set_elements(AAZObjectType, ".", typ_kwargs={"nullable": True}) + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_service_read = None + + @classmethod + def _build_schema_service_read(cls, _schema): + if cls._schema_service_read is not None: + _schema.id = cls._schema_service_read.id + _schema.identity = cls._schema_service_read.identity + _schema.location = cls._schema_service_read.location + _schema.name = cls._schema_service_read.name + _schema.properties = cls._schema_service_read.properties + _schema.system_data = cls._schema_service_read.system_data + _schema.tags = cls._schema_service_read.tags + _schema.type = cls._schema_service_read.type + return + + cls._schema_service_read = _schema_service_read = AAZObjectType() + + service_read = _schema_service_read + service_read.id = AAZStrType( + flags={"read_only": True}, + ) + service_read.identity = AAZObjectType() + service_read.location = AAZStrType( + flags={"required": True}, + ) + service_read.name = AAZStrType( + flags={"read_only": True}, + ) + service_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + service_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + service_read.tags = AAZDictType() + service_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_service_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_service_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_service_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_service_read.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = _schema_service_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_service_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_service_read.id + _schema.identity = cls._schema_service_read.identity + _schema.location = cls._schema_service_read.location + _schema.name = cls._schema_service_read.name + _schema.properties = cls._schema_service_read.properties + _schema.system_data = cls._schema_service_read.system_data + _schema.tags = cls._schema_service_read.tags + _schema.type = cls._schema_service_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__cmd_group.py new file mode 100644 index 00000000000..8309c41f39f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "apic workspace", +) +class __CMDGroup(AAZCommandGroup): + """Workspace + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__init__.py new file mode 100644 index 00000000000..a6ed8b6688f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._head import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_create.py new file mode 100644 index 00000000000..5fbc05a9f16 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_create.py @@ -0,0 +1,260 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace create", +) +class Create(AAZCommand): + """Create new or updates existing workspace. + + :example: Create workspace + az apic workspace create -g api-center-test -s contoso --name devdiv --title "Developer division" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--name", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Workspace description.", + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Workspace display name.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class WorkspacesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.description = AAZStrType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_delete.py new file mode 100644 index 00000000000..4ff3c2f816e --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_delete.py @@ -0,0 +1,158 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete specified workspace. + + :example: Delete workspace + az apic workspace delete -g api-center-test -s contoso --name devdiv + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--name", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class WorkspacesDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_head.py new file mode 100644 index 00000000000..4c5a0b114c1 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_head.py @@ -0,0 +1,149 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace head", +) +class Head(AAZCommand): + """Checks if specified workspace exists. + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--name", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesHead(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class WorkspacesHead(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "HEAD" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _HeadHelper: + """Helper class for Head""" + + +__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_list.py new file mode 100644 index 00000000000..17c8805cde7 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_list.py @@ -0,0 +1,230 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace list", +) +class List(AAZCommand): + """List a collection of workspaces. + + :example: List workspaces + az apic workspace list -g api-center-test -s contoso --name devdiv + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces", "2024-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.filter = AAZStrArg( + options=["--filter"], + help="OData filter parameter.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class WorkspacesList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "$filter", self.ctx.args.filter, + ), + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + _schema_on_200.value = AAZListType( + flags={"read_only": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.description = AAZStrType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_show.py new file mode 100644 index 00000000000..a55f27e818e --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_show.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace show", +) +class Show(AAZCommand): + """Get details of the workspace. + + :example: Show workspace details + az apic workspace show -g api-center-test -s contoso --name devdiv + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}", "2024-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--name", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + default="default", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class WorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.description = AAZStrType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_update.py new file mode 100644 index 00000000000..89affd800c9 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/workspace/_update.py @@ -0,0 +1,406 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "apic workspace update", +) +class Update(AAZCommand): + """Update new or updates existing workspace. + + :example: Update workspace + az apic workspace update -g api-center-test -s contoso --name devdiv --title "Developer division" + """ + + _aaz_info = { + "version": "2024-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}", "2024-03-01"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.service_name = AAZStrArg( + options=["-s", "--service", "--service-name"], + help="The name of the API Center service.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + _args_schema.workspace_name = AAZStrArg( + options=["-w", "--name", "--workspace", "--workspace-name"], + help="The name of the workspace.", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + max_length=90, + min_length=1, + ), + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.description = AAZStrArg( + options=["--description"], + arg_group="Properties", + help="Workspace description.", + nullable=True, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="Workspace display name.", + fmt=AAZStrArgFormat( + max_length=50, + min_length=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.WorkspacesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.WorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class WorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + _UpdateHelper._build_schema_workspace_read(cls._schema_on_200) + + return cls._schema_on_200 + + class WorkspacesCreateOrUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "serviceName", self.ctx.args.service_name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "workspaceName", self.ctx.args.workspace_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-03-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_workspace_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("description", AAZStrType, ".description") + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_workspace_read = None + + @classmethod + def _build_schema_workspace_read(cls, _schema): + if cls._schema_workspace_read is not None: + _schema.id = cls._schema_workspace_read.id + _schema.name = cls._schema_workspace_read.name + _schema.properties = cls._schema_workspace_read.properties + _schema.system_data = cls._schema_workspace_read.system_data + _schema.type = cls._schema_workspace_read.type + return + + cls._schema_workspace_read = _schema_workspace_read = AAZObjectType() + + workspace_read = _schema_workspace_read + workspace_read.id = AAZStrType( + flags={"read_only": True}, + ) + workspace_read.name = AAZStrType( + flags={"read_only": True}, + ) + workspace_read.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + workspace_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + workspace_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_workspace_read.properties + properties.description = AAZStrType() + properties.title = AAZStrType( + flags={"required": True}, + ) + + system_data = _schema_workspace_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.id = cls._schema_workspace_read.id + _schema.name = cls._schema_workspace_read.name + _schema.properties = cls._schema_workspace_read.properties + _schema.system_data = cls._schema_workspace_read.system_data + _schema.type = cls._schema_workspace_read.type + + +__all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/azext_metadata.json b/src/apic-extension/azext_apic_extension/azext_metadata.json new file mode 100644 index 00000000000..24862c32571 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.51.0" +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/commands.py b/src/apic-extension/azext_apic_extension/commands.py new file mode 100644 index 00000000000..c4ea801b8de --- /dev/null +++ b/src/apic-extension/azext_apic_extension/commands.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType +from .custom import ImportSpecificationExtension +from .custom import ExportSpecificationExtension +from .custom import ExportMetadataSchemaExtension +from .custom import CreateMetadataSchemaExtension +from .custom import UpdateMetadataSchemaExtension + + +def load_command_table(self, _): # pylint: disable=unused-argument + with self.command_group('apic api definition') as g: + self.command_table['apic api definition import-specification'] = ImportSpecificationExtension(loader=self) + self.command_table['apic api definition export-specification'] = ExportSpecificationExtension(loader=self) + with self.command_group('apic metadata-schema') as g: + self.command_table['apic metadata-schema create'] = CreateMetadataSchemaExtension(loader=self) + self.command_table['apic metadata-schema update'] = UpdateMetadataSchemaExtension(loader=self) + self.command_table['apic metadata-schema export-metadata-schema'] = ExportMetadataSchemaExtension(loader=self) + with self.command_group('apic api') as g: + g.custom_command("register", "register_apic") diff --git a/src/apic-extension/azext_apic_extension/custom.py b/src/apic-extension/azext_apic_extension/custom.py new file mode 100644 index 00000000000..b9d015ded75 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/custom.py @@ -0,0 +1,476 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements +# pylint: disable=line-too-long +# pylint: disable=too-many-locals + +import os +import sys +import json +import requests +from knack.log import get_logger +import chardet +from azure.cli.core.aaz._arg import AAZStrArg +from .aaz.latest.apic.api.definition import ImportSpecification +from .aaz.latest.apic.api.definition import ExportSpecification +from .aaz.latest.apic.metadata_schema import Create +from .aaz.latest.apic.metadata_schema import Update +from .aaz.latest.apic.metadata_schema import ExportMetadataSchema + +logger = get_logger(__name__) + + +class ImportSpecificationExtension(ImportSpecification): + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_profile = AAZStrArg( + options=["--file-name"], + help='Name of the file from where to import the spec from.', + required=False, + registered=True + ) + return args_schema + + def pre_operations(self): + args = self.ctx.args + data = None + value = None + + # Load the JSON file + if args.source_profile: + with open(str(args.source_profile), 'rb') as f: + data = f.read() + result = chardet.detect(data) + encoding = result['encoding'] + + with open(str(args.source_profile), 'r', encoding=encoding) as f: + data = json.load(f) + if data: + value = json.dumps(data) + + # If any of the fields are None, get them from self.args + if value is None: + value = args.value + + # Reassign the values to self.args + args.value = value + + # Check the size of 'value' if format is inline and raise error if value is greater than 3 mb + if args.format == 'inline': + value_size_bytes = sys.getsizeof(args.value) + value_size_mb = value_size_bytes / (1024 * 1024) # Convert bytes to megabytes + if value_size_mb > 3: + logger.error('The size of "value" is greater than 3 MB. ' + 'Please use --format "url" to import the specification from a URL for size greater than 3 mb.') + + +class ExportSpecificationExtension(ExportSpecification): + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_profile = AAZStrArg( + options=["--file-name"], + help='Name of the file where to export the spec to.', + required=True, + registered=True + ) + return args_schema + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + arguments = self.ctx.args + + if result: + response_format = result['format'] + exportedResults = result['value'] + + if response_format == 'link': + logger.warning('Fetching specification from: %s', exportedResults) + getReponse = requests.get(exportedResults, timeout=10) + if getReponse.status_code == 200: + exportedResults = getReponse.content.decode() + else: + logger.error('Error while fetching the results from the link.' + 'Status code: %s', getReponse.status_code) + + if arguments.source_profile: + try: + self.writeResultsToFile(results=exportedResults, file_name=str(arguments.source_profile)) + logger.warning('Results exported to %s', arguments.source_profile) + except Exception as e: # pylint: disable=broad-except + logger.error('Error while writing the results to the file. Error: %s', e) + else: + logger.error('Please provide the --file-name to exports the results to.') + else: + logger.error('No results found.') + + def writeResultsToFile(self, results, file_name): + if file_name: + with open(file_name, 'w', encoding='utf-8') as f: + if os.path.splitext(file_name)[1] == '.json': + if isinstance(results, str): + results = json.loads(results) + json.dump(results, f, indent=4, separators=(',', ':')) + else: + f.write(results) + + +class CreateMetadataSchemaExtension(Create): + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_profile = AAZStrArg( + options=["--file-name"], + help='Name of the file from that contains the metadata schema.', + required=False, + registered=True + ) + return args_schema + + def pre_operations(self): + args = self.ctx.args + data = None + value = args.schema + + # Load the JSON file + if args.source_profile: + with open(str(args.source_profile), 'rb') as f: + data = f.read() + result = chardet.detect(data) + encoding = result['encoding'] + + if os.stat(str(args.source_profile)).st_size == 0: + raise ValueError('Metadtata schema file is empty. Please provide a valid metadata schema file.') + + with open(str(args.source_profile), 'r', encoding=encoding) as f: + data = json.load(f) + if data: + value = json.dumps(data) + + # If any of the fields are None, get them from self.args + if value is None: + logger.error('Please provide the schema to create the metadata schema' + 'through --schema option or through --file-name option via a file.') + + # Reassign the values to self.args + self.ctx.args.schema = value + + +class UpdateMetadataSchemaExtension(Update): + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_profile = AAZStrArg( + options=["--file-name"], + help='Name of the file from that contains the metadata schema.', + required=False, + registered=True + ) + return args_schema + + def pre_operations(self): + args = self.ctx.args + data = None + value = args.schema + + # Load the JSON file + if args.source_profile: + with open(str(args.source_profile), 'rb') as f: + rawdata = f.read() + result = chardet.detect(rawdata) + encoding = result['encoding'] + + if os.stat(str(args.source_profile)).st_size == 0: + raise ValueError('Metadtata schema file is empty. Please provide a valid metadata schema file.') + + with open(str(args.source_profile), 'r', encoding=encoding) as f: + data = json.load(f) + if data: + value = json.dumps(data) + + # If any of the fields are None, get them from self.args + if value is None: + logger.error('Please provide the schema to update the metadata schema ' + 'through --schema option or through --file-name option via a file.') + + # Reassign the values to self.args + self.ctx.args.schema = value + + +class ExportMetadataSchemaExtension(ExportMetadataSchema): + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_profile = AAZStrArg( + options=["--file-name"], + help='Name of the file where to export the metadata schema to.', + required=True, + registered=True + ) + return args_schema + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + arguments = self.ctx.args + + if result: + response_format = result['format'] + exportedResults = result['value'] + + if response_format == 'link': + getReponse = requests.get(exportedResults, timeout=10) + if getReponse.status_code == 200: + exportedResults = getReponse.content.decode() + else: + logger.error('Error while fetching the results from the link. Status code: %s', getReponse.status_code) + + if arguments.source_profile: + try: + self.writeResultsToFile(results=exportedResults, file_name=str(arguments.source_profile)) + logger.warning('Results exported to %s', arguments.source_profile) + + except Exception as e: # pylint: disable=broad-except + logger.error('Error while writing the results to the file. Error: %s', e) + else: + logger.error('Please provide the --file-name to exports the results to.') + else: + logger.error('No results found.') + + def writeResultsToFile(self, results, file_name): + if file_name: + with open(file_name, 'w', encoding='utf-8') as f: + if os.path.splitext(file_name)[1] == '.json': + if isinstance(results, str): + results = json.loads(results) + json.dump(results, f, indent=4, separators=(',', ':')) + else: + f.write(results) + + +# Quick Import +def register_apic(cmd, api_location, resource_group, service_name, environment_name=None): + + # Load the JSON file + if api_location: + + # TODO Future Confirm its a file and not link + with open(str(api_location), 'rb') as f: + rawdata = f.read() + result = chardet.detect(rawdata) + encoding = result['encoding'] + + # TODO - read other file types later + with open(str(api_location), 'r', encoding=encoding) as f: + data = json.load(f) + if data: + value = json.dumps(data) + + # If we could not read the file, return error + if value is None: + logger.error('Could not load json file') + return + + # Check if the first field is 'swagger', 'openapi', or something else and get the definition name and version + first_key, first_value = list(data.items())[0] + if first_key in ['swagger', 'openapi']: + extracted_definition_name = 'openapi' + extracted_definition_version = first_value.replace(".", "-").lower() + extracted_api_kind = 'rest' # TODO determine kind from spec + else: + extracted_definition_name = 'default' + extracted_definition_version = 'v1' + extracted_api_kind = 'rest' + # TODO how to determine other kinds - enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"} + + # Create API and Create API Version + info = data['info'] + if info: + # Create API and Create API Version + extracted_api_name = info.get('title', 'Default API').replace(" ", "-").lower() + extracted_api_description = info.get('description', 'API Description') + extracted_api_summary = info.get('summary', extracted_api_description) + extracted_api_title = info.get('title', 'API Title').replace(" ", "-").lower() + extracted_api_version = info.get('version', 'v1').replace(".", "-").lower() + extracted_api_version_title = info.get('version', 'v1').replace(".", "-").lower() + # TODO -Create API Version lifecycle_stage + + # Create API - Get the contact details from info in spec + contact = info.get('contact') + if contact: + extracted_api_contact_email = contact.get('email') + extracted_api_contact_name = contact.get('name') + extracted_api_contact_url = contact.get('url') + contacts = [{'email': extracted_api_contact_email, 'name': extracted_api_contact_name, 'url': extracted_api_contact_url}] + else: + contacts = None + + # Create API - Get the license details from info in spec + licenseDetails = info.get('license') + if licenseDetails: + extracted_api_license_identifier = licenseDetails.get('identifier') + extracted_api_license_name = licenseDetails.get('name') + extracted_api_license_url = licenseDetails.get('url') + extracted_api_license = {'identifier': extracted_api_license_identifier, 'name': extracted_api_license_name, 'url': extracted_api_license_url} + else: + extracted_api_license = None + + # Create API - Get the terms of service from info in spec + extracted_api_terms_of_service_value = info.get('termsOfService') + if extracted_api_terms_of_service_value: + extracted_api_terms_of_service = {'url': extracted_api_terms_of_service_value} + else: + extracted_api_terms_of_service = {'url': None} + + # Create API - Get the external documentation from info in spec + extracted_api_external_documentation = None + external_documentation = info.get('externalDocumentation') + if external_documentation: + extracted_api_external_documentation_description = external_documentation.get('description') + extracted_api_external_documentation_title = external_documentation.get('title') + extracted_api_external_documentation_url = external_documentation.get('url') + extracted_api_external_documentation = {'description': extracted_api_external_documentation_description, 'title': extracted_api_external_documentation_title, 'url': extracted_api_external_documentation_url} + else: + extracted_api_external_documentation = None + + # TODO: Create API - custom-properties + # "The custom metadata defined for API catalog entities. #1 + + # Create API ------------------------------------------------------------------------------------- + from .aaz.latest.apic.api import Create as CreateAPI + + api_args = { + 'api_name': extracted_api_name, + 'resource_group': resource_group, + 'service_name': service_name, + 'workspace_name': 'default', + 'title': extracted_api_title, + 'summary': extracted_api_summary, + 'kind': extracted_api_kind, + 'contacts': contacts, + 'license': extracted_api_license, + 'terms_of_service': extracted_api_terms_of_service, + 'external_documentation': extracted_api_external_documentation, + 'description': extracted_api_description, + } + + CreateAPI(cli_ctx=cmd.cli_ctx)(command_args=api_args) + logger.warning('API was created successfully') + + # Create API Version ----------------------------------------------------------------------------- + from .aaz.latest.apic.api.version import Create as CreateAPIVersion + + api_version_args = { + 'api_name': extracted_api_name, + 'resource_group': resource_group, + 'service_name': service_name, + 'version_name': extracted_api_version, + 'workspace_name': 'default', + 'lifecycle_stage': 'design', # TODO: Extract from spec or not pass. was it required? + 'title': extracted_api_version_title + } + + CreateAPIVersion(cli_ctx=cmd.cli_ctx)(command_args=api_version_args) + logger.warning('API version was created successfully') + + # Create API Definition ----------------------------------------------------------------------------- + from .aaz.latest.apic.api.definition import Create as CreateAPIDefinition + + api_definition_args = { + 'api_name': extracted_api_name, + 'resource_group': resource_group, + 'service_name': service_name, + 'version_name': extracted_api_version, + 'workspace_name': 'default', + 'definition_name': extracted_definition_name, + 'title': extracted_definition_name, # TODO Extract from spec + 'description': extracted_api_description, # TODO Extract from spec + } + + CreateAPIDefinition(cli_ctx=cmd.cli_ctx)(command_args=api_definition_args) + logger.warning('API definition was created successfully') + + # Import Specification ----------------------------------------------------------------------------- + from azure.cli.core.commands import LongRunningOperation + + # uses customized ImportSpecificationExtension class + specification_details = {'name': extracted_definition_name, 'version': extracted_definition_version} + # TODO format - Link - what if the link is just pasted in the value? + # TODO format - inline - what if spec is just pasted in the value? + # TODO - other non json spec formats + + api_specification_args = { + 'resource_group': resource_group, + 'service_name': service_name, + 'workspace_name': 'default', + 'api_name': extracted_api_name, + 'version_name': extracted_api_version, + 'definition_name': extracted_definition_name, + 'format': 'inline', + 'specification': specification_details, # TODO write the correct spec object + 'source_profile': api_location + } + + importAPISpecificationResults = ImportSpecificationExtension(cli_ctx=cmd.cli_ctx)(command_args=api_specification_args) + LongRunningOperation(cmd.cli_ctx)(importAPISpecificationResults) + logger.warning('API specification was created successfully') + + # Create API Deployment ----------------------------------------------------------------------------- + from .aaz.latest.apic.api.deployment import Create as CreateAPIDeployment + from .aaz.latest.apic.environment import Show as GetEnvironment + + environment_id = None + if environment_name: + # GET Environment ID + environment_args = { + 'resource_group': resource_group, + 'service_name': service_name, + 'workspace_name': 'default', + 'environment_name': environment_name + } + + getEnvironmentResults = GetEnvironment(cli_ctx=cmd.cli_ctx)(command_args=environment_args) + environment_id = getEnvironmentResults['id'] + # full envId, extract actual envId if to be used later + + servers = data.get('servers') + if environment_id and servers: + for server in servers: + default_deployment_title = (extracted_api_name + "deployment").replace("-", "") + extracted_deployment_name = server.get('name', default_deployment_title).replace(" ", "-") + extracted_deployment_title = server.get('title', default_deployment_title).replace(" ", "-") + extracted_deployment_description = server.get('description', default_deployment_title) + extracted_definition_id = '/workspaces/default/apis/' + extracted_api_name + '/versions/' + extracted_api_version + '/definitions/' + extracted_definition_name + extracted_environment_id = '/workspaces/default/environments/' + environment_name + extracted_state = server.get('state', 'active') + + extracted_server_urls = [] + extracted_server_url = server.get('url') + extracted_server_urls.append(extracted_server_url) + extracted_server = {'runtime_uri': extracted_server_urls} + + api_deployment_args = { + 'resource_group': resource_group, + 'service_name': service_name, + 'workspace_name': 'default', + 'api_name': extracted_api_name, + 'deployment_name': extracted_deployment_name, + 'description': extracted_deployment_description, + 'title': extracted_deployment_title, + 'definition_id': extracted_definition_id, + 'environment_id': extracted_environment_id, + 'server': extracted_server, + 'state': extracted_state + # TODO custom properties + } + + CreateAPIDeployment(cli_ctx=cmd.cli_ctx)(command_args=api_deployment_args) + logger.warning('API deployment was created successfully') diff --git a/src/apic-extension/azext_apic_extension/tests/__init__.py b/src/apic-extension/azext_apic_extension/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/apic-extension/azext_apic_extension/tests/latest/__init__.py b/src/apic-extension/azext_apic_extension/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_api.json b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_api.json new file mode 100644 index 00000000000..1ab65409b68 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_api.json @@ -0,0 +1,177 @@ +{ + "type":"object", + "properties":{ + "title":{ + "description":"The name of the API.", + "type":"string", + "maxLength":50 + }, + "summary":{ + "description":"Short description of the API.", + "type":"string", + "maxLength":200 + }, + "description":{ + "description":"The description of the API.", + "type":"string", + "maxLength":1000 + }, + "kind":{ + "description":"Kind of API. For example, REST or GraphQL.", + "type":"string" + }, + "lifecycleStage":{ + "description":"Current lifecycle stage of the API.", + "type":"string", + "enum":[ + "design", + "development", + "testing", + "preview", + "production", + "deprecated", + "retired" + ] + }, + "termsOfService":{ + "description":"Terms of service for the API.", + "type":"object", + "properties":{ + "url":{ + "description":"URL pointing to the terms of service.", + "type":"string", + "maxLength":200, + "format":"uri" + } + } + }, + "license":{ + "description":"The license information for the API.", + "type":"object", + "properties":{ + "name":{ + "description":"Name of the license.", + "type":"string", + "maxLength":50 + }, + "url":{ + "description":"URL pointing to the license details. The URL field is mutually exclusive of the identifier field.", + "type":"string", + "maxLength":200, + "format":"uri" + }, + "identifier":{ + "description":"SPDX license information for the API. The identifier field is mutually exclusive of the URL field.", + "type":"string", + "maxLength":200, + "format":"uri" + } + } + }, + "externalDocumentation":{ + "description":"External documentation", + "type":"array", + "items":{ + "type":"object", + "properties":{ + "title":{ + "description":"Title of the documentation.", + "type":"string", + "maxLength":50 + }, + "description":{ + "description":"Description of the documentation.", + "type":"string", + "maxLength":1000 + }, + "url":{ + "description":"URL pointing to the documentation.", + "type":"string", + "maxLength":200, + "format":"uri" + } + } + }, + "maxItems":20 + }, + "contacts":{ + "description":"Points of contact for the API.", + "type":"array", + "items":{ + "type":"object", + "properties":{ + "name":{ + "description":"Name of the contact.", + "type":"string", + "maxLength":100 + }, + "url":{ + "description":"URL for the contact.", + "type":"string", + "maxLength":200, + "format":"uri" + }, + "email":{ + "description":"Email address for the contact.", + "type":"string", + "maxLength":100, + "format":"email" + } + } + }, + "maxItems":10 + }, + "customProperties":{ + "type":"object", + "properties":{ + "compliance-status":{ + "type":"string", + "title":"compliance-status", + "oneOf":[ + { + "const":"new", + "description":"" + }, + { + "const":"pending", + "description":"" + }, + { + "const":"solved", + "description":"" + } + ] + }, + "approver":{ + "title":"approver", + "type":"string" + }, + "cost-center":{ + "title":"cost-center", + "type":"string" + }, + "ownership":{ + "title":"ownership", + "type":"string" + }, + "metadata-test-1":{ + "title":"metadata-test-1", + "type":"string" + }, + "metadata-test-2":{ + "title":"metadata-test-2", + "type":"boolean" + } + }, + "unevaluatedProperties":false, + "required":[ + "metadata-test-1", + "metadata-test-2" + ] + } + }, + "required":[ + "title", + "kind" + ] +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_deployment.json b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_deployment.json new file mode 100644 index 00000000000..3f3aa87832c --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_deployment.json @@ -0,0 +1,56 @@ +{ + "type":"object", + "properties":{ + "title":{ + "description":"The name of the deployment.", + "type":"string", + "maxLength":50 + }, + "description":{ + "description":"The description of the deployment.", + "type":"string", + "maxLength":1000 + }, + "environmentId":{ + "description":"The service-scoped resource ID of the deployment environment.", + "type":"string" + }, + "definitionId":{ + "description":"The service-scoped resource ID of the API definition.", + "type":"string" + }, + "server":{ + "description":"The server information of the API deployment.", + "type":"object", + "properties":{ + "runtimeUri":{ + "description":"Base runtime URIs for this deployment.", + "type":"array", + "items":{ + "type":"string" + }, + "maxItems":200 + } + }, + "required":[ + "runtimeUri" + ] + }, + "customProperties":{ + "type":"object", + "properties":{}, + "unevaluatedProperties":false, + "required":[] + }, + "recommended":{ + "description":"Indicates if this is currently recommended deployment.", + "type":"boolean" + } + }, + "required":[ + "title", + "environmentId", + "definitionId", + "server" + ] +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_env.json b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_env.json new file mode 100644 index 00000000000..5d5d2dc00be --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_md_schema_env.json @@ -0,0 +1,66 @@ +{ + "type":"object", + "properties":{ + "title":{ + "description":"The name of the environment.", + "type":"string", + "maxLength":50 + }, + "kind":{ + "description":"Kind of deployment environment.", + "type":"string" + }, + "description":{ + "description":"Description of the environment.", + "type":"string", + "maxLength":1000 + }, + "server":{ + "description":"Server information of the environment.", + "type":"object", + "properties":{ + "type":{ + "description":"Type of the server that represents the environment.", + "type":"string" + }, + "managementPortalUri":{ + "description":"URIs of the server's management portal.", + "type":"array", + "items":{ + "type":"string" + }, + "maxItems":200 + } + } + }, + "onboarding":{ + "description":"Onboarding information for this environment.", + "type":"object", + "properties":{ + "instructions":{ + "description":"Instructions how to onboard to the environment.", + "type":"string", + "maxLength":1000 + }, + "developerPortalUri":{ + "description":"Developer portal URIs of the environment.", + "type":"array", + "items":{ + "type":"string" + }, + "maxItems":200 + } + } + }, + "customProperties":{ + "type":"object", + "properties":{}, + "unevaluatedProperties":false, + "required":[] + } + }, + "required":[ + "title", + "kind" + ] +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/exported_spec.json b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_spec.json new file mode 100644 index 00000000000..f4ac2c2048f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/exported_spec.json @@ -0,0 +1,36 @@ +{ + "openapi":"3.0.0", + "info":{ + "title":"Sample API 101", + "description":"API description in Markdown. 101", + "version":"1.0.0" + }, + "servers":[ + { + "url":"http://api.example.com/v1" + } + ], + "paths":{ + "/users":{ + "get":{ + "summary":"Returns a list of users.", + "description":"Optional extended description in Markdown.", + "responses":{ + "200":{ + "description":"A JSON array of user names", + "content":{ + "application/json":{ + "schema":{ + "type":"array", + "items":{ + "type":"string" + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/import_metadataschema_input.json b/src/apic-extension/azext_apic_extension/tests/latest/data/import_metadataschema_input.json new file mode 100644 index 00000000000..c3a0db33ded --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/import_metadataschema_input.json @@ -0,0 +1,5 @@ +{ + "type": "string", + "title": "CLI Test First name", + "pattern": "^[a-zA-Z0-9 ]+$" +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/import_spec_payload.json b/src/apic-extension/azext_apic_extension/tests/latest/data/import_spec_payload.json new file mode 100644 index 00000000000..3046e59b93f --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/import_spec_payload.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Sample API 101", + "description": "API description in Markdown. 101", + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://api.example.com/v1" + } + ], + "paths": { + "/users": { + "get": { + "summary": "Returns a list of users.", + "description": "Optional extended description in Markdown.", + "responses": { + "200": { + "description": "A JSON array of user names", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/data/register_quickadd_openai_spec.json b/src/apic-extension/azext_apic_extension/tests/latest/data/register_quickadd_openai_spec.json new file mode 100644 index 00000000000..503709fa43b --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/data/register_quickadd_openai_spec.json @@ -0,0 +1,3193 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "https://api.openai.com/v1" + } + ], + "info": { + "description": "APIs for sampling from and fine-tuning language models", + "title": "CLI Test OpenAI API 105", + "version": "1.2.0", + "x-apisguru-categories": [ + "machine_learning" + ], + "x-logo": { + "url": "https://learnodo-newtonic.com/wp-content/uploads/2020/04/Logo-of-OpenAI-768x161.jpg" + }, + "x-origin": [ + { + "format": "openapi", + "url": "https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml", + "version": "3.0" + } + ], + "x-providerName": "openai.com" + }, + "tags": [ + { + "description": "The OpenAI REST API", + "name": "OpenAI" + } + ], + "paths": { + "/answers": { + "post": { + "deprecated": true, + "operationId": "createAnswer", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateAnswerRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateAnswerResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Answers the specified question using the provided documents and examples.\n\nThe endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/answers \\\n -X POST \\\n -H \"Authorization: Bearer YOUR_API_KEY\" \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"documents\": [\"Puppy A is happy.\", \"Puppy B is sad.\"],\n \"question\": \"which puppy is happy?\",\n \"search_model\": \"ada\",\n \"model\": \"curie\",\n \"examples_context\": \"In 2017, U.S. life expectancy was 78.6 years.\",\n \"examples\": [[\"What is human life expectancy in the United States?\",\"78 years.\"]],\n \"max_tokens\": 5,\n \"stop\": [\"\\n\", \"<|endoftext|>\"]\n }'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createAnswer({\n search_model: \"ada\",\n model: \"curie\",\n question: \"which puppy is happy?\",\n documents: [\"Puppy A is happy.\", \"Puppy B is sad.\"],\n examples_context: \"In 2017, U.S. life expectancy was 78.6 years.\",\n examples: [[\"What is human life expectancy in the United States?\",\"78 years.\"]],\n max_tokens: 5,\n stop: [\"\\n\", \"<|endoftext|>\"],\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Answer.create(\n search_model=\"ada\",\n model=\"curie\",\n question=\"which puppy is happy?\",\n documents=[\"Puppy A is happy.\", \"Puppy B is sad.\"],\n examples_context=\"In 2017, U.S. life expectancy was 78.6 years.\",\n examples=[[\"What is human life expectancy in the United States?\",\"78 years.\"]],\n max_tokens=5,\n stop=[\"\\n\", \"<|endoftext|>\"],\n)\n" + }, + "group": "answers", + "name": "Create answer", + "parameters": "{\n \"documents\": [\"Puppy A is happy.\", \"Puppy B is sad.\"],\n \"question\": \"which puppy is happy?\",\n \"search_model\": \"ada\",\n \"model\": \"curie\",\n \"examples_context\": \"In 2017, U.S. life expectancy was 78.6 years.\",\n \"examples\": [[\"What is human life expectancy in the United States?\",\"78 years.\"]],\n \"max_tokens\": 5,\n \"stop\": [\"\\n\", \"<|endoftext|>\"]\n}\n", + "path": "create", + "response": "{\n \"answers\": [\n \"puppy A.\"\n ],\n \"completion\": \"cmpl-2euVa1kmKUuLpSX600M41125Mo9NI\",\n \"model\": \"curie:2020-05-03\",\n \"object\": \"answer\",\n \"search_model\": \"ada\",\n \"selected_documents\": [\n {\n \"document\": 0,\n \"text\": \"Puppy A is happy. \"\n },\n {\n \"document\": 1,\n \"text\": \"Puppy B is sad. \"\n }\n ]\n}\n" + } + } + }, + "/audio/transcriptions": { + "post": { + "operationId": "createTranscription", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateTranscriptionRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTranscriptionResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Transcribes audio into the input language.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -X POST \\\n -H 'Authorization: Bearer TOKEN' \\\n -H 'Content-Type: multipart/form-data' \\\n -F file=@/path/to/file/audio.mp3 \\\n -F model=whisper-1\n", + "node": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst resp = await openai.createTranscription(\n fs.createReadStream(\"audio.mp3\"),\n \"whisper-1\"\n);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\naudio_file = open(\"audio.mp3\", \"rb\")\ntranscript = openai.Audio.transcribe(\"whisper-1\", audio_file)\n" + }, + "group": "audio", + "name": "Create transcription", + "parameters": "{\n \"file\": \"audio.mp3\",\n \"model\": \"whisper-1\"\n}\n", + "path": "create", + "response": "{\n \"text\": \"Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.\"\n}\n" + } + } + }, + "/audio/translations": { + "post": { + "operationId": "createTranslation", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateTranslationRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTranslationResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Translates audio into into English.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/audio/translations \\\n -X POST \\\n -H 'Authorization: Bearer TOKEN' \\\n -H 'Content-Type: multipart/form-data' \\\n -F file=@/path/to/file/german.m4a \\\n -F model=whisper-1\n", + "node": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst resp = await openai.createTranslation(\n fs.createReadStream(\"audio.mp3\"),\n \"whisper-1\"\n);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\naudio_file = open(\"german.m4a\", \"rb\")\ntranscript = openai.Audio.translate(\"whisper-1\", audio_file)\n" + }, + "group": "audio", + "name": "Create translation", + "parameters": "{\n \"file\": \"german.m4a\",\n \"model\": \"whisper-1\"\n}\n", + "path": "create", + "response": "{\n \"text\": \"Hello, my name is Wolfgang and I come from Germany. Where are you heading today?\"\n}\n" + } + } + }, + "/chat/completions": { + "post": { + "operationId": "createChatCompletion", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateChatCompletionRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateChatCompletionResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates a completion for the chat message", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\n\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\n\nconst completion = await openai.createChatCompletion({\n model: \"gpt-3.5-turbo\",\n messages: [{role: \"user\", content: \"Hello world\"}],\n});\nconsole.log(completion.data.choices[0].message);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\n\ncompletion = openai.ChatCompletion.create(\n model=\"gpt-3.5-turbo\",\n messages=[\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ]\n)\n\nprint(completion.choices[0].message)\n" + }, + "group": "chat", + "name": "Create chat completion", + "parameters": "{\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n}\n", + "path": "create", + "response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" + } + } + }, + "/classifications": { + "post": { + "deprecated": true, + "operationId": "createClassification", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateClassificationRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateClassificationResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Classifies the specified `query` using provided examples.\n\nThe endpoint first [searches](/docs/api-reference/searches) over the labeled examples\nto select the ones most relevant for the particular query. Then, the relevant examples\nare combined with the query to construct a prompt to produce the final label via the\n[completions](/docs/api-reference/completions) endpoint.\n\nLabeled examples can be provided via an uploaded `file`, or explicitly listed in the\nrequest using the `examples` parameter for quick tests and small scale use cases.\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/classifications \\\n -X POST \\\n -H \"Authorization: Bearer YOUR_API_KEY\" \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"examples\": [\n [\"A happy moment\", \"Positive\"],\n [\"I am sad.\", \"Negative\"],\n [\"I am feeling awesome\", \"Positive\"]],\n \"query\": \"It is a raining day :(\",\n \"search_model\": \"ada\",\n \"model\": \"curie\",\n \"labels\":[\"Positive\", \"Negative\", \"Neutral\"]\n }'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createClassification({\n search_model: \"ada\",\n model: \"curie\",\n examples: [\n [\"A happy moment\", \"Positive\"],\n [\"I am sad.\", \"Negative\"],\n [\"I am feeling awesome\", \"Positive\"]\n ],\n query:\"It is a raining day :(\",\n labels: [\"Positive\", \"Negative\", \"Neutral\"],\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Classification.create(\n search_model=\"ada\",\n model=\"curie\",\n examples=[\n [\"A happy moment\", \"Positive\"],\n [\"I am sad.\", \"Negative\"],\n [\"I am feeling awesome\", \"Positive\"]\n ],\n query=\"It is a raining day :(\",\n labels=[\"Positive\", \"Negative\", \"Neutral\"],\n)\n" + }, + "group": "classifications", + "name": "Create classification", + "parameters": "{\n \"examples\": [\n [\"A happy moment\", \"Positive\"],\n [\"I am sad.\", \"Negative\"],\n [\"I am feeling awesome\", \"Positive\"]\n ],\n \"labels\": [\"Positive\", \"Negative\", \"Neutral\"],\n \"query\": \"It is a raining day :(\",\n \"search_model\": \"ada\",\n \"model\": \"curie\"\n}\n", + "path": "create", + "response": "{\n \"completion\": \"cmpl-2euN7lUVZ0d4RKbQqRV79IiiE6M1f\",\n \"label\": \"Negative\",\n \"model\": \"curie:2020-05-03\",\n \"object\": \"classification\",\n \"search_model\": \"ada\",\n \"selected_examples\": [\n {\n \"document\": 1,\n \"label\": \"Negative\",\n \"text\": \"I am sad.\"\n },\n {\n \"document\": 0,\n \"label\": \"Positive\",\n \"text\": \"A happy moment\"\n },\n {\n \"document\": 2,\n \"label\": \"Positive\",\n \"text\": \"I am feeling awesome\"\n }\n ]\n}\n" + } + } + }, + "/completions": { + "post": { + "operationId": "createCompletion", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCompletionRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCompletionResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates a completion for the provided prompt and parameters", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/completions \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createCompletion({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test\",\n max_tokens: 7,\n temperature: 0,\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Completion.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0\n)\n" + }, + "group": "completions", + "name": "Create completion", + "parameters": "{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": null,\n \"stop\": \"\\n\"\n}\n", + "path": "create", + "response": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"VAR_model_id\",\n \"choices\": [\n {\n \"text\": \"\\n\\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n" + } + } + }, + "/edits": { + "post": { + "operationId": "createEdit", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEditRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEditResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates a new edit for the provided input, instruction, and parameters.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/edits \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"input\": \"What day of the wek is it?\",\n \"instruction\": \"Fix the spelling mistakes\"\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createEdit({\n model: \"VAR_model_id\",\n input: \"What day of the wek is it?\",\n instruction: \"Fix the spelling mistakes\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Edit.create(\n model=\"VAR_model_id\",\n input=\"What day of the wek is it?\",\n instruction=\"Fix the spelling mistakes\"\n)\n" + }, + "group": "edits", + "name": "Create edit", + "parameters": "{\n \"model\": \"VAR_model_id\",\n \"input\": \"What day of the wek is it?\",\n \"instruction\": \"Fix the spelling mistakes\",\n}\n", + "path": "create", + "response": "{\n \"object\": \"edit\",\n \"created\": 1589478378,\n \"choices\": [\n {\n \"text\": \"What day of the week is it?\",\n \"index\": 0,\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 25,\n \"completion_tokens\": 32,\n \"total_tokens\": 57\n }\n}\n" + } + } + }, + "/embeddings": { + "post": { + "operationId": "createEmbedding", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEmbeddingRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEmbeddingResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates an embedding vector representing the input text.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/embeddings \\\n -X POST \\\n -H \"Authorization: Bearer YOUR_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"input\": \"The food was delicious and the waiter...\",\n \"model\": \"text-embedding-ada-002\"}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createEmbedding({\n model: \"text-embedding-ada-002\",\n input: \"The food was delicious and the waiter...\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Embedding.create(\n model=\"text-embedding-ada-002\",\n input=\"The food was delicious and the waiter...\"\n)\n" + }, + "group": "embeddings", + "name": "Create embeddings", + "parameters": "{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}\n", + "path": "create", + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222,\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}\n" + } + } + }, + "/engines": { + "get": { + "deprecated": true, + "operationId": "listEngines", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListEnginesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/engines \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listEngines();\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Engine.list()\n" + }, + "group": "engines", + "name": "List engines", + "path": "list", + "response": "{\n \"data\": [\n {\n \"id\": \"engine-id-0\",\n \"object\": \"engine\",\n \"owner\": \"organization-owner\",\n \"ready\": true\n },\n {\n \"id\": \"engine-id-2\",\n \"object\": \"engine\",\n \"owner\": \"organization-owner\",\n \"ready\": true\n },\n {\n \"id\": \"engine-id-3\",\n \"object\": \"engine\",\n \"owner\": \"openai\",\n \"ready\": false\n },\n ],\n \"object\": \"list\"\n}\n" + } + } + }, + "/engines/{engine_id}": { + "get": { + "deprecated": true, + "operationId": "retrieveEngine", + "parameters": [ + { + "description": "The ID of the engine to use for this request\n", + "in": "path", + "name": "engine_id", + "required": true, + "schema": { + "example": "davinci", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Engine" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieves a model instance, providing basic information about it such as the owner and availability.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/engines/VAR_model_id \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveEngine(\"VAR_model_id\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Engine.retrieve(\"VAR_model_id\")\n" + }, + "group": "engines", + "name": "Retrieve engine", + "path": "retrieve", + "response": "{\n \"id\": \"VAR_model_id\",\n \"object\": \"engine\",\n \"owner\": \"openai\",\n \"ready\": true\n}\n" + } + } + }, + "/engines/{engine_id}/search": { + "post": { + "deprecated": true, + "operationId": "createSearch", + "parameters": [ + { + "description": "The ID of the engine to use for this request. You can select one of `ada`, `babbage`, `curie`, or `davinci`.", + "in": "path", + "name": "engine_id", + "required": true, + "schema": { + "example": "davinci", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSearchResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.\n\nTo go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores.\n\nThe similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/engines/davinci/search \\\n -H \"Content-Type: application/json\" \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"documents\": [\"White House\", \"hospital\", \"school\"],\n \"query\": \"the president\"\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createSearch(\"davinci\", {\n documents: [\"White House\", \"hospital\", \"school\"],\n query: \"the president\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Engine(\"davinci\").search(\n documents=[\"White House\", \"hospital\", \"school\"],\n query=\"the president\"\n)\n" + }, + "group": "searches", + "name": "Create search", + "parameters": "{\n \"documents\": [\n \"White House\",\n \"hospital\",\n \"school\"\n ],\n \"query\": \"the president\"\n}\n", + "path": "create", + "response": "{\n \"data\": [\n {\n \"document\": 0,\n \"object\": \"search_result\",\n \"score\": 215.412\n },\n {\n \"document\": 1,\n \"object\": \"search_result\",\n \"score\": 40.316\n },\n {\n \"document\": 2,\n \"object\": \"search_result\",\n \"score\": 55.226\n }\n ],\n \"object\": \"list\"\n}\n" + } + } + }, + "/files": { + "get": { + "operationId": "listFiles", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFilesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Returns a list of files that belong to the user's organization.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/files \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFiles();\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.list()\n" + }, + "group": "files", + "name": "List files", + "path": "list", + "response": "{\n \"data\": [\n {\n \"id\": \"file-ccdDZrC3iZVNiQVeEA6Z66wf\",\n \"object\": \"file\",\n \"bytes\": 175,\n \"created_at\": 1613677385,\n \"filename\": \"train.jsonl\",\n \"purpose\": \"search\"\n },\n {\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"puppy.jsonl\",\n \"purpose\": \"search\"\n }\n ],\n \"object\": \"list\"\n}\n" + } + }, + "post": { + "operationId": "createFile", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateFileRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAIFile" + } + } + }, + "description": "OK" + } + }, + "summary": "Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer YOUR_API_KEY\" \\\n -F purpose=\"fine-tune\" \\\n -F file='@mydata.jsonl'\n", + "node.js": "const fs = require(\"fs\");\nconst { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createFile(\n fs.createReadStream(\"mydata.jsonl\"),\n \"fine-tune\"\n);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.create(\n file=open(\"mydata.jsonl\", \"rb\"),\n purpose='fine-tune'\n)\n" + }, + "group": "files", + "name": "Upload file", + "path": "upload", + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\"\n}\n" + } + } + }, + "/files/{file_id}": { + "delete": { + "operationId": "deleteFile", + "parameters": [ + { + "description": "The ID of the file to use for this request", + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteFileResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Delete a file.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \\\n -X DELETE \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.deleteFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.delete(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n" + }, + "group": "files", + "name": "Delete file", + "path": "delete", + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"deleted\": true\n}\n" + } + }, + "get": { + "operationId": "retrieveFile", + "parameters": [ + { + "description": "The ID of the file to use for this request", + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAIFile" + } + } + }, + "description": "OK" + } + }, + "summary": "Returns information about a specific file.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.retrieve(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n" + }, + "group": "files", + "name": "Retrieve file", + "path": "retrieve", + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779657,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\"\n}\n" + } + } + }, + "/files/{file_id}/content": { + "get": { + "operationId": "downloadFile", + "parameters": [ + { + "description": "The ID of the file to use for this request", + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "description": "OK" + } + }, + "summary": "Returns the contents of the specified file", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3/content \\\n -H 'Authorization: Bearer YOUR_API_KEY' > file.jsonl\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.downloadFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\ncontent = openai.File.download(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n" + }, + "group": "files", + "name": "Retrieve file content", + "path": "retrieve-content" + } + } + }, + "/fine-tunes": { + "get": { + "operationId": "listFineTunes", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFineTunesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "List your organization's fine-tuning jobs\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFineTunes();\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.list()\n" + }, + "group": "fine-tunes", + "name": "List fine-tunes", + "path": "list", + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"hyperparams\": { ... },\n \"organization_id\": \"org-...\",\n \"result_files\": [],\n \"status\": \"pending\",\n \"validation_files\": [],\n \"training_files\": [ { ... } ],\n \"updated_at\": 1614807352,\n },\n { ... },\n { ... }\n ]\n}\n" + } + }, + "post": { + "operationId": "createFineTune", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFineTuneRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FineTune" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates a job that fine-tunes a specified model from a given dataset.\n\nResponse includes details of the enqueued job including job status and the name of the fine-tuned models once complete.\n\n[Learn more about Fine-tuning](/docs/guides/fine-tuning)\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -X POST \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_API_KEY\" \\\n -d '{\n \"training_file\": \"file-XGinujblHPwGLSztz8cPS8XY\"\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createFineTune({\n training_file: \"file-XGinujblHPwGLSztz8cPS8XY\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.create(training_file=\"file-XGinujblHPwGLSztz8cPS8XY\")\n" + }, + "group": "fine-tunes", + "name": "Create fine-tune", + "path": "create", + "response": "{\n \"id\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"events\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n }\n ],\n \"fine_tuned_model\": null,\n \"hyperparams\": {\n \"batch_size\": 4,\n \"learning_rate_multiplier\": 0.1,\n \"n_epochs\": 4,\n \"prompt_loss_weight\": 0.1,\n },\n \"organization_id\": \"org-...\",\n \"result_files\": [],\n \"status\": \"pending\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807352,\n}\n" + } + } + }, + "/fine-tunes/{fine_tune_id}": { + "get": { + "operationId": "retrieveFineTune", + "parameters": [ + { + "description": "The ID of the fine-tune job\n", + "in": "path", + "name": "fine_tune_id", + "required": true, + "schema": { + "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FineTune" + } + } + }, + "description": "OK" + } + }, + "summary": "Gets info about the fine-tune job.\n\n[Learn more about Fine-tuning](/docs/guides/fine-tuning)\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F \\\n -H \"Authorization: Bearer YOUR_API_KEY\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveFineTune(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.retrieve(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n" + }, + "group": "fine-tunes", + "name": "Retrieve fine-tune", + "path": "retrieve", + "response": "{\n \"id\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"events\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807356,\n \"level\": \"info\",\n \"message\": \"Job started.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807861,\n \"level\": \"info\",\n \"message\": \"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Job succeeded.\"\n }\n ],\n \"fine_tuned_model\": \"curie:ft-acmeco-2021-03-03-21-44-20\",\n \"hyperparams\": {\n \"batch_size\": 4,\n \"learning_rate_multiplier\": 0.1,\n \"n_epochs\": 4,\n \"prompt_loss_weight\": 0.1,\n },\n \"organization_id\": \"org-...\",\n \"result_files\": [\n {\n \"id\": \"file-QQm6ZpqdNwAaVC3aSz5sWwLT\",\n \"object\": \"file\",\n \"bytes\": 81509,\n \"created_at\": 1614807863,\n \"filename\": \"compiled_results.csv\",\n \"purpose\": \"fine-tune-results\"\n }\n ],\n \"status\": \"succeeded\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807865,\n}\n" + } + } + }, + "/fine-tunes/{fine_tune_id}/cancel": { + "post": { + "operationId": "cancelFineTune", + "parameters": [ + { + "description": "The ID of the fine-tune job to cancel\n", + "in": "path", + "name": "fine_tune_id", + "required": true, + "schema": { + "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FineTune" + } + } + }, + "description": "OK" + } + }, + "summary": "Immediately cancel a fine-tune job.\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \\\n -X POST \\\n -H \"Authorization: Bearer YOUR_API_KEY\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.cancelFineTune(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.cancel(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n" + }, + "group": "fine-tunes", + "name": "Cancel fine-tune", + "path": "cancel", + "response": "{\n \"id\": \"ft-xhrpBbvVUzYGo8oUO1FY4nI7\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807770,\n \"events\": [ { ... } ],\n \"fine_tuned_model\": null,\n \"hyperparams\": { ... },\n \"organization_id\": \"org-...\",\n \"result_files\": [],\n \"status\": \"cancelled\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807789,\n}\n" + } + } + }, + "/fine-tunes/{fine_tune_id}/events": { + "get": { + "operationId": "listFineTuneEvents", + "parameters": [ + { + "description": "The ID of the fine-tune job to get events for.\n", + "in": "path", + "name": "fine_tune_id", + "required": true, + "schema": { + "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F", + "type": "string" + } + }, + { + "description": "Whether to stream events for the fine-tune job. If set to true,\nevents will be sent as data-only\n[server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)\nas they become available. The stream will terminate with a\n`data: [DONE]` message when the job is finished (succeeded, cancelled,\nor failed).\n\nIf set to false, only events generated so far will be returned.\n", + "in": "query", + "name": "stream", + "required": false, + "schema": { + "default": false, + "type": "boolean" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFineTuneEventsResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Get fine-grained status updates for a fine-tune job.\n", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \\\n -H \"Authorization: Bearer YOUR_API_KEY\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFineTuneEvents(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.list_events(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n" + }, + "group": "fine-tunes", + "name": "List fine-tune events", + "path": "events", + "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807356,\n \"level\": \"info\",\n \"message\": \"Job started.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807861,\n \"level\": \"info\",\n \"message\": \"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Job succeeded.\"\n }\n ]\n}\n" + } + } + }, + "/images/edits": { + "post": { + "operationId": "createImageEdit", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateImageEditRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates an edited or extended image given an original image and a prompt.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/images/edits \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -F image='@otter.png' \\\n -F mask='@mask.png' \\\n -F prompt=\"A cute baby sea otter wearing a beret\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImageEdit(\n fs.createReadStream(\"otter.png\"),\n fs.createReadStream(\"mask.png\"),\n \"A cute baby sea otter wearing a beret\",\n 2,\n \"1024x1024\"\n);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create_edit(\n image=open(\"otter.png\", \"rb\"),\n mask=open(\"mask.png\", \"rb\"),\n prompt=\"A cute baby sea otter wearing a beret\",\n n=2,\n size=\"1024x1024\"\n)\n" + }, + "group": "images", + "name": "Create image edit", + "path": "create-edit", + "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" + } + } + }, + "/images/generations": { + "post": { + "operationId": "createImage", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateImageRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates an image given a prompt.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/images/generations \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 2,\n \"size\": \"1024x1024\"\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImage({\n prompt: \"A cute baby sea otter\",\n n: 2,\n size: \"1024x1024\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create(\n prompt=\"A cute baby sea otter\",\n n=2,\n size=\"1024x1024\"\n)\n" + }, + "group": "images", + "name": "Create image", + "parameters": "{\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 2,\n \"size\": \"1024x1024\"\n}\n", + "path": "create", + "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" + } + } + }, + "/images/variations": { + "post": { + "operationId": "createImageVariation", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateImageVariationRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Creates a variation of a given image.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "beta": true, + "examples": { + "curl": "curl https://api.openai.com/v1/images/variations \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -F image='@otter.png' \\\n -F n=2 \\\n -F size=\"1024x1024\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImageVariation(\n fs.createReadStream(\"otter.png\"),\n 2,\n \"1024x1024\"\n);\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create_variation(\n image=open(\"otter.png\", \"rb\"),\n n=2,\n size=\"1024x1024\"\n)\n" + }, + "group": "images", + "name": "Create image variation", + "path": "create-variation", + "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" + } + } + }, + "/models": { + "get": { + "operationId": "listModels", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListModelsResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Lists the currently available models, and provides basic information about each one such as the owner and availability.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/models \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listModels();\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.list()\n" + }, + "group": "models", + "name": "List models", + "path": "list", + "response": "{\n \"data\": [\n {\n \"id\": \"model-id-0\",\n \"object\": \"model\",\n \"owned_by\": \"organization-owner\",\n \"permission\": [...]\n },\n {\n \"id\": \"model-id-1\",\n \"object\": \"model\",\n \"owned_by\": \"organization-owner\",\n \"permission\": [...]\n },\n {\n \"id\": \"model-id-2\",\n \"object\": \"model\",\n \"owned_by\": \"openai\",\n \"permission\": [...]\n },\n ],\n \"object\": \"list\"\n}\n" + } + } + }, + "/models/{model}": { + "delete": { + "operationId": "deleteModel", + "parameters": [ + { + "description": "The model to delete", + "in": "path", + "name": "model", + "required": true, + "schema": { + "example": "curie:ft-acmeco-2021-03-03-21-44-20", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteModelResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Delete a fine-tuned model. You must have the Owner role in your organization.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/models/curie:ft-acmeco-2021-03-03-21-44-20 \\\n -X DELETE \\\n -H \"Authorization: Bearer YOUR_API_KEY\"\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.deleteModel('curie:ft-acmeco-2021-03-03-21-44-20');\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.delete(\"curie:ft-acmeco-2021-03-03-21-44-20\")\n" + }, + "group": "fine-tunes", + "name": "Delete fine-tune model", + "path": "delete-model", + "response": "{\n \"id\": \"curie:ft-acmeco-2021-03-03-21-44-20\",\n \"object\": \"model\",\n \"deleted\": true\n}\n" + } + }, + "get": { + "operationId": "retrieveModel", + "parameters": [ + { + "description": "The ID of the model to use for this request", + "in": "path", + "name": "model", + "required": true, + "schema": { + "example": "text-davinci-001", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Model" + } + } + }, + "description": "OK" + } + }, + "summary": "Retrieves a model instance, providing basic information about the model such as the owner and permissioning.", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/models/VAR_model_id \\\n -H 'Authorization: Bearer YOUR_API_KEY'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveModel(\"VAR_model_id\");\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.retrieve(\"VAR_model_id\")\n" + }, + "group": "models", + "name": "Retrieve model", + "path": "retrieve", + "response": "{\n \"id\": \"VAR_model_id\",\n \"object\": \"model\",\n \"owned_by\": \"openai\",\n \"permission\": [...]\n}\n" + } + } + }, + "/moderations": { + "post": { + "operationId": "createModeration", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateModerationRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateModerationResponse" + } + } + }, + "description": "OK" + } + }, + "summary": "Classifies if text violates OpenAI's Content Policy", + "tags": [ + "OpenAI" + ], + "x-oaiMeta": { + "examples": { + "curl": "curl https://api.openai.com/v1/moderations \\\n -H 'Content-Type: application/json' \\\n -H 'Authorization: Bearer YOUR_API_KEY' \\\n -d '{\n \"input\": \"I want to kill them.\"\n}'\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createModeration({\n input: \"I want to kill them.\",\n});\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Moderation.create(\n input=\"I want to kill them.\",\n)\n" + }, + "group": "moderations", + "name": "Create moderation", + "parameters": "{\n \"input\": \"I want to kill them.\"\n}\n", + "path": "create", + "response": "{\n \"id\": \"modr-5MWoLO\",\n \"model\": \"text-moderation-001\",\n \"results\": [\n {\n \"categories\": {\n \"hate\": false,\n \"hate/threatening\": true,\n \"self-harm\": false,\n \"sexual\": false,\n \"sexual/minors\": false,\n \"violence\": true,\n \"violence/graphic\": false\n },\n \"category_scores\": {\n \"hate\": 0.22714105248451233,\n \"hate/threatening\": 0.4132447838783264,\n \"self-harm\": 0.005232391878962517,\n \"sexual\": 0.01407341007143259,\n \"sexual/minors\": 0.0038522258400917053,\n \"violence\": 0.9223177433013916,\n \"violence/graphic\": 0.036865197122097015\n },\n \"flagged\": true\n }\n ]\n}\n" + } + } + } + }, + "components": { + "schemas": { + "ChatCompletionRequestMessage": { + "properties": { + "content": { + "description": "The contents of the message", + "type": "string" + }, + "name": { + "description": "The name of the user in a multi-user chat", + "type": "string" + }, + "role": { + "description": "The role of the author of this message.", + "enum": [ + "system", + "user", + "assistant" + ], + "type": "string" + } + }, + "required": [ + "role", + "content" + ], + "type": "object" + }, + "ChatCompletionResponseMessage": { + "properties": { + "content": { + "description": "The contents of the message", + "type": "string" + }, + "role": { + "description": "The role of the author of this message.", + "enum": [ + "system", + "user", + "assistant" + ], + "type": "string" + } + }, + "required": [ + "role", + "content" + ], + "type": "object" + }, + "CreateAnswerRequest": { + "additionalProperties": false, + "properties": { + "documents": { + "description": "List of documents from which the answer for the input `question` should be derived. If this is an empty list, the question will be answered based on the question-answer examples.\n\nYou should specify either `documents` or a `file`, but not both.\n", + "example": "['Japan is an island country in East Asia, located in the northwest Pacific Ocean.', 'Tokyo is the capital and most populous prefecture of Japan.']", + "items": { + "type": "string" + }, + "maxItems": 200, + "nullable": true, + "type": "array" + }, + "examples": { + "description": "List of (question, answer) pairs that will help steer the model towards the tone and answer format you'd like. We recommend adding 2 to 3 examples.", + "example": "[['What is the capital of Canada?', 'Ottawa'], ['Which province is Ottawa in?', 'Ontario']]", + "items": { + "items": { + "minLength": 1, + "type": "string" + }, + "maxItems": 2, + "minItems": 2, + "type": "array" + }, + "maxItems": 200, + "minItems": 1, + "type": "array" + }, + "examples_context": { + "description": "A text snippet containing the contextual information used to generate the answers for the `examples` you provide.", + "example": "Ottawa, Canada's capital, is located in the east of southern Ontario, near the city of Montréal and the U.S. border.", + "type": "string" + }, + "expand": { + "default": [], + "description": "If an object name is in the list, we provide the full information of the object; otherwise, we only provide the object ID. Currently we support `completion` and `file` objects for expansion.", + "items": {}, + "nullable": true, + "type": "array" + }, + "file": { + "description": "The ID of an uploaded file that contains documents to search over. See [upload file](/docs/api-reference/files/upload) for how to upload a file of the desired format and purpose.\n\nYou should specify either `documents` or a `file`, but not both.\n", + "nullable": true, + "type": "string" + }, + "logit_bias": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/logit_bias" + }, + "logprobs": { + "default": null, + "description": "Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case.\n\nWhen `logprobs` is set, `completion` will be automatically added into `expand` to get the logprobs.\n", + "maximum": 5, + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "max_rerank": { + "default": 200, + "description": "The maximum number of documents to be ranked by [Search](/docs/api-reference/searches/create) when using `file`. Setting it to a higher value leads to improved accuracy but with increased latency and cost.", + "nullable": true, + "type": "integer" + }, + "max_tokens": { + "default": 16, + "description": "The maximum number of tokens allowed for the generated answer", + "nullable": true, + "type": "integer" + }, + "model": { + "description": "ID of the model to use for completion. You can select one of `ada`, `babbage`, `curie`, or `davinci`.", + "type": "string" + }, + "n": { + "default": 1, + "description": "How many answers to generate for each question.", + "maximum": 10, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "question": { + "description": "Question to get answered.", + "example": "What is the capital of Japan?", + "minLength": 1, + "type": "string" + }, + "return_metadata": { + "$ref": "#/components/schemas/CreateSearchRequest/properties/return_metadata" + }, + "return_prompt": { + "default": false, + "description": "If set to `true`, the returned JSON will include a \"prompt\" field containing the final prompt that was used to request a completion. This is mainly useful for debugging purposes.", + "nullable": true, + "type": "boolean" + }, + "search_model": { + "default": "ada", + "description": "ID of the model to use for [Search](/docs/api-reference/searches/create). You can select one of `ada`, `babbage`, `curie`, or `davinci`.", + "nullable": true, + "type": "string" + }, + "stop": { + "default": null, + "description": "Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.\n", + "nullable": true, + "oneOf": [ + { + "default": "<|endoftext|>", + "example": "\n", + "type": "string" + }, + { + "items": { + "example": "[\"\\n\"]", + "type": "string" + }, + "maxItems": 4, + "minItems": 1, + "type": "array" + } + ] + }, + "temperature": { + "default": 0, + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.", + "nullable": true, + "type": "number" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "model", + "question", + "examples", + "examples_context" + ], + "type": "object" + }, + "CreateAnswerResponse": { + "properties": { + "answers": { + "items": { + "type": "string" + }, + "type": "array" + }, + "completion": { + "type": "string" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "search_model": { + "type": "string" + }, + "selected_documents": { + "items": { + "properties": { + "document": { + "type": "integer" + }, + "text": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "CreateChatCompletionRequest": { + "properties": { + "frequency_penalty": { + "default": 0, + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", + "maximum": 2, + "minimum": -2, + "nullable": true, + "type": "number" + }, + "logit_bias": { + "default": null, + "description": "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n", + "nullable": true, + "type": "object", + "x-oaiTypeLabel": "map" + }, + "max_tokens": { + "default": "inf", + "description": "The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).\n", + "type": "integer" + }, + "messages": { + "description": "The messages to generate chat completions for, in the [chat format](/docs/guides/chat/introduction).", + "items": { + "$ref": "#/components/schemas/ChatCompletionRequestMessage" + }, + "minItems": 1, + "type": "array" + }, + "model": { + "description": "ID of the model to use. Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.", + "type": "string" + }, + "n": { + "default": 1, + "description": "How many chat completion choices to generate for each input message.", + "example": 1, + "maximum": 128, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "presence_penalty": { + "default": 0, + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", + "maximum": 2, + "minimum": -2, + "nullable": true, + "type": "number" + }, + "stop": { + "default": null, + "description": "Up to 4 sequences where the API will stop generating further tokens.\n", + "oneOf": [ + { + "nullable": true, + "type": "string" + }, + { + "items": { + "type": "string" + }, + "maxItems": 4, + "minItems": 1, + "type": "array" + } + ] + }, + "stream": { + "default": false, + "description": "If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.\n", + "nullable": true, + "type": "boolean" + }, + "temperature": { + "default": 1, + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n", + "example": 1, + "maximum": 2, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "top_p": { + "default": 1, + "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n", + "example": 1, + "maximum": 1, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "model", + "messages" + ], + "type": "object" + }, + "CreateChatCompletionResponse": { + "properties": { + "choices": { + "items": { + "properties": { + "finish_reason": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "message": { + "$ref": "#/components/schemas/ChatCompletionResponseMessage" + } + }, + "type": "object" + }, + "type": "array" + }, + "created": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "usage": { + "properties": { + "completion_tokens": { + "type": "integer" + }, + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ], + "type": "object" + } + }, + "required": [ + "id", + "object", + "created", + "model", + "choices" + ], + "type": "object" + }, + "CreateClassificationRequest": { + "additionalProperties": false, + "properties": { + "examples": { + "description": "A list of examples with labels, in the following format:\n\n`[[\"The movie is so interesting.\", \"Positive\"], [\"It is quite boring.\", \"Negative\"], ...]`\n\nAll the label strings will be normalized to be capitalized.\n\nYou should specify either `examples` or `file`, but not both.\n", + "example": "[['Do not see this film.', 'Negative'], ['Smart, provocative and blisteringly funny.', 'Positive']]", + "items": { + "items": { + "minLength": 1, + "type": "string" + }, + "maxItems": 2, + "minItems": 2, + "type": "array" + }, + "maxItems": 200, + "minItems": 2, + "nullable": true, + "type": "array" + }, + "expand": { + "$ref": "#/components/schemas/CreateAnswerRequest/properties/expand" + }, + "file": { + "description": "The ID of the uploaded file that contains training examples. See [upload file](/docs/api-reference/files/upload) for how to upload a file of the desired format and purpose.\n\nYou should specify either `examples` or `file`, but not both.\n", + "nullable": true, + "type": "string" + }, + "labels": { + "default": null, + "description": "The set of categories being classified. If not specified, candidate labels will be automatically collected from the examples you provide. All the label strings will be normalized to be capitalized.", + "example": [ + "Positive", + "Negative" + ], + "items": { + "type": "string" + }, + "maxItems": 200, + "minItems": 2, + "nullable": true, + "type": "array" + }, + "logit_bias": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/logit_bias" + }, + "logprobs": { + "$ref": "#/components/schemas/CreateAnswerRequest/properties/logprobs" + }, + "max_examples": { + "default": 200, + "description": "The maximum number of examples to be ranked by [Search](/docs/api-reference/searches/create) when using `file`. Setting it to a higher value leads to improved accuracy but with increased latency and cost.", + "nullable": true, + "type": "integer" + }, + "model": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/model" + }, + "query": { + "description": "Query to be classified.", + "example": "The plot is not very attractive.", + "minLength": 1, + "type": "string" + }, + "return_metadata": { + "$ref": "#/components/schemas/CreateSearchRequest/properties/return_metadata" + }, + "return_prompt": { + "$ref": "#/components/schemas/CreateAnswerRequest/properties/return_prompt" + }, + "search_model": { + "$ref": "#/components/schemas/CreateAnswerRequest/properties/search_model" + }, + "temperature": { + "default": 0, + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.", + "example": 0, + "maximum": 2, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "model", + "query" + ], + "type": "object" + }, + "CreateClassificationResponse": { + "properties": { + "completion": { + "type": "string" + }, + "label": { + "type": "string" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "search_model": { + "type": "string" + }, + "selected_examples": { + "items": { + "properties": { + "document": { + "type": "integer" + }, + "label": { + "type": "string" + }, + "text": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "CreateCompletionRequest": { + "properties": { + "best_of": { + "default": 1, + "description": "Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n", + "maximum": 20, + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "echo": { + "default": false, + "description": "Echo back the prompt in addition to the completion\n", + "nullable": true, + "type": "boolean" + }, + "frequency_penalty": { + "default": 0, + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", + "maximum": 2, + "minimum": -2, + "nullable": true, + "type": "number" + }, + "logit_bias": { + "default": null, + "description": "Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.\n", + "nullable": true, + "type": "object", + "x-oaiTypeLabel": "map" + }, + "logprobs": { + "default": null, + "description": "Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case.\n", + "maximum": 5, + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "max_tokens": { + "default": 16, + "description": "The maximum number of [tokens](/tokenizer) to generate in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).\n", + "example": 16, + "minimum": 0, + "nullable": true, + "type": "integer" + }, + "model": { + "description": "ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.", + "type": "string" + }, + "n": { + "default": 1, + "description": "How many completions to generate for each prompt.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n", + "example": 1, + "maximum": 128, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "presence_penalty": { + "default": 0, + "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", + "maximum": 2, + "minimum": -2, + "nullable": true, + "type": "number" + }, + "prompt": { + "default": "<|endoftext|>", + "description": "The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.\n", + "nullable": true, + "oneOf": [ + { + "default": "", + "example": "This is a test.", + "type": "string" + }, + { + "items": { + "default": "", + "example": "This is a test.", + "type": "string" + }, + "type": "array" + }, + { + "example": "[1212, 318, 257, 1332, 13]", + "items": { + "type": "integer" + }, + "minItems": 1, + "type": "array" + }, + { + "example": "[[1212, 318, 257, 1332, 13]]", + "items": { + "items": { + "type": "integer" + }, + "minItems": 1, + "type": "array" + }, + "minItems": 1, + "type": "array" + } + ] + }, + "stop": { + "default": null, + "description": "Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.\n", + "nullable": true, + "oneOf": [ + { + "default": "<|endoftext|>", + "example": "\n", + "nullable": true, + "type": "string" + }, + { + "items": { + "example": "[\"\\n\"]", + "type": "string" + }, + "maxItems": 4, + "minItems": 1, + "type": "array" + } + ] + }, + "stream": { + "default": false, + "description": "Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.\n", + "nullable": true, + "type": "boolean" + }, + "suffix": { + "default": null, + "description": "The suffix that comes after a completion of inserted text.", + "example": "test.", + "nullable": true, + "type": "string" + }, + "temperature": { + "default": 1, + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n", + "example": 1, + "maximum": 2, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "top_p": { + "default": 1, + "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n", + "example": 1, + "maximum": 1, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "user": { + "description": "A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n", + "example": "user-1234", + "type": "string" + } + }, + "required": [ + "model" + ], + "type": "object" + }, + "CreateCompletionResponse": { + "properties": { + "choices": { + "items": { + "properties": { + "finish_reason": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "logprobs": { + "nullable": true, + "properties": { + "text_offset": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "token_logprobs": { + "items": { + "type": "number" + }, + "type": "array" + }, + "tokens": { + "items": { + "type": "string" + }, + "type": "array" + }, + "top_logprobs": { + "items": { + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "text": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "created": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "usage": { + "properties": { + "completion_tokens": { + "type": "integer" + }, + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ], + "type": "object" + } + }, + "required": [ + "id", + "object", + "created", + "model", + "choices" + ], + "type": "object" + }, + "CreateEditRequest": { + "properties": { + "input": { + "default": "", + "description": "The input text to use as a starting point for the edit.", + "example": "What day of the wek is it?", + "nullable": true, + "type": "string" + }, + "instruction": { + "description": "The instruction that tells the model how to edit the prompt.", + "example": "Fix the spelling mistakes.", + "type": "string" + }, + "model": { + "description": "ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint.", + "type": "string" + }, + "n": { + "default": 1, + "description": "How many edits to generate for the input and instruction.", + "example": 1, + "maximum": 20, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "temperature": { + "default": 1, + "description": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n", + "example": 1, + "maximum": 2, + "minimum": 0, + "nullable": true, + "type": "number" + }, + "top_p": { + "default": 1, + "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n", + "example": 1, + "maximum": 1, + "minimum": 0, + "nullable": true, + "type": "number" + } + }, + "required": [ + "model", + "instruction" + ], + "type": "object" + }, + "CreateEditResponse": { + "properties": { + "choices": { + "items": { + "properties": { + "finish_reason": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "logprobs": { + "nullable": true, + "properties": { + "text_offset": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "token_logprobs": { + "items": { + "type": "number" + }, + "type": "array" + }, + "tokens": { + "items": { + "type": "string" + }, + "type": "array" + }, + "top_logprobs": { + "items": { + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "text": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "created": { + "type": "integer" + }, + "object": { + "type": "string" + }, + "usage": { + "properties": { + "completion_tokens": { + "type": "integer" + }, + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ], + "type": "object" + } + }, + "required": [ + "object", + "created", + "choices", + "usage" + ], + "type": "object" + }, + "CreateEmbeddingRequest": { + "additionalProperties": false, + "properties": { + "input": { + "description": "Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length.\n", + "example": "The quick brown fox jumped over the lazy dog", + "oneOf": [ + { + "default": "", + "example": "This is a test.", + "type": "string" + }, + { + "items": { + "default": "", + "example": "This is a test.", + "type": "string" + }, + "type": "array" + }, + { + "example": "[1212, 318, 257, 1332, 13]", + "items": { + "type": "integer" + }, + "minItems": 1, + "type": "array" + }, + { + "example": "[[1212, 318, 257, 1332, 13]]", + "items": { + "items": { + "type": "integer" + }, + "minItems": 1, + "type": "array" + }, + "minItems": 1, + "type": "array" + } + ] + }, + "model": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/model" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "model", + "input" + ], + "type": "object" + }, + "CreateEmbeddingResponse": { + "properties": { + "data": { + "items": { + "properties": { + "embedding": { + "items": { + "type": "number" + }, + "type": "array" + }, + "index": { + "type": "integer" + }, + "object": { + "type": "string" + } + }, + "required": [ + "index", + "object", + "embedding" + ], + "type": "object" + }, + "type": "array" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "usage": { + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "total_tokens" + ], + "type": "object" + } + }, + "required": [ + "object", + "model", + "data", + "usage" + ], + "type": "object" + }, + "CreateFileRequest": { + "additionalProperties": false, + "properties": { + "file": { + "description": "Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded.\n\nIf the `purpose` is set to \"fine-tune\", each line is a JSON record with \"prompt\" and \"completion\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).\n", + "format": "binary", + "type": "string" + }, + "purpose": { + "description": "The intended purpose of the uploaded documents.\n\nUse \"fine-tune\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.\n", + "type": "string" + } + }, + "required": [ + "file", + "purpose" + ], + "type": "object" + }, + "CreateFineTuneRequest": { + "properties": { + "batch_size": { + "default": null, + "description": "The batch size to use for training. The batch size is the number of\ntraining examples used to train a single forward and backward pass.\n\nBy default, the batch size will be dynamically configured to be\n~0.2% of the number of examples in the training set, capped at 256 -\nin general, we've found that larger batch sizes tend to work better\nfor larger datasets.\n", + "nullable": true, + "type": "integer" + }, + "classification_betas": { + "default": null, + "description": "If this is provided, we calculate F-beta scores at the specified\nbeta values. The F-beta score is a generalization of F-1 score.\nThis is only used for binary classification.\n\nWith a beta of 1 (i.e. the F-1 score), precision and recall are\ngiven the same weight. A larger beta score puts more weight on\nrecall and less on precision. A smaller beta score puts more weight\non precision and less on recall.\n", + "example": [ + 0.6, + 1, + 1.5, + 2 + ], + "items": { + "type": "number" + }, + "nullable": true, + "type": "array" + }, + "classification_n_classes": { + "default": null, + "description": "The number of classes in a classification task.\n\nThis parameter is required for multiclass classification.\n", + "nullable": true, + "type": "integer" + }, + "classification_positive_class": { + "default": null, + "description": "The positive class in binary classification.\n\nThis parameter is needed to generate precision, recall, and F1\nmetrics when doing binary classification.\n", + "nullable": true, + "type": "string" + }, + "compute_classification_metrics": { + "default": false, + "description": "If set, we calculate classification-specific metrics such as accuracy\nand F-1 score using the validation set at the end of every epoch.\nThese metrics can be viewed in the [results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\n\nIn order to compute classification metrics, you must provide a\n`validation_file`. Additionally, you must\nspecify `classification_n_classes` for multiclass classification or\n`classification_positive_class` for binary classification.\n", + "nullable": true, + "type": "boolean" + }, + "learning_rate_multiplier": { + "default": null, + "description": "The learning rate multiplier to use for training.\nThe fine-tuning learning rate is the original learning rate used for\npretraining multiplied by this value.\n\nBy default, the learning rate multiplier is the 0.05, 0.1, or 0.2\ndepending on final `batch_size` (larger learning rates tend to\nperform better with larger batch sizes). We recommend experimenting\nwith values in the range 0.02 to 0.2 to see what produces the best\nresults.\n", + "nullable": true, + "type": "number" + }, + "model": { + "default": "curie", + "description": "The name of the base model to fine-tune. You can select one of \"ada\",\n\"babbage\", \"curie\", \"davinci\", or a fine-tuned model created after 2022-04-21.\nTo learn more about these models, see the\n[Models](https://platform.openai.com/docs/models) documentation.\n", + "nullable": true, + "type": "string" + }, + "n_epochs": { + "default": 4, + "description": "The number of epochs to train the model for. An epoch refers to one\nfull cycle through the training dataset.\n", + "nullable": true, + "type": "integer" + }, + "prompt_loss_weight": { + "default": 0.01, + "description": "The weight to use for loss on the prompt tokens. This controls how\nmuch the model tries to learn to generate the prompt (as compared\nto the completion which always has a weight of 1.0), and can add\na stabilizing effect to training when completions are short.\n\nIf prompts are extremely long (relative to completions), it may make\nsense to reduce this weight so as to avoid over-prioritizing\nlearning the prompt.\n", + "nullable": true, + "type": "number" + }, + "suffix": { + "default": null, + "description": "A string of up to 40 characters that will be added to your fine-tuned model name.\n\nFor example, a `suffix` of \"custom-model-name\" would produce a model name like `ada:ft-your-org:custom-model-name-2022-02-15-04-21-04`.\n", + "maxLength": 40, + "minLength": 1, + "nullable": true, + "type": "string" + }, + "training_file": { + "description": "The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/upload) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file, where each training\nexample is a JSON object with the keys \"prompt\" and \"completion\".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.\n", + "example": "file-ajSREls59WBbvgSzJSVWxMCB", + "type": "string" + }, + "validation_file": { + "description": "The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe [fine-tuning results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\nYour train and validation data should be mutually exclusive.\n\nYour dataset must be formatted as a JSONL file, where each validation\nexample is a JSON object with the keys \"prompt\" and \"completion\".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.\n", + "example": "file-XjSREls59WBbvgSzJSVWxMCa", + "nullable": true, + "type": "string" + } + }, + "required": [ + "training_file" + ], + "type": "object" + }, + "CreateImageEditRequest": { + "properties": { + "image": { + "description": "The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.", + "format": "binary", + "type": "string" + }, + "mask": { + "description": "An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.", + "format": "binary", + "type": "string" + }, + "n": { + "$ref": "#/components/schemas/CreateImageRequest/properties/n" + }, + "prompt": { + "description": "A text description of the desired image(s). The maximum length is 1000 characters.", + "example": "A cute baby sea otter wearing a beret", + "type": "string" + }, + "response_format": { + "$ref": "#/components/schemas/CreateImageRequest/properties/response_format" + }, + "size": { + "$ref": "#/components/schemas/CreateImageRequest/properties/size" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "prompt", + "image" + ], + "type": "object" + }, + "CreateImageRequest": { + "properties": { + "n": { + "default": 1, + "description": "The number of images to generate. Must be between 1 and 10.", + "example": 1, + "maximum": 10, + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "prompt": { + "description": "A text description of the desired image(s). The maximum length is 1000 characters.", + "example": "A cute baby sea otter", + "type": "string" + }, + "response_format": { + "default": "url", + "description": "The format in which the generated images are returned. Must be one of `url` or `b64_json`.", + "enum": [ + "url", + "b64_json" + ], + "example": "url", + "nullable": true, + "type": "string" + }, + "size": { + "default": "1024x1024", + "description": "The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.", + "enum": [ + "256x256", + "512x512", + "1024x1024" + ], + "example": "1024x1024", + "nullable": true, + "type": "string" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "prompt" + ], + "type": "object" + }, + "CreateImageVariationRequest": { + "properties": { + "image": { + "description": "The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.", + "format": "binary", + "type": "string" + }, + "n": { + "$ref": "#/components/schemas/CreateImageRequest/properties/n" + }, + "response_format": { + "$ref": "#/components/schemas/CreateImageRequest/properties/response_format" + }, + "size": { + "$ref": "#/components/schemas/CreateImageRequest/properties/size" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "image" + ], + "type": "object" + }, + "CreateModerationRequest": { + "properties": { + "input": { + "description": "The input text to classify", + "oneOf": [ + { + "default": "", + "example": "I want to kill them.", + "type": "string" + }, + { + "items": { + "default": "", + "example": "I want to kill them.", + "type": "string" + }, + "type": "array" + } + ] + }, + "model": { + "default": "text-moderation-latest", + "description": "Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`.\n\nThe default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`.\n", + "example": "text-moderation-stable", + "nullable": false, + "type": "string" + } + }, + "required": [ + "input" + ], + "type": "object" + }, + "CreateModerationResponse": { + "properties": { + "id": { + "type": "string" + }, + "model": { + "type": "string" + }, + "results": { + "items": { + "properties": { + "categories": { + "properties": { + "hate": { + "type": "boolean" + }, + "hate/threatening": { + "type": "boolean" + }, + "self-harm": { + "type": "boolean" + }, + "sexual": { + "type": "boolean" + }, + "sexual/minors": { + "type": "boolean" + }, + "violence": { + "type": "boolean" + }, + "violence/graphic": { + "type": "boolean" + } + }, + "required": [ + "hate", + "hate/threatening", + "self-harm", + "sexual", + "sexual/minors", + "violence", + "violence/graphic" + ], + "type": "object" + }, + "category_scores": { + "properties": { + "hate": { + "type": "number" + }, + "hate/threatening": { + "type": "number" + }, + "self-harm": { + "type": "number" + }, + "sexual": { + "type": "number" + }, + "sexual/minors": { + "type": "number" + }, + "violence": { + "type": "number" + }, + "violence/graphic": { + "type": "number" + } + }, + "required": [ + "hate", + "hate/threatening", + "self-harm", + "sexual", + "sexual/minors", + "violence", + "violence/graphic" + ], + "type": "object" + }, + "flagged": { + "type": "boolean" + } + }, + "required": [ + "flagged", + "categories", + "category_scores" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "id", + "model", + "results" + ], + "type": "object" + }, + "CreateSearchRequest": { + "properties": { + "documents": { + "description": "Up to 200 documents to search over, provided as a list of strings.\n\nThe maximum document length (in tokens) is 2034 minus the number of tokens in the query.\n\nYou should specify either `documents` or a `file`, but not both.\n", + "example": "['White House', 'hospital', 'school']", + "items": { + "type": "string" + }, + "maxItems": 200, + "minItems": 1, + "nullable": true, + "type": "array" + }, + "file": { + "description": "The ID of an uploaded file that contains documents to search over.\n\nYou should specify either `documents` or a `file`, but not both.\n", + "nullable": true, + "type": "string" + }, + "max_rerank": { + "default": 200, + "description": "The maximum number of documents to be re-ranked and returned by search.\n\nThis flag only takes effect when `file` is set.\n", + "minimum": 1, + "nullable": true, + "type": "integer" + }, + "query": { + "description": "Query to search against the documents.", + "example": "the president", + "minLength": 1, + "type": "string" + }, + "return_metadata": { + "default": false, + "description": "A special boolean flag for showing metadata. If set to `true`, each document entry in the returned JSON will contain a \"metadata\" field.\n\nThis flag only takes effect when `file` is set.\n", + "nullable": true, + "type": "boolean" + }, + "user": { + "$ref": "#/components/schemas/CreateCompletionRequest/properties/user" + } + }, + "required": [ + "query" + ], + "type": "object" + }, + "CreateSearchResponse": { + "properties": { + "data": { + "items": { + "properties": { + "document": { + "type": "integer" + }, + "object": { + "type": "string" + }, + "score": { + "type": "number" + } + }, + "type": "object" + }, + "type": "array" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + } + }, + "type": "object" + }, + "CreateTranscriptionRequest": { + "additionalProperties": false, + "properties": { + "file": { + "description": "The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.\n", + "format": "binary", + "type": "string" + }, + "language": { + "description": "The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.\n", + "type": "string" + }, + "model": { + "description": "ID of the model to use. Only `whisper-1` is currently available.\n", + "type": "string" + }, + "prompt": { + "description": "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.\n", + "type": "string" + }, + "response_format": { + "default": "json", + "description": "The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.\n", + "type": "string" + }, + "temperature": { + "default": 0, + "description": "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n", + "type": "number" + } + }, + "required": [ + "file", + "model" + ], + "type": "object" + }, + "CreateTranscriptionResponse": { + "properties": { + "text": { + "type": "string" + } + }, + "required": [ + "text" + ], + "type": "object" + }, + "CreateTranslationRequest": { + "additionalProperties": false, + "properties": { + "file": { + "description": "The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.\n", + "format": "binary", + "type": "string" + }, + "model": { + "description": "ID of the model to use. Only `whisper-1` is currently available.\n", + "type": "string" + }, + "prompt": { + "description": "An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.\n", + "type": "string" + }, + "response_format": { + "default": "json", + "description": "The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.\n", + "type": "string" + }, + "temperature": { + "default": 0, + "description": "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n", + "type": "number" + } + }, + "required": [ + "file", + "model" + ], + "type": "object" + }, + "CreateTranslationResponse": { + "properties": { + "text": { + "type": "string" + } + }, + "required": [ + "text" + ], + "type": "object" + }, + "DeleteFileResponse": { + "properties": { + "deleted": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string" + } + }, + "required": [ + "id", + "object", + "deleted" + ], + "type": "object" + }, + "DeleteModelResponse": { + "properties": { + "deleted": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string" + } + }, + "required": [ + "id", + "object", + "deleted" + ], + "type": "object" + }, + "Engine": { + "properties": { + "created": { + "nullable": true, + "type": "integer" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "ready": { + "type": "boolean" + } + }, + "required": [ + "id", + "object", + "created", + "ready" + ], + "title": "Engine" + }, + "FineTune": { + "properties": { + "created_at": { + "type": "integer" + }, + "events": { + "items": { + "$ref": "#/components/schemas/FineTuneEvent" + }, + "type": "array" + }, + "fine_tuned_model": { + "nullable": true, + "type": "string" + }, + "hyperparams": { + "type": "object" + }, + "id": { + "type": "string" + }, + "model": { + "type": "string" + }, + "object": { + "type": "string" + }, + "organization_id": { + "type": "string" + }, + "result_files": { + "items": { + "$ref": "#/components/schemas/OpenAIFile" + }, + "type": "array" + }, + "status": { + "type": "string" + }, + "training_files": { + "items": { + "$ref": "#/components/schemas/OpenAIFile" + }, + "type": "array" + }, + "updated_at": { + "type": "integer" + }, + "validation_files": { + "items": { + "$ref": "#/components/schemas/OpenAIFile" + }, + "type": "array" + } + }, + "required": [ + "id", + "object", + "created_at", + "updated_at", + "model", + "fine_tuned_model", + "organization_id", + "status", + "hyperparams", + "training_files", + "validation_files", + "result_files" + ], + "title": "FineTune" + }, + "FineTuneEvent": { + "properties": { + "created_at": { + "type": "integer" + }, + "level": { + "type": "string" + }, + "message": { + "type": "string" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "created_at", + "level", + "message" + ], + "title": "FineTuneEvent" + }, + "ImagesResponse": { + "properties": { + "created": { + "type": "integer" + }, + "data": { + "items": { + "properties": { + "b64_json": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "created", + "data" + ] + }, + "ListEnginesResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/Engine" + }, + "type": "array" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + }, + "ListFilesResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/OpenAIFile" + }, + "type": "array" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + }, + "ListFineTuneEventsResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/FineTuneEvent" + }, + "type": "array" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + }, + "ListFineTunesResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/FineTune" + }, + "type": "array" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + }, + "ListModelsResponse": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/Model" + }, + "type": "array" + }, + "object": { + "type": "string" + } + }, + "required": [ + "object", + "data" + ], + "type": "object" + }, + "Model": { + "properties": { + "created": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "owned_by": { + "type": "string" + } + }, + "required": [ + "id", + "object", + "created", + "owned_by" + ], + "title": "Model" + }, + "OpenAIFile": { + "properties": { + "bytes": { + "type": "integer" + }, + "created_at": { + "type": "integer" + }, + "filename": { + "type": "string" + }, + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "purpose": { + "type": "string" + }, + "status": { + "type": "string" + }, + "status_details": { + "nullable": true, + "type": "object" + } + }, + "required": [ + "id", + "object", + "bytes", + "created_at", + "filename", + "purpose" + ], + "title": "OpenAIFile" + } + } + }, + "x-oaiMeta": { + "groups": [ + { + "description": "List and describe the various models available in the API. You can refer to the [Models](/docs/models) documentation to understand what models are available and the differences between them.\n", + "id": "models", + "title": "Models" + }, + { + "description": "Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.\n", + "id": "completions", + "title": "Completions" + }, + { + "description": "Given a chat conversation, the model will return a chat completion response.\n", + "id": "chat", + "title": "Chat" + }, + { + "description": "Given a prompt and an instruction, the model will return an edited version of the prompt.\n", + "id": "edits", + "title": "Edits" + }, + { + "description": "Given a prompt and/or an input image, the model will generate a new image.\n\nRelated guide: [Image generation](/docs/guides/images)\n", + "id": "images", + "title": "Images" + }, + { + "description": "Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.\n\nRelated guide: [Embeddings](/docs/guides/embeddings)\n", + "id": "embeddings", + "title": "Embeddings" + }, + { + "description": "Learn how to turn audio into text.\n\nRelated guide: [Speech to text](/docs/guides/speech-to-text)\n", + "id": "audio", + "title": "Audio" + }, + { + "description": "Files are used to upload documents that can be used with features like [Fine-tuning](/docs/api-reference/fine-tunes).\n", + "id": "files", + "title": "Files" + }, + { + "description": "Manage fine-tuning jobs to tailor a model to your specific training data.\n\nRelated guide: [Fine-tune models](/docs/guides/fine-tuning)\n", + "id": "fine-tunes", + "title": "Fine-tunes" + }, + { + "description": "Given a input text, outputs if the model classifies it as violating OpenAI's content policy.\n\nRelated guide: [Moderations](/docs/guides/moderation)\n", + "id": "moderations", + "title": "Moderations" + }, + { + "description": "Given a query and a set of documents or labels, the model ranks each document based on its semantic similarity to the provided query.\n\nRelated guide: [Search](/docs/guides/search)\n", + "id": "searches", + "title": "Searches", + "warning": { + "message": "We’ve developed new methods with better performance. [Learn more](https://help.openai.com/en/articles/6272952-search-transition-guide).", + "title": "This endpoint is deprecated and will be removed on December 3rd, 2022" + } + }, + { + "description": "Given a query and a set of labeled examples, the model will predict the most likely label for the query. Useful as a drop-in replacement for any ML classification or text-to-label task.\n\nRelated guide: [Classification](/docs/guides/classifications)\n", + "id": "classifications", + "title": "Classifications", + "warning": { + "message": "We’ve developed new methods with better performance. [Learn more](https://help.openai.com/en/articles/6272941-classifications-transition-guide).", + "title": "This endpoint is deprecated and will be removed on December 3rd, 2022" + } + }, + { + "description": "Given a question, a set of documents, and some examples, the API generates an answer to the question based on the information in the set of documents. This is useful for question-answering applications on sources of truth, like company documentation or a knowledge base.\n\nRelated guide: [Question answering](/docs/guides/answers)\n", + "id": "answers", + "title": "Answers", + "warning": { + "message": "We’ve developed new methods with better performance. [Learn more](https://help.openai.com/en/articles/6233728-answers-transition-guide).", + "title": "This endpoint is deprecated and will be removed on December 3rd, 2022" + } + }, + { + "description": "These endpoints describe and provide access to the various engines available in the API.", + "id": "engines", + "title": "Engines", + "warning": { + "message": "Please use their replacement, [Models](/docs/api-reference/models), instead. [Learn more](https://help.openai.com/TODO).", + "title": "The Engines endpoints are deprecated." + } + } + ] + } + } \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_apic_scenarios.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_apic_scenarios.yaml new file mode 100644 index 00000000000..29c2eda87bd --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_apic_scenarios.yaml @@ -0,0 +1,3540 @@ +interactions: +- request: + body: '{"properties": {"kind": "development", "server": {"managementPortalUri": + ["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service-0"], + "type": "Azure API Management"}, "title": "Public cloud"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic environment create + Connection: + - keep-alive + Content-Length: + - '311' + Content-Type: + - application/json + ParameterSetName: + - -g -s --name --title --kind --server + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:19.1988805Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service-0"]},"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '694' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:18 GMT + etag: + - 0800317f-0000-3300-0000-656687bf0000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic environment update + Connection: + - keep-alive + ParameterSetName: + - -g -s --name --title --kind --server -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:19.1988805Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service-0"]},"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '694' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:19 GMT + etag: + - 0800317f-0000-3300-0000-656687bf0000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"customProperties": {}, "kind": "development", "server": + {"managementPortalUri": ["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"], + "type": "Azure API Management"}, "title": "Public cloud"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic environment update + Connection: + - keep-alive + Content-Length: + - '333' + Content-Type: + - application/json + ParameterSetName: + - -g -s --name --title --kind --server -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:20.325193Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:19 GMT + etag: + - 0800337f-0000-3300-0000-656687c00000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic environment show + Connection: + - keep-alive + ParameterSetName: + - -g -s --name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:20.325193Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:20 GMT + etag: + - 0800337f-0000-3300-0000-656687c00000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic environment list + Connection: + - keep-alive + ParameterSetName: + - -g -s + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments?api-version=2024-03-01 + response: + body: + string: '{"value":[{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/metadata-test-env","name":"metadata-test-env","systemData":{"createdAt":"2023-08-02T15:06:50.5631147Z","lastModifiedAt":"2023-09-05T14:11:02.7886448Z"},"properties":{"title":"Metadata + test env","server":{"type":"azure-api-management","managementPortalUri":[]},"onboarding":{"developerPortalUri":[]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/production","name":"production","systemData":{"createdAt":"2023-08-28T20:40:54.4152308Z","lastModifiedAt":"2023-08-28T20:40:54.4152526Z"},"properties":{"title":"Contoso + Europe Azure API Management","description":"The primary Azure API Management + service for the European division of Contoso.","server":{"type":"Azure API + Management","managementPortalUri":["https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"onboarding":{"instructions":"Sign + in or sign up in the specified developer portal to request API access. You + must complete the internal privacy training for your account to be approved.","developerPortalUri":["https://developer.contoso.com"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/test-env-for-depl","name":"test-env-for-depl","systemData":{"createdAt":"2023-08-30T14:28:25.8546451Z","lastModifiedAt":"2023-11-14T22:54:17.5088956Z"},"properties":{"title":"Contoso + Europe Azure API Management","kind":"production","description":"The primary + Azure API Management service for the European division of Contoso.","server":{"type":"Azure + API Management","managementPortalUri":["https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"onboarding":{"instructions":"Sign + in or sign up in the specified developer portal to request API access. You + must complete the internal privacy training for your account to be approved.","developerPortalUri":["https://developer.contoso.com"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/apim-test","name":"apim-test","systemData":{"createdAt":"2023-11-01T14:39:10.2346949Z","lastModifiedAt":"2023-11-14T23:09:47.5310688Z"},"properties":{"title":"Contoso + Europe Azure API Management","kind":"production","description":"The primary + Azure API Management service for the European division of Contoso.","server":{"type":"Azure + API Management","managementPortalUri":["https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"onboarding":{"instructions":"Sign + in or sign up in the specified developer portal to request API access. You + must complete the internal privacy training for your account to be approved.","developerPortalUri":["https://developer.contoso.com"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/apim","name":"apim","systemData":{"createdAt":"2023-11-09T01:37:33.3789162Z","lastModifiedAt":"2023-11-14T23:09:41.5126901Z"},"properties":{"title":"Contoso + Europe Azure API Management","kind":"production","description":"The primary + Azure API Management service for the European division of Contoso.","server":{"type":"Azure + API Management","managementPortalUri":["https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"onboarding":{"instructions":"Sign + in or sign up in the specified developer portal to request API access. You + must complete the internal privacy training for your account to be approved.","developerPortalUri":["https://developer.contoso.com"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/apim-ignite23","name":"apim-ignite23","systemData":{"createdAt":"2023-11-15T18:21:12.5751434Z","lastModifiedAt":"2023-11-15T18:21:12.5751436Z"},"properties":{"title":"Ignite + 2023 Azure API Management","kind":"production","description":"The primary + Azure API Management service for European division of Contoso","server":{"type":"azure-api-management","managementPortalUri":["https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service"]},"onboarding":{"instructions":"Sign + in or sign up","developerPortalUri":["https://developer.abcd.com"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/public-2","name":"public-2","systemData":{"createdAt":"2023-11-20T20:46:43.0550419Z","lastModifiedAt":"2023-11-20T20:46:43.0550789Z"},"properties":{"title":"Public + cloud","kind":"development","customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/public-3","name":"public-3","systemData":{"createdAt":"2023-11-20T20:52:17.473183Z","lastModifiedAt":"2023-11-28T04:46:03.372605Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/testpublic","name":"testpublic","systemData":{"createdAt":"2023-11-22T15:50:59.2415397Z","lastModifiedAt":"2023-11-22T16:50:42.7816893Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}},{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:20.325193Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}}]}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '8128' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:21 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"description": "CLI Test API 106", "kind": "rest", "title": + "CLI Test API 106"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api create + Connection: + - keep-alive + Content-Length: + - '96' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --description --kind --title + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/apis","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106","name":"cli-test-api-106","systemData":{"createdAt":"2023-11-29T00:37:22.3456411Z","lastModifiedAt":"2023-11-29T00:37:22.3456422Z"},"properties":{"title":"CLI + Test API 106","description":"CLI Test API 106","kind":"rest","lifecycleStage":"design","externalDocumentation":[],"contacts":[],"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '536' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:22 GMT + etag: + - 6e003e49-0000-3300-0000-656687c20000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api show + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/apis","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106","name":"cli-test-api-106","systemData":{"createdAt":"2023-11-29T00:37:22.3456411Z","lastModifiedAt":"2023-11-29T00:37:22.3456422Z"},"properties":{"title":"CLI + Test API 106","description":"CLI Test API 106","kind":"rest","lifecycleStage":"design","externalDocumentation":[],"contacts":[],"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '536' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:22 GMT + etag: + - 6e003e49-0000-3300-0000-656687c20000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api list + Connection: + - keep-alive + ParameterSetName: + - -g -s + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis?api-version=2024-03-01 + response: + body: + string: "{\"value\":[{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/petstore-api\",\"name\":\"petstore-api\",\"systemData\":{\"createdAt\":\"2023-11-08T18:57:32.3783991Z\",\"lastModifiedAt\":\"2023-11-28T21:20:33.549201Z\"},\"properties\":{\"title\":\"Petstore-Api\",\"kind\":\"rest\",\"lifecycleStage\":\"design\",\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{\"metadata-test-2\":true,\"metadata-test-1\":\"abc\"}}},{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/ensight-servicereports\",\"name\":\"ensight-servicereports\",\"systemData\":{\"createdAt\":\"2023-11-10T22:24:10.4970866Z\",\"lastModifiedAt\":\"2023-11-10T22:24:10.4971093Z\"},\"properties\":{\"title\":\"ensight-servicereports\",\"description\":\"**ENSIGHT + Servicereports API** verf\xFCgt \xFCber den prim\xE4ren Endpunkt [Get Servicereports](https://dev-core-base-apim.developer.azure-api.net/api-details#api=ENSIGHT-API-Servicereportsv1&operation=GlobalServiceProtocol) + mithilfe dessen Servicereports - Dokumentationen von Betriebs- und Instandhaltungsmassnahmen + von Kraftwerken f\xFCr erneuerbare Energien - in Form des Globalen Service + Protokolls (GSP, engl. 'Global Service Protocol') abgefragt werden k\xF6nnen. + Derzeit stehen die Servicereports folgender Dienstleister f\xFCr Betriebs- + und Instandhaltungsmassnahmen zur Verf\xFCgung:\\r\\n- CWS Connected Wind + Services GmbH (seit --/----),\\r\\n- EnBW Energie Baden-W\xFCrttemberg AG + (seit 12/2019),\\r\\n- Nordex Energy GmbH (seit 11/2017),\\r\\n- Siemens Gamesa + Renewable Energy AG (seit 12/2019), und\\r\\n- Vestas Deutschland GmbH (seit + 07/2016).\\r\\n*Stand: 03. August 2022*\\r\\n\\r\\nDas Globale Service Protokoll + ist ein Teil der technischen Richtlinie f\xFCr Erzeugungseinheiten, die zum + 01.01.2014 von der FGW F\xF6rdergesellschaft Windenergie und andere Erneuerbare + Energien e.V. herausgegeben wurde. Ziel des GSP ist 'die Bereitstellung eines + einheitlichen elektronischen Datenformates, welches die Kommunikation verschiedener + an der Instandhaltung von erneuerbaren Energieanlagen beteiligter Akteure + erm\xF6glicht'.\\r\\n\\r\\nDie Entit\xE4tstypen aus dem Entity Data Model + der Globalen Service Protokolle sowie deren Eigenschaften werden \xFCber den + Endpunkt [Get Metadata](https://dev-core-base-apim.developer.azure-api.net/api-details#api=ENSIGHT-API-Servicereportsv1&operation=metadata) + im XML-Format bereitgestellt.\\r\\n### Datenquellen\\r\\nDie Daten f\xFCr + Betrieb- und Instandhaltungsmassnahmen werden von den entsprechenden Dienstleistern + bezogen, wobei sich die Quellformate wie folgt unterscheiden:\\r\\n- CWS Connected + Wind Services GmbH via REST API,\\r\\n- EnBW Energie Baden-W\xFCrttemberg + AG via SAP,\\r\\n- Nordex Energy GmbH via *.pdf,\\r\\n- Siemens Gamesa Renewable + Energy AG via *.xlsx, und\\r\\n- Vestas Deutschland GmbH via *.xml.\\r\\n### + OData\\r\\nBei ENSIGHT Servicereports ist die OData-Funktionalit\xE4t gegeben. + Hierdurch k\xF6nnen die im Folgenden aufgef\xFChrten Optionen sowie vergleichende + und logische Operatoren f\xFCr eine Abfrage spezifiziert werden.\\r\\n\\r\\n**Optionen**\\r\\n\\r\\n- + *apply*,\\r\\n- *count*,\\r\\n- *filter*,\\r\\n- *orderby*,\\r\\n- *select*,\\r\\n- + *skip*, und\\r\\n- *top*.\\r\\n\\r\\n**Vergleichsoperatoren**\\r\\n\\r\\n- + *eq*,\\r\\n- *ne*,\\r\\n- *gt*,\\r\\n- *lt*,\\r\\n- *ge*, und\\r\\n- *le*.\\r\\n\\r\\nWeitere + Informationen zu Vergleichsoperatoren werden hier von Microsoft angeboten: + [Comparison Operators](https://docs.microsoft.com/en-us/azure/search/search-query-odata-comparison-operators)\\r\\n\\r\\n**Logische + Operatoren**\\r\\n\\r\\n- *and*,\\r\\n- *or*, und\\r\\n- *not*.\\r\\n\\r\\nWeitere + Informationen zu logischen Operatoren werden hier von Microsoft angeboten: + [Logical Operators](https://docs.microsoft.com/en-us/azure/search/search-query-odata-logical-operators)\\r\\n\\r\\n\\r\\nBeispielhafte + Anwendungen von OData-Abfragen werden hier von Microsoft aufgef\xFChrt: [Query + Options Overview](https://docs.microsoft.com/en-us/odata/concepts/queryoptions-overview).\\r\\nDie + Optionen k\xF6nnen der Abfrage entweder als Parameter oder direkt \xFCber + die URL hinzugef\xFCgt werden, wie es hier von Microsoft beschrieben wird: + [URL Query](https://docs.microsoft.com/en-us/odata/concepts/url-components).\\r\\nWeitere, + umf\xE4ngliche Informationen zu OData sind hier in der Dokumentation zu finden: + [OData Documentation](https://www.odata.org/documentation/)\\r\\n\\r\\n*F\xFCr + den Umgang mit Daten im OData-Kontext bedarf es folgendes Format: ISO 8601. + Besipiel: 2019-06-03T00:00:00Z.*\\r\\n\\r\\n**Beispiele f\xFCr ENSIGHT Servicereports**\\r\\n\\r\\n*Anzahl + der Servicereports nach Dienstleister*\\r\\n\\r\\n [URL]?$apply=groupby((workOrder/contractor/name), + aggregate(id with countdistinct as total))\\r\\n\\r\\n*Anzahl der Servicereports + nach Windpark*\\r\\n\\r\\n [URL]?$apply=groupby((powerPlant/id), aggregate(id + with countdistinct as total))\\r\\n\\r\\n*Name und Beschreibung des Vestas-Servicereports + 55636522*\\r\\n\\r\\n [URL]?$filter=gspInfo/documentId eq 'VESTAS_55636522'&$select=workReport/items/name,workReport/items/longDescription\\r\\n\\r\\n*Materialverbrauch + des Nordex-Serviceberichts 600180286*\\r\\n\\r\\n [URL]?$filter=gspInfo/documentId + eq 'NORDEX_600180286'&$select=workReport/items/materials\",\"lifecycleStage\":\"design\",\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{}}},{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/customer-issue\",\"name\":\"customer-issue\",\"systemData\":{\"createdAt\":\"2023-11-11T00:29:24.954375Z\",\"lastModifiedAt\":\"2023-11-11T00:29:24.9543769Z\"},\"properties\":{\"title\":\"customer-issue\",\"lifecycleStage\":\"design\",\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{}}},{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/uber-api\",\"name\":\"uber-api\",\"systemData\":{\"createdAt\":\"2023-11-14T20:32:01.6772075Z\",\"lastModifiedAt\":\"2023-11-14T20:36:19.4958358Z\"},\"properties\":{\"title\":\"Uber + API\",\"summary\":\"Move your app forward with the Uber API\",\"description\":\"Move + your app forward with the Uber API\",\"kind\":\"rest\",\"lifecycleStage\":\"design\",\"termsOfService\":{},\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{}}},{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/swagger-petstore\",\"name\":\"swagger-petstore\",\"systemData\":{\"createdAt\":\"2023-11-15T00:39:28.4314069Z\",\"lastModifiedAt\":\"2023-11-15T00:39:28.4314279Z\"},\"properties\":{\"title\":\"swagger-petstore\",\"description\":\"This + is a sample server Petstore server. You can find out more about Swagger at + [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). + \ For this sample, you can use the api key `special-key` to test the authorization + filters.\",\"lifecycleStage\":\"design\",\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{}}},{\"type\":\"Microsoft.ApiCenter/services/apis\",\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106\",\"name\":\"cli-test-api-106\",\"systemData\":{\"createdAt\":\"2023-11-29T00:37:22.3456411Z\",\"lastModifiedAt\":\"2023-11-29T00:37:22.3456422Z\"},\"properties\":{\"title\":\"CLI + Test API 106\",\"description\":\"CLI Test API 106\",\"kind\":\"rest\",\"lifecycleStage\":\"design\",\"externalDocumentation\":[],\"contacts\":[],\"customProperties\":{}}}]}" + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '7788' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:23 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"title": "cli-test-2023-01-02"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api version create + Connection: + - keep-alive + Content-Length: + - '48' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --name --title + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02","name":"cli-test-2023-01-02","systemData":{"createdAt":"2023-11-29T00:37:24.4649903Z","lastModifiedAt":"2023-11-29T00:37:24.4649903Z"},"properties":{"title":"cli-test-2023-01-02","lifecycleStage":"design"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '465' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:24 GMT + etag: + - 9a0072b9-0000-3300-0000-656687c40000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api version update + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02","name":"cli-test-2023-01-02","systemData":{"createdAt":"2023-11-29T00:37:24.4649903Z","lastModifiedAt":"2023-11-29T00:37:24.4649903Z"},"properties":{"title":"cli-test-2023-01-02","lifecycleStage":"design"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '465' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:24 GMT + etag: + - 9a0072b9-0000-3300-0000-656687c40000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"lifecycleStage": "design", "title": "CLI Test API Version + 0"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api version update + Connection: + - keep-alive + Content-Length: + - '79' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02","name":"cli-test-2023-01-02","systemData":{"createdAt":"2023-11-29T00:37:24.4649903Z","lastModifiedAt":"2023-11-29T00:37:25.4952003Z"},"properties":{"title":"CLI + Test API Version 0","lifecycleStage":"design"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '468' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:25 GMT + etag: + - 9a007cb9-0000-3300-0000-656687c50000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api version show + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02","name":"cli-test-2023-01-02","systemData":{"createdAt":"2023-11-29T00:37:24.4649903Z","lastModifiedAt":"2023-11-29T00:37:25.4952003Z"},"properties":{"title":"CLI + Test API Version 0","lifecycleStage":"design"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '468' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:26 GMT + etag: + - 9a007cb9-0000-3300-0000-656687c50000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api version list + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions?api-version=2024-03-01 + response: + body: + string: '{"value":[{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02","name":"cli-test-2023-01-02","systemData":{"createdAt":"2023-11-29T00:37:24.4649903Z","lastModifiedAt":"2023-11-29T00:37:25.4952003Z"},"properties":{"title":"CLI + Test API Version 0","lifecycleStage":"design"}}]}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '480' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:26 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"title": "OpenAPI"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition create + Connection: + - keep-alive + Content-Length: + - '36' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --version --name --title + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","name":"cli-test-openapi-106","systemData":{"createdAt":"2023-11-24T04:36:51.2266973Z","lastModifiedAt":"2023-11-29T00:37:27.6778681Z"},"properties":{"title":"OpenAPI","specification":{"name":"openapi","version":"3.0.0"}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '517' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:27 GMT + etag: + - 00000a01-0000-3300-0000-656687c70000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition update + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --version --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","name":"cli-test-openapi-106","systemData":{"createdAt":"2023-11-24T04:36:51.2266973Z","lastModifiedAt":"2023-11-29T00:37:27.6778681Z"},"properties":{"title":"OpenAPI","specification":{"name":"openapi","version":"3.0.0"}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '517' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:27 GMT + etag: + - 00000a01-0000-3300-0000-656687c70000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"title": "CLI Test API Definition 0"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition update + Connection: + - keep-alive + Content-Length: + - '54' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --version --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","name":"cli-test-openapi-106","systemData":{"createdAt":"2023-11-24T04:36:51.2266973Z","lastModifiedAt":"2023-11-29T00:37:28.5978862Z"},"properties":{"title":"CLI + Test API Definition 0","specification":{"name":"openapi","version":"3.0.0"}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '535' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:27 GMT + etag: + - 00000b01-0000-3300-0000-656687c80000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition show + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --version --name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","name":"cli-test-openapi-106","systemData":{"createdAt":"2023-11-24T04:36:51.2266973Z","lastModifiedAt":"2023-11-29T00:37:28.5978862Z"},"properties":{"title":"CLI + Test API Definition 0","specification":{"name":"openapi","version":"3.0.0"}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '535' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:28 GMT + etag: + - 00000b01-0000-3300-0000-656687c80000 + 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-msedge-ref: + - 'Ref A: 3CAA6C2332F9486FA8C93DB25833038C Ref B: SN4AA2022302035 Ref C: 2023-11-29T00:37:29Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition list + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --version + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions?api-version=2024-03-01 + response: + body: + string: '{"value":[{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","name":"cli-test-openapi-106","systemData":{"createdAt":"2023-11-24T04:36:51.2266973Z","lastModifiedAt":"2023-11-29T00:37:28.5978862Z"},"properties":{"title":"CLI + Test API Definition 0","specification":{"name":"openapi","version":"3.0.0"}}}]}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '547' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:29 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-msedge-ref: + - 'Ref A: FFBBA555E1004D52A83FE29475C8C244 Ref B: DM2AA1091211047 Ref C: 2023-11-29T00:37:29Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"format": "inline", "specification": {"name": "openapi", "version": "3.0.0"}, + "value": "{\"openapi\": \"3.0.0\", \"info\": {\"title\": \"Sample API 101\", + \"description\": \"API description in Markdown. 101\", \"version\": \"1.0.0\"}, + \"servers\": [{\"url\": \"http://api.example.com/v1\"}], \"paths\": {\"/users\": + {\"get\": {\"summary\": \"Returns a list of users.\", \"description\": \"Optional + extended description in Markdown.\", \"responses\": {\"200\": {\"description\": + \"A JSON array of user names\", \"content\": {\"application/json\": {\"schema\": + {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}}}}}}}"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition import-specification + Connection: + - keep-alive + Content-Length: + - '626' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --version --name --format --specification --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106/importSpecification?api-version=2024-03-01 + response: + body: + string: '' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '0' + date: + - Wed, 29 Nov 2023 00:37:30 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106/operationResults/b2118ba0-9884-4a2a-8bea-0082985ed8b0?api-version=2024-03-01 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 6D2F1FD2759B4CD5A0C644D7B25EC516 Ref B: SN4AA2022303027 Ref C: 2023-11-29T00:37:30Z' + x-powered-by: + - ASP.NET + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition import-specification + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --version --name --format --specification --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106/operationResults/b2118ba0-9884-4a2a-8bea-0082985ed8b0?api-version=2024-03-01 + response: + body: + string: '{"apiName":"default","apiVersion":"cli-test-2023-01-02","catalogName":"contosoeuap","provisioningState":"Succeeded","error":{"message":""}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '139' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:30 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-msedge-ref: + - 'Ref A: 519E2E277D5F445BB5BEABAE6705FBF3 Ref B: SN4AA2022303027 Ref C: 2023-11-29T00:37:30Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api definition export-specification + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -s --api-name --version --name --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106/exportSpecification?api-version=2024-03-01 + response: + body: + string: '{"format":"inline","value":"{\"openapi\": \"3.0.0\", \"info\": {\"title\": + \"Sample API 101\", \"description\": \"API description in Markdown. 101\", + \"version\": \"1.0.0\"}, \"servers\": [{\"url\": \"http://api.example.com/v1\"}], + \"paths\": {\"/users\": {\"get\": {\"summary\": \"Returns a list of users.\", + \"description\": \"Optional extended description in Markdown.\", \"responses\": + {\"200\": {\"description\": \"A JSON array of user names\", \"content\": {\"application/json\": + {\"schema\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}}}}}}}"}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '565' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:31 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 47A372177331425E8F52BF6142DE2BA2 Ref B: SN4AA2022303031 Ref C: 2023-11-29T00:37:31Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"definitionId": "/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106", + "description": "CLI Test Public cloud production deployment.", "environmentId": + "/workspaces/default/environments/cli-test-public", "server": {"runtimeUri": + ["https://api.contoso.com"]}, "title": "CLI Test Production deployment"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api deployment create + Connection: + - keep-alive + Content-Length: + - '369' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --name --title --description --environment-id --definition-id + --server + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/mock-deployment?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/production","name":"production","systemData":{"createdAt":"2023-11-29T00:37:32.7590411Z","lastModifiedAt":"2023-11-29T00:37:32.7590411Z"},"properties":{"title":"CLI + Test Production deployment","description":"CLI Test Public cloud production + deployment.","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","server":{"runtimeUri":["https://api.contoso.com"]},"customProperties":{},"recommended":false}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '781' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:32 GMT + etag: + - 0c00f79a-0000-3300-0000-656687cc0000 + 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: A775BED7A86B45F6AC881AE659B49758 Ref B: SN4AA2022304023 Ref C: 2023-11-29T00:37:32Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api deployment show + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/mock-deployment?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/production","name":"production","systemData":{"createdAt":"2023-11-29T00:37:32.7590411Z","lastModifiedAt":"2023-11-29T00:37:32.7590411Z"},"properties":{"title":"CLI + Test Production deployment","description":"CLI Test Public cloud production + deployment.","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","server":{"runtimeUri":["https://api.contoso.com"]},"customProperties":{},"recommended":false}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '781' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:33 GMT + etag: + - 0c00f79a-0000-3300-0000-656687cc0000 + 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-msedge-ref: + - 'Ref A: 95366EE161A64EECA6B668010553962E Ref B: SN4AA2022304047 Ref C: 2023-11-29T00:37:33Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api deployment update + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/mock-deployment?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/production","name":"production","systemData":{"createdAt":"2023-11-29T00:37:32.7590411Z","lastModifiedAt":"2023-11-29T00:37:32.7590411Z"},"properties":{"title":"CLI + Test Production deployment","description":"CLI Test Public cloud production + deployment.","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","server":{"runtimeUri":["https://api.contoso.com"]},"customProperties":{},"recommended":false}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '781' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:33 GMT + etag: + - 0c00f79a-0000-3300-0000-656687cc0000 + 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-msedge-ref: + - 'Ref A: B08C21F4C5BA4173BAB47FDE11604037 Ref B: DM2AA1091213047 Ref C: 2023-11-29T00:37:33Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"customProperties": {}, "definitionId": "/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106", + "description": "CLI Test Public cloud production deployment.", "environmentId": + "/workspaces/default/environments/cli-test-public", "server": {"runtimeUri": + ["https://api.contoso.com"]}, "title": "CLI Test Production deployment update"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api deployment update + Connection: + - keep-alive + Content-Length: + - '400' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-name --name --title -w + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/mock-deployment?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/production","name":"production","systemData":{"createdAt":"2023-11-29T00:37:32.7590411Z","lastModifiedAt":"2023-11-29T00:37:34.3376453Z"},"properties":{"title":"CLI + Test Production deployment update","description":"CLI Test Public cloud production + deployment.","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","server":{"runtimeUri":["https://api.contoso.com"]},"customProperties":{},"recommended":false}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '788' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:34 GMT + etag: + - 0c00f89a-0000-3300-0000-656687ce0000 + 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 409433B794F54C128553F217B1A12BCD Ref B: DM2AA1091213047 Ref C: 2023-11-29T00:37:34Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api deployment list + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments?api-version=2024-03-01 + response: + body: + string: '{"value":[{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-api-106/deployments/production","name":"production","systemData":{"createdAt":"2023-11-29T00:37:32.7590411Z","lastModifiedAt":"2023-11-29T00:37:34.3376453Z"},"properties":{"title":"CLI + Test Production deployment update","description":"CLI Test Public cloud production + deployment.","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-api-106/versions/cli-test-2023-01-02/definitions/cli-test-openapi-106","server":{"runtimeUri":["https://api.contoso.com"]},"customProperties":{},"recommended":false}}]}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '800' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:34 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-msedge-ref: + - 'Ref A: 7912630E8FE54DDE8FAC2139BD1C449E Ref B: DM2AA1091212047 Ref C: 2023-11-29T00:37:34Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"schema": "{\"type\": \"string\", \"title\": \"CLI Test + First name\", \"pattern\": \"^[a-zA-Z0-9 ]+$\"}"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic metadata-schema create + Connection: + - keep-alive + Content-Length: + - '122' + Content-Type: + - application/json + ParameterSetName: + - -g -s --name --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/metadataSchemas/cli-test-metadata-schema-1?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/metadataSchema","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/metadataSchema/cli-test-metadata-schema-1","name":"cli-test-metadata-schema-1","systemData":{"createdAt":"2023-11-24T04:18:02.4538124Z","lastModifiedAt":"2023-11-29T00:37:35.7449241Z"},"properties":{"assignedTo":[],"schema":"{\"type\": + \"string\", \"title\": \"CLI Test First name\", \"pattern\": \"^[a-zA-Z0-9 + ]+$\"}"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '514' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:35 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 1E4BB2FFF5834FDCB03696445C9D9A1D Ref B: DM2AA1091214027 Ref C: 2023-11-29T00:37:35Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"assignedTo": "api"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic metadata-schema export-metadata-schema + Connection: + - keep-alive + Content-Length: + - '21' + Content-Type: + - application/json + ParameterSetName: + - -g -s --assigned-to --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/exportMetadataSchema?api-version=2024-03-01 + response: + body: + string: '{"format":"json-schema","value":"{\"type\":\"object\",\"properties\":{\"title\":{\"description\":\"The + name of the API.\",\"type\":\"string\",\"maxLength\":50},\"summary\":{\"description\":\"Short + description of the API.\",\"type\":\"string\",\"maxLength\":200},\"description\":{\"description\":\"The + description of the API.\",\"type\":\"string\",\"maxLength\":1000},\"kind\":{\"description\":\"Kind + of API. For example, REST or GraphQL.\",\"type\":\"string\"},\"lifecycleStage\":{\"description\":\"Current + lifecycle stage of the API.\",\"type\":\"string\",\"enum\":[\"design\",\"development\",\"testing\",\"preview\",\"production\",\"deprecated\",\"retired\"]},\"termsOfService\":{\"description\":\"Terms + of service for the API.\",\"type\":\"object\",\"properties\":{\"url\":{\"description\":\"URL + pointing to the terms of service.\",\"type\":\"string\",\"maxLength\":200,\"format\":\"uri\"}}},\"license\":{\"description\":\"The + license information for the API.\",\"type\":\"object\",\"properties\":{\"name\":{\"description\":\"Name + of the license.\",\"type\":\"string\",\"maxLength\":50},\"url\":{\"description\":\"URL + pointing to the license details. The URL field is mutually exclusive of the + identifier field.\",\"type\":\"string\",\"maxLength\":200,\"format\":\"uri\"},\"identifier\":{\"description\":\"SPDX + license information for the API. The identifier field is mutually exclusive + of the URL field.\",\"type\":\"string\",\"maxLength\":200,\"format\":\"uri\"}}},\"externalDocumentation\":{\"description\":\"External + documentation\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"title\":{\"description\":\"Title + of the documentation.\",\"type\":\"string\",\"maxLength\":50},\"description\":{\"description\":\"Description + of the documentation.\",\"type\":\"string\",\"maxLength\":1000},\"url\":{\"description\":\"URL + pointing to the documentation.\",\"type\":\"string\",\"maxLength\":200,\"format\":\"uri\"}}},\"maxItems\":20},\"contacts\":{\"description\":\"Points + of contact for the API.\",\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"description\":\"Name + of the contact.\",\"type\":\"string\",\"maxLength\":100},\"url\":{\"description\":\"URL + for the contact.\",\"type\":\"string\",\"maxLength\":200,\"format\":\"uri\"},\"email\":{\"description\":\"Email + address for the contact.\",\"type\":\"string\",\"maxLength\":100,\"format\":\"email\"}}},\"maxItems\":10},\"customProperties\":{\"type\":\"object\",\"properties\":{\"compliance-status\":{\"type\":\"string\",\"title\":\"compliance-status\",\"oneOf\":[{\"const\":\"new\",\"description\":\"\"},{\"const\":\"pending\",\"description\":\"\"},{\"const\":\"solved\",\"description\":\"\"}]},\"approver\":{\"title\":\"approver\",\"type\":\"string\"},\"cost-center\":{\"title\":\"cost-center\",\"type\":\"string\"},\"ownership\":{\"title\":\"ownership\",\"type\":\"string\"},\"metadata-test-1\":{\"title\":\"metadata-test-1\",\"type\":\"string\"},\"metadata-test-2\":{\"title\":\"metadata-test-2\",\"type\":\"boolean\"}},\"unevaluatedProperties\":false,\"required\":[\"metadata-test-1\",\"metadata-test-2\"]}},\"required\":[\"title\",\"kind\"]}"}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '3154' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:36 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: AC122277A38748ADA2CA5C8BCF337707 Ref B: SN4AA2022303053 Ref C: 2023-11-29T00:37:36Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"assignedTo": "deployment"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic metadata-schema export-metadata-schema + Connection: + - keep-alive + Content-Length: + - '28' + Content-Type: + - application/json + ParameterSetName: + - -g -s --assigned-to --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/exportMetadataSchema?api-version=2024-03-01 + response: + body: + string: '{"format":"json-schema","value":"{\"type\":\"object\",\"properties\":{\"title\":{\"description\":\"The + name of the deployment.\",\"type\":\"string\",\"maxLength\":50},\"description\":{\"description\":\"The + description of the deployment.\",\"type\":\"string\",\"maxLength\":1000},\"environmentId\":{\"description\":\"The + service-scoped resource ID of the deployment environment.\",\"type\":\"string\"},\"definitionId\":{\"description\":\"The + service-scoped resource ID of the API definition.\",\"type\":\"string\"},\"server\":{\"description\":\"The + server information of the API deployment.\",\"type\":\"object\",\"properties\":{\"runtimeUri\":{\"description\":\"Base + runtime URIs for this deployment.\",\"type\":\"array\",\"items\":{\"type\":\"string\"},\"maxItems\":200}},\"required\":[\"runtimeUri\"]},\"customProperties\":{\"type\":\"object\",\"properties\":{},\"unevaluatedProperties\":false,\"required\":[]},\"recommended\":{\"description\":\"Indicates + if this is currently recommended deployment.\",\"type\":\"boolean\"}},\"required\":[\"title\",\"environmentId\",\"definitionId\",\"server\"]}"}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '1101' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:37 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 6411025974C344859EBC6E33123B5339 Ref B: SN4AA2022305023 Ref C: 2023-11-29T00:37:37Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"assignedTo": "environment"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic metadata-schema export-metadata-schema + Connection: + - keep-alive + Content-Length: + - '29' + Content-Type: + - application/json + ParameterSetName: + - -g -s --assigned-to --file-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/exportMetadataSchema?api-version=2024-03-01 + response: + body: + string: '{"format":"json-schema","value":"{\"type\":\"object\",\"properties\":{\"title\":{\"description\":\"The + name of the environment.\",\"type\":\"string\",\"maxLength\":50},\"kind\":{\"description\":\"Kind + of deployment environment.\",\"type\":\"string\"},\"description\":{\"description\":\"Description + of the environment.\",\"type\":\"string\",\"maxLength\":1000},\"server\":{\"description\":\"Server + information of the environment.\",\"type\":\"object\",\"properties\":{\"type\":{\"description\":\"Type + of the server that represents the environment.\",\"type\":\"string\"},\"managementPortalUri\":{\"description\":\"URIs + of the server''s management portal.\",\"type\":\"array\",\"items\":{\"type\":\"string\"},\"maxItems\":200}}},\"onboarding\":{\"description\":\"Onboarding + information for this environment.\",\"type\":\"object\",\"properties\":{\"instructions\":{\"description\":\"Instructions + how to onboard to the environment.\",\"type\":\"string\",\"maxLength\":1000},\"developerPortalUri\":{\"description\":\"Developer + portal URIs of the environment.\",\"type\":\"array\",\"items\":{\"type\":\"string\"},\"maxItems\":200}}},\"customProperties\":{\"type\":\"object\",\"properties\":{},\"unevaluatedProperties\":false,\"required\":[]}},\"required\":[\"title\",\"kind\"]}"}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '1272' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:38 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 6597CE2286DB4C96871CAE488D948E75 Ref B: SN4AA2022304047 Ref C: 2023-11-29T00:37:38Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic metadata-schema show + Connection: + - keep-alive + ParameterSetName: + - -g -s --name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/metadataSchemas/cli-test-metadata-schema-1?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/metadataSchema","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/metadataSchema/cli-test-metadata-schema-1","name":"cli-test-metadata-schema-1","systemData":{"createdAt":"2023-11-24T04:18:02.4538124Z","lastModifiedAt":"2023-11-29T00:37:35.7449241Z"},"properties":{"assignedTo":[],"schema":"{\"type\": + \"string\", \"title\": \"CLI Test First name\", \"pattern\": \"^[a-zA-Z0-9 + ]+$\"}"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '514' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:39 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-msedge-ref: + - 'Ref A: 63A25FB85ACC4BD7A837D0E20400D363 Ref B: DM2AA1091214031 Ref C: 2023-11-29T00:37:39Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"description": "APIs for sampling from and fine-tuning + language models", "kind": "rest", "summary": "APIs for sampling from and fine-tuning + language models", "termsOfService": {}, "title": "cli-test-openai-api-105"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + Content-Length: + - '232' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/apis","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105","name":"cli-test-openai-api-105","systemData":{"createdAt":"2023-11-29T00:37:40.6349454Z","lastModifiedAt":"2023-11-29T00:37:40.6349466Z"},"properties":{"title":"cli-test-openai-api-105","summary":"APIs + for sampling from and fine-tuning language models","description":"APIs for + sampling from and fine-tuning language models","kind":"rest","lifecycleStage":"design","termsOfService":{},"externalDocumentation":[],"contacts":[],"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '682' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:40 GMT + etag: + - 6e00a049-0000-3300-0000-656687d40000 + 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 9148C489A269482DB1EF86956161D00C Ref B: SN4AA2022304029 Ref C: 2023-11-29T00:37:40Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"lifecycleStage": "design", "title": "1-2-0"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + Content-Length: + - '62' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/versions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0","name":"1-2-0","systemData":{"createdAt":"2023-11-29T00:37:41.2557802Z","lastModifiedAt":"2023-11-29T00:37:41.2557802Z"},"properties":{"title":"1-2-0","lifecycleStage":"design"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '430' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:40 GMT + etag: + - 9a00efb9-0000-3300-0000-656687d50000 + 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: 1DC444D7954546E4847C70E73E3D2CEC Ref B: SN4AA2022303011 Ref C: 2023-11-29T00:37:40Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"description": "APIs for sampling from and fine-tuning + language models", "title": "openapi"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + Content-Length: + - '109' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/definitions","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi","name":"openapi","systemData":{"createdAt":"2023-11-24T04:37:03.5685003Z","lastModifiedAt":"2023-11-29T00:37:41.8357734Z"},"properties":{"title":"openapi","description":"APIs + for sampling from and fine-tuning language models","specification":{"name":"openapi","version":"3-0-0"}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '555' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:41 GMT + etag: + - 00000d01-0000-3300-0000-656687d50000 + 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-writes: + - '1199' + x-msedge-ref: + - 'Ref A: B6C6DCF90E8F4CF1A7581615896577CE Ref B: DM2AA1091213029 Ref C: 2023-11-29T00:37:41Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"format": "inline", "specification": {"name": "openapi", "version": "3-0-0"}, + "value": "{\"openapi\": \"3.0.0\", \"servers\": [{\"url\": \"https://api.openai.com/v1\"}], + \"info\": {\"description\": \"APIs for sampling from and fine-tuning language + models\", \"title\": \"CLI Test OpenAI API 105\", \"version\": \"1.2.0\", \"x-apisguru-categories\": + [\"machine_learning\"], \"x-logo\": {\"url\": \"https://learnodo-newtonic.com/wp-content/uploads/2020/04/Logo-of-OpenAI-768x161.jpg\"}, + \"x-origin\": [{\"format\": \"openapi\", \"url\": \"https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml\", + \"version\": \"3.0\"}], \"x-providerName\": \"openai.com\"}, \"tags\": [{\"description\": + \"The OpenAI REST API\", \"name\": \"OpenAI\"}], \"paths\": {\"/answers\": {\"post\": + {\"deprecated\": true, \"operationId\": \"createAnswer\", \"requestBody\": {\"content\": + {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateAnswerRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateAnswerResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Answers the specified question using the provided documents + and examples.\\n\\nThe endpoint first [searches](/docs/api-reference/searches) + over provided documents or files to find relevant context. The relevant context + is combined with the provided examples and question to create the prompt for + [completion](/docs/api-reference/completions).\\n\", \"tags\": [\"OpenAI\"], + \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/answers + \\\\\\n -X POST \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\" \\\\\\n -H + ''Content-Type: application/json'' \\\\\\n -d ''{\\n \\\"documents\\\": + [\\\"Puppy A is happy.\\\", \\\"Puppy B is sad.\\\"],\\n \\\"question\\\": + \\\"which puppy is happy?\\\",\\n \\\"search_model\\\": \\\"ada\\\",\\n \\\"model\\\": + \\\"curie\\\",\\n \\\"examples_context\\\": \\\"In 2017, U.S. life expectancy + was 78.6 years.\\\",\\n \\\"examples\\\": [[\\\"What is human life expectancy + in the United States?\\\",\\\"78 years.\\\"]],\\n \\\"max_tokens\\\": 5,\\n \\\"stop\\\": + [\\\"\\\\n\\\", \\\"<|endoftext|>\\\"]\\n }''\\n\", \"node.js\": \"const { + Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createAnswer({\\n search_model: + \\\"ada\\\",\\n model: \\\"curie\\\",\\n question: \\\"which puppy is happy?\\\",\\n documents: + [\\\"Puppy A is happy.\\\", \\\"Puppy B is sad.\\\"],\\n examples_context: + \\\"In 2017, U.S. life expectancy was 78.6 years.\\\",\\n examples: [[\\\"What + is human life expectancy in the United States?\\\",\\\"78 years.\\\"]],\\n max_tokens: + 5,\\n stop: [\\\"\\\\n\\\", \\\"<|endoftext|>\\\"],\\n});\\n\", \"python\": + \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Answer.create(\\n search_model=\\\"ada\\\",\\n model=\\\"curie\\\",\\n question=\\\"which + puppy is happy?\\\",\\n documents=[\\\"Puppy A is happy.\\\", \\\"Puppy B is + sad.\\\"],\\n examples_context=\\\"In 2017, U.S. life expectancy was 78.6 years.\\\",\\n examples=[[\\\"What + is human life expectancy in the United States?\\\",\\\"78 years.\\\"]],\\n max_tokens=5,\\n stop=[\\\"\\\\n\\\", + \\\"<|endoftext|>\\\"],\\n)\\n\"}, \"group\": \"answers\", \"name\": \"Create + answer\", \"parameters\": \"{\\n \\\"documents\\\": [\\\"Puppy A is happy.\\\", + \\\"Puppy B is sad.\\\"],\\n \\\"question\\\": \\\"which puppy is happy?\\\",\\n \\\"search_model\\\": + \\\"ada\\\",\\n \\\"model\\\": \\\"curie\\\",\\n \\\"examples_context\\\": + \\\"In 2017, U.S. life expectancy was 78.6 years.\\\",\\n \\\"examples\\\": + [[\\\"What is human life expectancy in the United States?\\\",\\\"78 years.\\\"]],\\n \\\"max_tokens\\\": + 5,\\n \\\"stop\\\": [\\\"\\\\n\\\", \\\"<|endoftext|>\\\"]\\n}\\n\", \"path\": + \"create\", \"response\": \"{\\n \\\"answers\\\": [\\n \\\"puppy A.\\\"\\n ],\\n \\\"completion\\\": + \\\"cmpl-2euVa1kmKUuLpSX600M41125Mo9NI\\\",\\n \\\"model\\\": \\\"curie:2020-05-03\\\",\\n \\\"object\\\": + \\\"answer\\\",\\n \\\"search_model\\\": \\\"ada\\\",\\n \\\"selected_documents\\\": + [\\n {\\n \\\"document\\\": 0,\\n \\\"text\\\": \\\"Puppy A is + happy. \\\"\\n },\\n {\\n \\\"document\\\": 1,\\n \\\"text\\\": + \\\"Puppy B is sad. \\\"\\n }\\n ]\\n}\\n\"}}}, \"/audio/transcriptions\": + {\"post\": {\"operationId\": \"createTranscription\", \"requestBody\": {\"content\": + {\"multipart/form-data\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateTranscriptionRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateTranscriptionResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Transcribes audio into the input language.\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"beta\": true, \"examples\": {\"curl\": + \"curl https://api.openai.com/v1/audio/transcriptions \\\\\\n -X POST \\\\\\n -H + ''Authorization: Bearer TOKEN'' \\\\\\n -H ''Content-Type: multipart/form-data'' + \\\\\\n -F file=@/path/to/file/audio.mp3 \\\\\\n -F model=whisper-1\\n\", + \"node\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst resp = await openai.createTranscription(\\n fs.createReadStream(\\\"audio.mp3\\\"),\\n \\\"whisper-1\\\"\\n);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\naudio_file + = open(\\\"audio.mp3\\\", \\\"rb\\\")\\ntranscript = openai.Audio.transcribe(\\\"whisper-1\\\", + audio_file)\\n\"}, \"group\": \"audio\", \"name\": \"Create transcription\", + \"parameters\": \"{\\n \\\"file\\\": \\\"audio.mp3\\\",\\n \\\"model\\\": + \\\"whisper-1\\\"\\n}\\n\", \"path\": \"create\", \"response\": \"{\\n \\\"text\\\": + \\\"Imagine the wildest idea that you''ve ever had, and you''re curious about + how it might scale to something that''s a 100, a 1,000 times bigger. This is + a place where you can get to do that.\\\"\\n}\\n\"}}}, \"/audio/translations\": + {\"post\": {\"operationId\": \"createTranslation\", \"requestBody\": {\"content\": + {\"multipart/form-data\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateTranslationRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateTranslationResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Translates audio into into English.\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"beta\": true, \"examples\": {\"curl\": + \"curl https://api.openai.com/v1/audio/translations \\\\\\n -X POST \\\\\\n -H + ''Authorization: Bearer TOKEN'' \\\\\\n -H ''Content-Type: multipart/form-data'' + \\\\\\n -F file=@/path/to/file/german.m4a \\\\\\n -F model=whisper-1\\n\", + \"node\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst resp = await openai.createTranslation(\\n fs.createReadStream(\\\"audio.mp3\\\"),\\n \\\"whisper-1\\\"\\n);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\naudio_file + = open(\\\"german.m4a\\\", \\\"rb\\\")\\ntranscript = openai.Audio.translate(\\\"whisper-1\\\", + audio_file)\\n\"}, \"group\": \"audio\", \"name\": \"Create translation\", \"parameters\": + \"{\\n \\\"file\\\": \\\"german.m4a\\\",\\n \\\"model\\\": \\\"whisper-1\\\"\\n}\\n\", + \"path\": \"create\", \"response\": \"{\\n \\\"text\\\": \\\"Hello, my name + is Wolfgang and I come from Germany. Where are you heading today?\\\"\\n}\\n\"}}}, + \"/chat/completions\": {\"post\": {\"operationId\": \"createChatCompletion\", + \"requestBody\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/CreateChatCompletionRequest\"}}}, \"required\": true}, + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/CreateChatCompletionResponse\"}}}, \"description\": \"OK\"}}, + \"summary\": \"Creates a completion for the chat message\", \"tags\": [\"OpenAI\"], + \"x-oaiMeta\": {\"beta\": true, \"examples\": {\"curl\": \"curl https://api.openai.com/v1/chat/completions + \\\\\\n -H ''Content-Type: application/json'' \\\\\\n -H ''Authorization: + Bearer YOUR_API_KEY'' \\\\\\n -d ''{\\n \\\"model\\\": \\\"gpt-3.5-turbo\\\",\\n \\\"messages\\\": + [{\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"Hello!\\\"}]\\n}''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\n\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\n\\nconst completion = await openai.createChatCompletion({\\n model: + \\\"gpt-3.5-turbo\\\",\\n messages: [{role: \\\"user\\\", content: \\\"Hello + world\\\"}],\\n});\\nconsole.log(completion.data.choices[0].message);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\n\\ncompletion + = openai.ChatCompletion.create(\\n model=\\\"gpt-3.5-turbo\\\",\\n messages=[\\n {\\\"role\\\": + \\\"user\\\", \\\"content\\\": \\\"Hello!\\\"}\\n ]\\n)\\n\\nprint(completion.choices[0].message)\\n\"}, + \"group\": \"chat\", \"name\": \"Create chat completion\", \"parameters\": \"{\\n \\\"model\\\": + \\\"gpt-3.5-turbo\\\",\\n \\\"messages\\\": [{\\\"role\\\": \\\"user\\\", \\\"content\\\": + \\\"Hello!\\\"}]\\n}\\n\", \"path\": \"create\", \"response\": \"{\\n \\\"id\\\": + \\\"chatcmpl-123\\\",\\n \\\"object\\\": \\\"chat.completion\\\",\\n \\\"created\\\": + 1677652288,\\n \\\"choices\\\": [{\\n \\\"index\\\": 0,\\n \\\"message\\\": + {\\n \\\"role\\\": \\\"assistant\\\",\\n \\\"content\\\": \\\"\\\\n\\\\nHello + there, how may I assist you today?\\\",\\n },\\n \\\"finish_reason\\\": + \\\"stop\\\"\\n }],\\n \\\"usage\\\": {\\n \\\"prompt_tokens\\\": 9,\\n \\\"completion_tokens\\\": + 12,\\n \\\"total_tokens\\\": 21\\n }\\n}\\n\"}}}, \"/classifications\": + {\"post\": {\"deprecated\": true, \"operationId\": \"createClassification\", + \"requestBody\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/CreateClassificationRequest\"}}}, \"required\": true}, + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/CreateClassificationResponse\"}}}, \"description\": \"OK\"}}, + \"summary\": \"Classifies the specified `query` using provided examples.\\n\\nThe + endpoint first [searches](/docs/api-reference/searches) over the labeled examples\\nto + select the ones most relevant for the particular query. Then, the relevant examples\\nare + combined with the query to construct a prompt to produce the final label via + the\\n[completions](/docs/api-reference/completions) endpoint.\\n\\nLabeled + examples can be provided via an uploaded `file`, or explicitly listed in the\\nrequest + using the `examples` parameter for quick tests and small scale use cases.\\n\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/classifications + \\\\\\n -X POST \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\" \\\\\\n -H + ''Content-Type: application/json'' \\\\\\n -d ''{\\n \\\"examples\\\": [\\n [\\\"A + happy moment\\\", \\\"Positive\\\"],\\n [\\\"I am sad.\\\", \\\"Negative\\\"],\\n [\\\"I + am feeling awesome\\\", \\\"Positive\\\"]],\\n \\\"query\\\": \\\"It is a + raining day :(\\\",\\n \\\"search_model\\\": \\\"ada\\\",\\n \\\"model\\\": + \\\"curie\\\",\\n \\\"labels\\\":[\\\"Positive\\\", \\\"Negative\\\", \\\"Neutral\\\"]\\n }''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createClassification({\\n search_model: + \\\"ada\\\",\\n model: \\\"curie\\\",\\n examples: [\\n [\\\"A happy moment\\\", + \\\"Positive\\\"],\\n [\\\"I am sad.\\\", \\\"Negative\\\"],\\n [\\\"I + am feeling awesome\\\", \\\"Positive\\\"]\\n ],\\n query:\\\"It is a raining + day :(\\\",\\n labels: [\\\"Positive\\\", \\\"Negative\\\", \\\"Neutral\\\"],\\n});\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Classification.create(\\n search_model=\\\"ada\\\",\\n model=\\\"curie\\\",\\n examples=[\\n [\\\"A + happy moment\\\", \\\"Positive\\\"],\\n [\\\"I am sad.\\\", \\\"Negative\\\"],\\n [\\\"I + am feeling awesome\\\", \\\"Positive\\\"]\\n ],\\n query=\\\"It is a raining + day :(\\\",\\n labels=[\\\"Positive\\\", \\\"Negative\\\", \\\"Neutral\\\"],\\n)\\n\"}, + \"group\": \"classifications\", \"name\": \"Create classification\", \"parameters\": + \"{\\n \\\"examples\\\": [\\n [\\\"A happy moment\\\", \\\"Positive\\\"],\\n [\\\"I + am sad.\\\", \\\"Negative\\\"],\\n [\\\"I am feeling awesome\\\", \\\"Positive\\\"]\\n ],\\n \\\"labels\\\": + [\\\"Positive\\\", \\\"Negative\\\", \\\"Neutral\\\"],\\n \\\"query\\\": \\\"It + is a raining day :(\\\",\\n \\\"search_model\\\": \\\"ada\\\",\\n \\\"model\\\": + \\\"curie\\\"\\n}\\n\", \"path\": \"create\", \"response\": \"{\\n \\\"completion\\\": + \\\"cmpl-2euN7lUVZ0d4RKbQqRV79IiiE6M1f\\\",\\n \\\"label\\\": \\\"Negative\\\",\\n \\\"model\\\": + \\\"curie:2020-05-03\\\",\\n \\\"object\\\": \\\"classification\\\",\\n \\\"search_model\\\": + \\\"ada\\\",\\n \\\"selected_examples\\\": [\\n {\\n \\\"document\\\": + 1,\\n \\\"label\\\": \\\"Negative\\\",\\n \\\"text\\\": \\\"I am sad.\\\"\\n },\\n {\\n \\\"document\\\": + 0,\\n \\\"label\\\": \\\"Positive\\\",\\n \\\"text\\\": \\\"A happy + moment\\\"\\n },\\n {\\n \\\"document\\\": 2,\\n \\\"label\\\": + \\\"Positive\\\",\\n \\\"text\\\": \\\"I am feeling awesome\\\"\\n }\\n ]\\n}\\n\"}}}, + \"/completions\": {\"post\": {\"operationId\": \"createCompletion\", \"requestBody\": + {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateCompletionResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Creates a completion for the provided + prompt and parameters\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": + {\"curl\": \"curl https://api.openai.com/v1/completions \\\\\\n -H ''Content-Type: + application/json'' \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY'' \\\\\\n -d + ''{\\n \\\"model\\\": \\\"VAR_model_id\\\",\\n \\\"prompt\\\": \\\"Say this + is a test\\\",\\n \\\"max_tokens\\\": 7,\\n \\\"temperature\\\": 0\\n}''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createCompletion({\\n model: + \\\"VAR_model_id\\\",\\n prompt: \\\"Say this is a test\\\",\\n max_tokens: + 7,\\n temperature: 0,\\n});\\n\", \"python\": \"import os\\nimport openai\\nopenai.api_key + = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Completion.create(\\n model=\\\"VAR_model_id\\\",\\n prompt=\\\"Say + this is a test\\\",\\n max_tokens=7,\\n temperature=0\\n)\\n\"}, \"group\": + \"completions\", \"name\": \"Create completion\", \"parameters\": \"{\\n \\\"model\\\": + \\\"VAR_model_id\\\",\\n \\\"prompt\\\": \\\"Say this is a test\\\",\\n \\\"max_tokens\\\": + 7,\\n \\\"temperature\\\": 0,\\n \\\"top_p\\\": 1,\\n \\\"n\\\": 1,\\n \\\"stream\\\": + false,\\n \\\"logprobs\\\": null,\\n \\\"stop\\\": \\\"\\\\n\\\"\\n}\\n\", + \"path\": \"create\", \"response\": \"{\\n \\\"id\\\": \\\"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\\\",\\n \\\"object\\\": + \\\"text_completion\\\",\\n \\\"created\\\": 1589478378,\\n \\\"model\\\": + \\\"VAR_model_id\\\",\\n \\\"choices\\\": [\\n {\\n \\\"text\\\": \\\"\\\\n\\\\nThis + is indeed a test\\\",\\n \\\"index\\\": 0,\\n \\\"logprobs\\\": null,\\n \\\"finish_reason\\\": + \\\"length\\\"\\n }\\n ],\\n \\\"usage\\\": {\\n \\\"prompt_tokens\\\": + 5,\\n \\\"completion_tokens\\\": 7,\\n \\\"total_tokens\\\": 12\\n }\\n}\\n\"}}}, + \"/edits\": {\"post\": {\"operationId\": \"createEdit\", \"requestBody\": {\"content\": + {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateEditRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateEditResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Creates a new edit for the provided input, instruction, + and parameters.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": + \"curl https://api.openai.com/v1/edits \\\\\\n -H ''Content-Type: application/json'' + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY'' \\\\\\n -d ''{\\n \\\"model\\\": + \\\"VAR_model_id\\\",\\n \\\"input\\\": \\\"What day of the wek is it?\\\",\\n \\\"instruction\\\": + \\\"Fix the spelling mistakes\\\"\\n}''\\n\", \"node.js\": \"const { Configuration, + OpenAIApi } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.createEdit({\\n model: \\\"VAR_model_id\\\",\\n input: + \\\"What day of the wek is it?\\\",\\n instruction: \\\"Fix the spelling mistakes\\\",\\n});\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Edit.create(\\n model=\\\"VAR_model_id\\\",\\n input=\\\"What + day of the wek is it?\\\",\\n instruction=\\\"Fix the spelling mistakes\\\"\\n)\\n\"}, + \"group\": \"edits\", \"name\": \"Create edit\", \"parameters\": \"{\\n \\\"model\\\": + \\\"VAR_model_id\\\",\\n \\\"input\\\": \\\"What day of the wek is it?\\\",\\n \\\"instruction\\\": + \\\"Fix the spelling mistakes\\\",\\n}\\n\", \"path\": \"create\", \"response\": + \"{\\n \\\"object\\\": \\\"edit\\\",\\n \\\"created\\\": 1589478378,\\n \\\"choices\\\": + [\\n {\\n \\\"text\\\": \\\"What day of the week is it?\\\",\\n \\\"index\\\": + 0,\\n }\\n ],\\n \\\"usage\\\": {\\n \\\"prompt_tokens\\\": 25,\\n \\\"completion_tokens\\\": + 32,\\n \\\"total_tokens\\\": 57\\n }\\n}\\n\"}}}, \"/embeddings\": {\"post\": + {\"operationId\": \"createEmbedding\", \"requestBody\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateEmbeddingRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateEmbeddingResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Creates an embedding vector representing + the input text.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": + \"curl https://api.openai.com/v1/embeddings \\\\\\n -X POST \\\\\\n -H \\\"Authorization: + Bearer YOUR_API_KEY\\\" \\\\\\n -H \\\"Content-Type: application/json\\\" \\\\\\n -d + ''{\\\"input\\\": \\\"The food was delicious and the waiter...\\\",\\n \\\"model\\\": + \\\"text-embedding-ada-002\\\"}''\\n\", \"node.js\": \"const { Configuration, + OpenAIApi } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.createEmbedding({\\n model: \\\"text-embedding-ada-002\\\",\\n input: + \\\"The food was delicious and the waiter...\\\",\\n});\\n\", \"python\": \"import + os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Embedding.create(\\n model=\\\"text-embedding-ada-002\\\",\\n input=\\\"The + food was delicious and the waiter...\\\"\\n)\\n\"}, \"group\": \"embeddings\", + \"name\": \"Create embeddings\", \"parameters\": \"{\\n \\\"model\\\": \\\"text-embedding-ada-002\\\",\\n \\\"input\\\": + \\\"The food was delicious and the waiter...\\\"\\n}\\n\", \"path\": \"create\", + \"response\": \"{\\n \\\"object\\\": \\\"list\\\",\\n \\\"data\\\": [\\n {\\n \\\"object\\\": + \\\"embedding\\\",\\n \\\"embedding\\\": [\\n 0.0023064255,\\n -0.009327292,\\n .... + (1536 floats total for ada-002)\\n -0.0028842222,\\n ],\\n \\\"index\\\": + 0\\n }\\n ],\\n \\\"model\\\": \\\"text-embedding-ada-002\\\",\\n \\\"usage\\\": + {\\n \\\"prompt_tokens\\\": 8,\\n \\\"total_tokens\\\": 8\\n }\\n}\\n\"}}}, + \"/engines\": {\"get\": {\"deprecated\": true, \"operationId\": \"listEngines\", + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/ListEnginesResponse\"}}}, \"description\": \"OK\"}}, + \"summary\": \"Lists the currently available (non-finetuned) models, and provides + basic information about each one such as the owner and availability.\", \"tags\": + [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/engines + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.listEngines();\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Engine.list()\\n\"}, + \"group\": \"engines\", \"name\": \"List engines\", \"path\": \"list\", \"response\": + \"{\\n \\\"data\\\": [\\n {\\n \\\"id\\\": \\\"engine-id-0\\\",\\n \\\"object\\\": + \\\"engine\\\",\\n \\\"owner\\\": \\\"organization-owner\\\",\\n \\\"ready\\\": + true\\n },\\n {\\n \\\"id\\\": \\\"engine-id-2\\\",\\n \\\"object\\\": + \\\"engine\\\",\\n \\\"owner\\\": \\\"organization-owner\\\",\\n \\\"ready\\\": + true\\n },\\n {\\n \\\"id\\\": \\\"engine-id-3\\\",\\n \\\"object\\\": + \\\"engine\\\",\\n \\\"owner\\\": \\\"openai\\\",\\n \\\"ready\\\": + false\\n },\\n ],\\n \\\"object\\\": \\\"list\\\"\\n}\\n\"}}}, \"/engines/{engine_id}\": + {\"get\": {\"deprecated\": true, \"operationId\": \"retrieveEngine\", \"parameters\": + [{\"description\": \"The ID of the engine to use for this request\\n\", \"in\": + \"path\", \"name\": \"engine_id\", \"required\": true, \"schema\": {\"example\": + \"davinci\", \"type\": \"string\"}}], \"responses\": {\"200\": {\"content\": + {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/Engine\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Retrieves a model instance, providing + basic information about it such as the owner and availability.\", \"tags\": + [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/engines/VAR_model_id + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.retrieveEngine(\\\"VAR_model_id\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Engine.retrieve(\\\"VAR_model_id\\\")\\n\"}, + \"group\": \"engines\", \"name\": \"Retrieve engine\", \"path\": \"retrieve\", + \"response\": \"{\\n \\\"id\\\": \\\"VAR_model_id\\\",\\n \\\"object\\\": + \\\"engine\\\",\\n \\\"owner\\\": \\\"openai\\\",\\n \\\"ready\\\": true\\n}\\n\"}}}, + \"/engines/{engine_id}/search\": {\"post\": {\"deprecated\": true, \"operationId\": + \"createSearch\", \"parameters\": [{\"description\": \"The ID of the engine + to use for this request. You can select one of `ada`, `babbage`, `curie`, or + `davinci`.\", \"in\": \"path\", \"name\": \"engine_id\", \"required\": true, + \"schema\": {\"example\": \"davinci\", \"type\": \"string\"}}], \"requestBody\": + {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateSearchRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateSearchResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"The search endpoint computes similarity scores between + provided query and documents. Documents can be passed directly to the API if + there are no more than 200 of them.\\n\\nTo go beyond the 200 document limit, + documents can be processed offline and then used for efficient retrieval at + query time. When `file` is set, the search endpoint searches over all the documents + in the given file and returns up to the `max_rerank` number of documents. These + documents will be returned along with their search scores.\\n\\nThe similarity + score is a positive score that usually ranges from 0 to 300 (but can sometimes + go higher), where a score above 200 usually means the document is semantically + similar to the query.\\n\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": + {\"curl\": \"curl https://api.openai.com/v1/engines/davinci/search \\\\\\n -H + \\\"Content-Type: application/json\\\" \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY'' + \\\\\\n -d ''{\\n \\\"documents\\\": [\\\"White House\\\", \\\"hospital\\\", + \\\"school\\\"],\\n \\\"query\\\": \\\"the president\\\"\\n}''\\n\", \"node.js\": + \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createSearch(\\\"davinci\\\", + {\\n documents: [\\\"White House\\\", \\\"hospital\\\", \\\"school\\\"],\\n query: + \\\"the president\\\",\\n});\\n\", \"python\": \"import os\\nimport openai\\nopenai.api_key + = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Engine(\\\"davinci\\\").search(\\n documents=[\\\"White + House\\\", \\\"hospital\\\", \\\"school\\\"],\\n query=\\\"the president\\\"\\n)\\n\"}, + \"group\": \"searches\", \"name\": \"Create search\", \"parameters\": \"{\\n \\\"documents\\\": + [\\n \\\"White House\\\",\\n \\\"hospital\\\",\\n \\\"school\\\"\\n ],\\n \\\"query\\\": + \\\"the president\\\"\\n}\\n\", \"path\": \"create\", \"response\": \"{\\n \\\"data\\\": + [\\n {\\n \\\"document\\\": 0,\\n \\\"object\\\": \\\"search_result\\\",\\n \\\"score\\\": + 215.412\\n },\\n {\\n \\\"document\\\": 1,\\n \\\"object\\\": + \\\"search_result\\\",\\n \\\"score\\\": 40.316\\n },\\n {\\n \\\"document\\\": + 2,\\n \\\"object\\\": \\\"search_result\\\",\\n \\\"score\\\": 55.226\\n }\\n ],\\n \\\"object\\\": + \\\"list\\\"\\n}\\n\"}}}, \"/files\": {\"get\": {\"operationId\": \"listFiles\", + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/ListFilesResponse\"}}}, \"description\": \"OK\"}}, \"summary\": + \"Returns a list of files that belong to the user''s organization.\", \"tags\": + [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/files + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.listFiles();\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.File.list()\\n\"}, + \"group\": \"files\", \"name\": \"List files\", \"path\": \"list\", \"response\": + \"{\\n \\\"data\\\": [\\n {\\n \\\"id\\\": \\\"file-ccdDZrC3iZVNiQVeEA6Z66wf\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 175,\\n \\\"created_at\\\": 1613677385,\\n \\\"filename\\\": + \\\"train.jsonl\\\",\\n \\\"purpose\\\": \\\"search\\\"\\n },\\n {\\n \\\"id\\\": + \\\"file-XjGxS3KTG0uNmNOK362iJua3\\\",\\n \\\"object\\\": \\\"file\\\",\\n \\\"bytes\\\": + 140,\\n \\\"created_at\\\": 1613779121,\\n \\\"filename\\\": \\\"puppy.jsonl\\\",\\n \\\"purpose\\\": + \\\"search\\\"\\n }\\n ],\\n \\\"object\\\": \\\"list\\\"\\n}\\n\"}}, \"post\": + {\"operationId\": \"createFile\", \"requestBody\": {\"content\": {\"multipart/form-data\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateFileRequest\"}}}, \"required\": + true}, \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": + {\"$ref\": \"#/components/schemas/OpenAIFile\"}}}, \"description\": \"OK\"}}, + \"summary\": \"Upload a file that contains document(s) to be used across various + endpoints/features. Currently, the size of all the files uploaded by one organization + can be up to 1 GB. Please contact us if you need to increase the storage limit.\\n\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/files + \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\" \\\\\\n -F purpose=\\\"fine-tune\\\" + \\\\\\n -F file=''@mydata.jsonl''\\n\", \"node.js\": \"const fs = require(\\\"fs\\\");\\nconst + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createFile(\\n fs.createReadStream(\\\"mydata.jsonl\\\"),\\n \\\"fine-tune\\\"\\n);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.File.create(\\n file=open(\\\"mydata.jsonl\\\", + \\\"rb\\\"),\\n purpose=''fine-tune''\\n)\\n\"}, \"group\": \"files\", \"name\": + \"Upload file\", \"path\": \"upload\", \"response\": \"{\\n \\\"id\\\": \\\"file-XjGxS3KTG0uNmNOK362iJua3\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 140,\\n \\\"created_at\\\": 1613779121,\\n \\\"filename\\\": + \\\"mydata.jsonl\\\",\\n \\\"purpose\\\": \\\"fine-tune\\\"\\n}\\n\"}}}, \"/files/{file_id}\": + {\"delete\": {\"operationId\": \"deleteFile\", \"parameters\": [{\"description\": + \"The ID of the file to use for this request\", \"in\": \"path\", \"name\": + \"file_id\", \"required\": true, \"schema\": {\"type\": \"string\"}}], \"responses\": + {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/DeleteFileResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Delete a file.\", \"tags\": [\"OpenAI\"], + \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 + \\\\\\n -X DELETE \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.deleteFile(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.File.delete(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\")\\n\"}, + \"group\": \"files\", \"name\": \"Delete file\", \"path\": \"delete\", \"response\": + \"{\\n \\\"id\\\": \\\"file-XjGxS3KTG0uNmNOK362iJua3\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"deleted\\\": true\\n}\\n\"}}, \"get\": {\"operationId\": + \"retrieveFile\", \"parameters\": [{\"description\": \"The ID of the file to + use for this request\", \"in\": \"path\", \"name\": \"file_id\", \"required\": + true, \"schema\": {\"type\": \"string\"}}], \"responses\": {\"200\": {\"content\": + {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/OpenAIFile\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Returns information about a specific + file.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl + https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \\\\\\n -H ''Authorization: + Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const { Configuration, OpenAIApi + } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.retrieveFile(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.File.retrieve(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\")\\n\"}, + \"group\": \"files\", \"name\": \"Retrieve file\", \"path\": \"retrieve\", \"response\": + \"{\\n \\\"id\\\": \\\"file-XjGxS3KTG0uNmNOK362iJua3\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 140,\\n \\\"created_at\\\": 1613779657,\\n \\\"filename\\\": + \\\"mydata.jsonl\\\",\\n \\\"purpose\\\": \\\"fine-tune\\\"\\n}\\n\"}}}, \"/files/{file_id}/content\": + {\"get\": {\"operationId\": \"downloadFile\", \"parameters\": [{\"description\": + \"The ID of the file to use for this request\", \"in\": \"path\", \"name\": + \"file_id\", \"required\": true, \"schema\": {\"type\": \"string\"}}], \"responses\": + {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"type\": \"string\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Returns the contents of the specified + file\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl + https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3/content \\\\\\n -H + ''Authorization: Bearer YOUR_API_KEY'' > file.jsonl\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.downloadFile(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\ncontent + = openai.File.download(\\\"file-XjGxS3KTG0uNmNOK362iJua3\\\")\\n\"}, \"group\": + \"files\", \"name\": \"Retrieve file content\", \"path\": \"retrieve-content\"}}}, + \"/fine-tunes\": {\"get\": {\"operationId\": \"listFineTunes\", \"responses\": + {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/ListFineTunesResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"List your organization''s fine-tuning + jobs\\n\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": + \"curl https://api.openai.com/v1/fine-tunes \\\\\\n -H ''Authorization: Bearer + YOUR_API_KEY''\\n\", \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.listFineTunes();\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.FineTune.list()\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"List fine-tunes\", \"path\": \"list\", + \"response\": \"{\\n \\\"object\\\": \\\"list\\\",\\n \\\"data\\\": [\\n {\\n \\\"id\\\": + \\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\",\\n \\\"object\\\": \\\"fine-tune\\\",\\n \\\"model\\\": + \\\"curie\\\",\\n \\\"created_at\\\": 1614807352,\\n \\\"fine_tuned_model\\\": + null,\\n \\\"hyperparams\\\": { ... },\\n \\\"organization_id\\\": + \\\"org-...\\\",\\n \\\"result_files\\\": [],\\n \\\"status\\\": \\\"pending\\\",\\n \\\"validation_files\\\": + [],\\n \\\"training_files\\\": [ { ... } ],\\n \\\"updated_at\\\": + 1614807352,\\n },\\n { ... },\\n { ... }\\n ]\\n}\\n\"}}, \"post\": + {\"operationId\": \"createFineTune\", \"requestBody\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateFineTuneRequest\"}}}, \"required\": + true}, \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": + {\"$ref\": \"#/components/schemas/FineTune\"}}}, \"description\": \"OK\"}}, + \"summary\": \"Creates a job that fine-tunes a specified model from a given + dataset.\\n\\nResponse includes details of the enqueued job including job status + and the name of the fine-tuned models once complete.\\n\\n[Learn more about + Fine-tuning](/docs/guides/fine-tuning)\\n\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": + {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/fine-tunes \\\\\\n -X + POST \\\\\\n -H \\\"Content-Type: application/json\\\" \\\\\\n -H \\\"Authorization: + Bearer YOUR_API_KEY\\\" \\\\\\n -d ''{\\n \\\"training_file\\\": \\\"file-XGinujblHPwGLSztz8cPS8XY\\\"\\n}''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createFineTune({\\n training_file: + \\\"file-XGinujblHPwGLSztz8cPS8XY\\\",\\n});\\n\", \"python\": \"import os\\nimport + openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.FineTune.create(training_file=\\\"file-XGinujblHPwGLSztz8cPS8XY\\\")\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"Create fine-tune\", \"path\": \"create\", + \"response\": \"{\\n \\\"id\\\": \\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\",\\n \\\"object\\\": + \\\"fine-tune\\\",\\n \\\"model\\\": \\\"curie\\\",\\n \\\"created_at\\\": + 1614807352,\\n \\\"events\\\": [\\n {\\n \\\"object\\\": \\\"fine-tune-event\\\",\\n \\\"created_at\\\": + 1614807352,\\n \\\"level\\\": \\\"info\\\",\\n \\\"message\\\": \\\"Job + enqueued. Waiting for jobs ahead to complete. Queue number: 0.\\\"\\n }\\n ],\\n \\\"fine_tuned_model\\\": + null,\\n \\\"hyperparams\\\": {\\n \\\"batch_size\\\": 4,\\n \\\"learning_rate_multiplier\\\": + 0.1,\\n \\\"n_epochs\\\": 4,\\n \\\"prompt_loss_weight\\\": 0.1,\\n },\\n \\\"organization_id\\\": + \\\"org-...\\\",\\n \\\"result_files\\\": [],\\n \\\"status\\\": \\\"pending\\\",\\n \\\"validation_files\\\": + [],\\n \\\"training_files\\\": [\\n {\\n \\\"id\\\": \\\"file-XGinujblHPwGLSztz8cPS8XY\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 1547276,\\n \\\"created_at\\\": 1610062281,\\n \\\"filename\\\": + \\\"my-data-train.jsonl\\\",\\n \\\"purpose\\\": \\\"fine-tune-train\\\"\\n }\\n ],\\n \\\"updated_at\\\": + 1614807352,\\n}\\n\"}}}, \"/fine-tunes/{fine_tune_id}\": {\"get\": {\"operationId\": + \"retrieveFineTune\", \"parameters\": [{\"description\": \"The ID of the fine-tune + job\\n\", \"in\": \"path\", \"name\": \"fine_tune_id\", \"required\": true, + \"schema\": {\"example\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\", \"type\": \"string\"}}], + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/FineTune\"}}}, \"description\": \"OK\"}}, \"summary\": + \"Gets info about the fine-tune job.\\n\\n[Learn more about Fine-tuning](/docs/guides/fine-tuning)\\n\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F + \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\"\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.retrieveFineTune(\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.FineTune.retrieve(id=\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\")\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"Retrieve fine-tune\", \"path\": \"retrieve\", + \"response\": \"{\\n \\\"id\\\": \\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\",\\n \\\"object\\\": + \\\"fine-tune\\\",\\n \\\"model\\\": \\\"curie\\\",\\n \\\"created_at\\\": + 1614807352,\\n \\\"events\\\": [\\n {\\n \\\"object\\\": \\\"fine-tune-event\\\",\\n \\\"created_at\\\": + 1614807352,\\n \\\"level\\\": \\\"info\\\",\\n \\\"message\\\": \\\"Job + enqueued. Waiting for jobs ahead to complete. Queue number: 0.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807356,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Job started.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807861,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807864,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807864,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Job succeeded.\\\"\\n }\\n ],\\n \\\"fine_tuned_model\\\": + \\\"curie:ft-acmeco-2021-03-03-21-44-20\\\",\\n \\\"hyperparams\\\": {\\n \\\"batch_size\\\": + 4,\\n \\\"learning_rate_multiplier\\\": 0.1,\\n \\\"n_epochs\\\": 4,\\n \\\"prompt_loss_weight\\\": + 0.1,\\n },\\n \\\"organization_id\\\": \\\"org-...\\\",\\n \\\"result_files\\\": + [\\n {\\n \\\"id\\\": \\\"file-QQm6ZpqdNwAaVC3aSz5sWwLT\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 81509,\\n \\\"created_at\\\": 1614807863,\\n \\\"filename\\\": + \\\"compiled_results.csv\\\",\\n \\\"purpose\\\": \\\"fine-tune-results\\\"\\n }\\n ],\\n \\\"status\\\": + \\\"succeeded\\\",\\n \\\"validation_files\\\": [],\\n \\\"training_files\\\": + [\\n {\\n \\\"id\\\": \\\"file-XGinujblHPwGLSztz8cPS8XY\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 1547276,\\n \\\"created_at\\\": 1610062281,\\n \\\"filename\\\": + \\\"my-data-train.jsonl\\\",\\n \\\"purpose\\\": \\\"fine-tune-train\\\"\\n }\\n ],\\n \\\"updated_at\\\": + 1614807865,\\n}\\n\"}}}, \"/fine-tunes/{fine_tune_id}/cancel\": {\"post\": {\"operationId\": + \"cancelFineTune\", \"parameters\": [{\"description\": \"The ID of the fine-tune + job to cancel\\n\", \"in\": \"path\", \"name\": \"fine_tune_id\", \"required\": + true, \"schema\": {\"example\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\", \"type\": \"string\"}}], + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/FineTune\"}}}, \"description\": \"OK\"}}, \"summary\": + \"Immediately cancel a fine-tune job.\\n\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": + {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel + \\\\\\n -X POST \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\"\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.cancelFineTune(\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.FineTune.cancel(id=\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\")\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"Cancel fine-tune\", \"path\": \"cancel\", + \"response\": \"{\\n \\\"id\\\": \\\"ft-xhrpBbvVUzYGo8oUO1FY4nI7\\\",\\n \\\"object\\\": + \\\"fine-tune\\\",\\n \\\"model\\\": \\\"curie\\\",\\n \\\"created_at\\\": + 1614807770,\\n \\\"events\\\": [ { ... } ],\\n \\\"fine_tuned_model\\\": null,\\n \\\"hyperparams\\\": + { ... },\\n \\\"organization_id\\\": \\\"org-...\\\",\\n \\\"result_files\\\": + [],\\n \\\"status\\\": \\\"cancelled\\\",\\n \\\"validation_files\\\": [],\\n \\\"training_files\\\": + [\\n {\\n \\\"id\\\": \\\"file-XGinujblHPwGLSztz8cPS8XY\\\",\\n \\\"object\\\": + \\\"file\\\",\\n \\\"bytes\\\": 1547276,\\n \\\"created_at\\\": 1610062281,\\n \\\"filename\\\": + \\\"my-data-train.jsonl\\\",\\n \\\"purpose\\\": \\\"fine-tune-train\\\"\\n }\\n ],\\n \\\"updated_at\\\": + 1614807789,\\n}\\n\"}}}, \"/fine-tunes/{fine_tune_id}/events\": {\"get\": {\"operationId\": + \"listFineTuneEvents\", \"parameters\": [{\"description\": \"The ID of the fine-tune + job to get events for.\\n\", \"in\": \"path\", \"name\": \"fine_tune_id\", \"required\": + true, \"schema\": {\"example\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\", \"type\": \"string\"}}, + {\"description\": \"Whether to stream events for the fine-tune job. If set to + true,\\nevents will be sent as data-only\\n[server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)\\nas + they become available. The stream will terminate with a\\n`data: [DONE]` message + when the job is finished (succeeded, cancelled,\\nor failed).\\n\\nIf set to + false, only events generated so far will be returned.\\n\", \"in\": \"query\", + \"name\": \"stream\", \"required\": false, \"schema\": {\"default\": false, + \"type\": \"boolean\"}}], \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/ListFineTuneEventsResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Get fine-grained status updates for + a fine-tune job.\\n\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": + {\"curl\": \"curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events + \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\"\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.listFineTuneEvents(\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\");\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.FineTune.list_events(id=\\\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\\\")\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"List fine-tune events\", \"path\": \"events\", + \"response\": \"{\\n \\\"object\\\": \\\"list\\\",\\n \\\"data\\\": [\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807352,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Job enqueued. Waiting for jobs ahead + to complete. Queue number: 0.\\\"\\n },\\n {\\n \\\"object\\\": \\\"fine-tune-event\\\",\\n \\\"created_at\\\": + 1614807356,\\n \\\"level\\\": \\\"info\\\",\\n \\\"message\\\": \\\"Job + started.\\\"\\n },\\n {\\n \\\"object\\\": \\\"fine-tune-event\\\",\\n \\\"created_at\\\": + 1614807861,\\n \\\"level\\\": \\\"info\\\",\\n \\\"message\\\": \\\"Uploaded + snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807864,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT.\\\"\\n },\\n {\\n \\\"object\\\": + \\\"fine-tune-event\\\",\\n \\\"created_at\\\": 1614807864,\\n \\\"level\\\": + \\\"info\\\",\\n \\\"message\\\": \\\"Job succeeded.\\\"\\n }\\n ]\\n}\\n\"}}}, + \"/images/edits\": {\"post\": {\"operationId\": \"createImageEdit\", \"requestBody\": + {\"content\": {\"multipart/form-data\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateImageEditRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/ImagesResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Creates an edited or extended image given an original + image and a prompt.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"beta\": true, + \"examples\": {\"curl\": \"curl https://api.openai.com/v1/images/edits \\\\\\n -H + ''Authorization: Bearer YOUR_API_KEY'' \\\\\\n -F image=''@otter.png'' \\\\\\n -F + mask=''@mask.png'' \\\\\\n -F prompt=\\\"A cute baby sea otter wearing a beret\\\" + \\\\\\n -F n=2 \\\\\\n -F size=\\\"1024x1024\\\"\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createImageEdit(\\n fs.createReadStream(\\\"otter.png\\\"),\\n fs.createReadStream(\\\"mask.png\\\"),\\n \\\"A + cute baby sea otter wearing a beret\\\",\\n 2,\\n \\\"1024x1024\\\"\\n);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Image.create_edit(\\n image=open(\\\"otter.png\\\", + \\\"rb\\\"),\\n mask=open(\\\"mask.png\\\", \\\"rb\\\"),\\n prompt=\\\"A cute + baby sea otter wearing a beret\\\",\\n n=2,\\n size=\\\"1024x1024\\\"\\n)\\n\"}, + \"group\": \"images\", \"name\": \"Create image edit\", \"path\": \"create-edit\", + \"response\": \"{\\n \\\"created\\\": 1589478378,\\n \\\"data\\\": [\\n {\\n \\\"url\\\": + \\\"https://...\\\"\\n },\\n {\\n \\\"url\\\": \\\"https://...\\\"\\n }\\n ]\\n}\\n\"}}}, + \"/images/generations\": {\"post\": {\"operationId\": \"createImage\", \"requestBody\": + {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateImageRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/ImagesResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Creates an image given a prompt.\", \"tags\": [\"OpenAI\"], + \"x-oaiMeta\": {\"beta\": true, \"examples\": {\"curl\": \"curl https://api.openai.com/v1/images/generations + \\\\\\n -H ''Content-Type: application/json'' \\\\\\n -H ''Authorization: + Bearer YOUR_API_KEY'' \\\\\\n -d ''{\\n \\\"prompt\\\": \\\"A cute baby sea + otter\\\",\\n \\\"n\\\": 2,\\n \\\"size\\\": \\\"1024x1024\\\"\\n}''\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.createImage({\\n prompt: + \\\"A cute baby sea otter\\\",\\n n: 2,\\n size: \\\"1024x1024\\\",\\n});\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Image.create(\\n prompt=\\\"A + cute baby sea otter\\\",\\n n=2,\\n size=\\\"1024x1024\\\"\\n)\\n\"}, \"group\": + \"images\", \"name\": \"Create image\", \"parameters\": \"{\\n \\\"prompt\\\": + \\\"A cute baby sea otter\\\",\\n \\\"n\\\": 2,\\n \\\"size\\\": \\\"1024x1024\\\"\\n}\\n\", + \"path\": \"create\", \"response\": \"{\\n \\\"created\\\": 1589478378,\\n \\\"data\\\": + [\\n {\\n \\\"url\\\": \\\"https://...\\\"\\n },\\n {\\n \\\"url\\\": + \\\"https://...\\\"\\n }\\n ]\\n}\\n\"}}}, \"/images/variations\": {\"post\": + {\"operationId\": \"createImageVariation\", \"requestBody\": {\"content\": {\"multipart/form-data\": + {\"schema\": {\"$ref\": \"#/components/schemas/CreateImageVariationRequest\"}}}, + \"required\": true}, \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/ImagesResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Creates a variation of a given image.\", \"tags\": + [\"OpenAI\"], \"x-oaiMeta\": {\"beta\": true, \"examples\": {\"curl\": \"curl + https://api.openai.com/v1/images/variations \\\\\\n -H ''Authorization: Bearer + YOUR_API_KEY'' \\\\\\n -F image=''@otter.png'' \\\\\\n -F n=2 \\\\\\n -F + size=\\\"1024x1024\\\"\\n\", \"node.js\": \"const { Configuration, OpenAIApi + } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.createImageVariation(\\n fs.createReadStream(\\\"otter.png\\\"),\\n 2,\\n \\\"1024x1024\\\"\\n);\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Image.create_variation(\\n image=open(\\\"otter.png\\\", + \\\"rb\\\"),\\n n=2,\\n size=\\\"1024x1024\\\"\\n)\\n\"}, \"group\": \"images\", + \"name\": \"Create image variation\", \"path\": \"create-variation\", \"response\": + \"{\\n \\\"created\\\": 1589478378,\\n \\\"data\\\": [\\n {\\n \\\"url\\\": + \\\"https://...\\\"\\n },\\n {\\n \\\"url\\\": \\\"https://...\\\"\\n }\\n ]\\n}\\n\"}}}, + \"/models\": {\"get\": {\"operationId\": \"listModels\", \"responses\": {\"200\": + {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/ListModelsResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Lists the currently available models, + and provides basic information about each one such as the owner and availability.\", + \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": \"curl https://api.openai.com/v1/models + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const + { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst configuration + = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.listModels();\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Model.list()\\n\"}, + \"group\": \"models\", \"name\": \"List models\", \"path\": \"list\", \"response\": + \"{\\n \\\"data\\\": [\\n {\\n \\\"id\\\": \\\"model-id-0\\\",\\n \\\"object\\\": + \\\"model\\\",\\n \\\"owned_by\\\": \\\"organization-owner\\\",\\n \\\"permission\\\": + [...]\\n },\\n {\\n \\\"id\\\": \\\"model-id-1\\\",\\n \\\"object\\\": + \\\"model\\\",\\n \\\"owned_by\\\": \\\"organization-owner\\\",\\n \\\"permission\\\": + [...]\\n },\\n {\\n \\\"id\\\": \\\"model-id-2\\\",\\n \\\"object\\\": + \\\"model\\\",\\n \\\"owned_by\\\": \\\"openai\\\",\\n \\\"permission\\\": + [...]\\n },\\n ],\\n \\\"object\\\": \\\"list\\\"\\n}\\n\"}}}, \"/models/{model}\": + {\"delete\": {\"operationId\": \"deleteModel\", \"parameters\": [{\"description\": + \"The model to delete\", \"in\": \"path\", \"name\": \"model\", \"required\": + true, \"schema\": {\"example\": \"curie:ft-acmeco-2021-03-03-21-44-20\", \"type\": + \"string\"}}], \"responses\": {\"200\": {\"content\": {\"application/json\": + {\"schema\": {\"$ref\": \"#/components/schemas/DeleteModelResponse\"}}}, \"description\": + \"OK\"}}, \"summary\": \"Delete a fine-tuned model. You must have the Owner + role in your organization.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": + {\"curl\": \"curl https://api.openai.com/v1/models/curie:ft-acmeco-2021-03-03-21-44-20 + \\\\\\n -X DELETE \\\\\\n -H \\\"Authorization: Bearer YOUR_API_KEY\\\"\\n\", + \"node.js\": \"const { Configuration, OpenAIApi } = require(\\\"openai\\\");\\nconst + configuration = new Configuration({\\n apiKey: process.env.OPENAI_API_KEY,\\n});\\nconst + openai = new OpenAIApi(configuration);\\nconst response = await openai.deleteModel(''curie:ft-acmeco-2021-03-03-21-44-20'');\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Model.delete(\\\"curie:ft-acmeco-2021-03-03-21-44-20\\\")\\n\"}, + \"group\": \"fine-tunes\", \"name\": \"Delete fine-tune model\", \"path\": \"delete-model\", + \"response\": \"{\\n \\\"id\\\": \\\"curie:ft-acmeco-2021-03-03-21-44-20\\\",\\n \\\"object\\\": + \\\"model\\\",\\n \\\"deleted\\\": true\\n}\\n\"}}, \"get\": {\"operationId\": + \"retrieveModel\", \"parameters\": [{\"description\": \"The ID of the model + to use for this request\", \"in\": \"path\", \"name\": \"model\", \"required\": + true, \"schema\": {\"example\": \"text-davinci-001\", \"type\": \"string\"}}], + \"responses\": {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/Model\"}}}, \"description\": \"OK\"}}, \"summary\": \"Retrieves + a model instance, providing basic information about the model such as the owner + and permissioning.\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": + {\"curl\": \"curl https://api.openai.com/v1/models/VAR_model_id \\\\\\n -H + ''Authorization: Bearer YOUR_API_KEY''\\n\", \"node.js\": \"const { Configuration, + OpenAIApi } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.retrieveModel(\\\"VAR_model_id\\\");\\n\", \"python\": + \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Model.retrieve(\\\"VAR_model_id\\\")\\n\"}, + \"group\": \"models\", \"name\": \"Retrieve model\", \"path\": \"retrieve\", + \"response\": \"{\\n \\\"id\\\": \\\"VAR_model_id\\\",\\n \\\"object\\\": + \\\"model\\\",\\n \\\"owned_by\\\": \\\"openai\\\",\\n \\\"permission\\\": + [...]\\n}\\n\"}}}, \"/moderations\": {\"post\": {\"operationId\": \"createModeration\", + \"requestBody\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": + \"#/components/schemas/CreateModerationRequest\"}}}, \"required\": true}, \"responses\": + {\"200\": {\"content\": {\"application/json\": {\"schema\": {\"$ref\": \"#/components/schemas/CreateModerationResponse\"}}}, + \"description\": \"OK\"}}, \"summary\": \"Classifies if text violates OpenAI''s + Content Policy\", \"tags\": [\"OpenAI\"], \"x-oaiMeta\": {\"examples\": {\"curl\": + \"curl https://api.openai.com/v1/moderations \\\\\\n -H ''Content-Type: application/json'' + \\\\\\n -H ''Authorization: Bearer YOUR_API_KEY'' \\\\\\n -d ''{\\n \\\"input\\\": + \\\"I want to kill them.\\\"\\n}''\\n\", \"node.js\": \"const { Configuration, + OpenAIApi } = require(\\\"openai\\\");\\nconst configuration = new Configuration({\\n apiKey: + process.env.OPENAI_API_KEY,\\n});\\nconst openai = new OpenAIApi(configuration);\\nconst + response = await openai.createModeration({\\n input: \\\"I want to kill them.\\\",\\n});\\n\", + \"python\": \"import os\\nimport openai\\nopenai.api_key = os.getenv(\\\"OPENAI_API_KEY\\\")\\nopenai.Moderation.create(\\n input=\\\"I + want to kill them.\\\",\\n)\\n\"}, \"group\": \"moderations\", \"name\": \"Create + moderation\", \"parameters\": \"{\\n \\\"input\\\": \\\"I want to kill them.\\\"\\n}\\n\", + \"path\": \"create\", \"response\": \"{\\n \\\"id\\\": \\\"modr-5MWoLO\\\",\\n \\\"model\\\": + \\\"text-moderation-001\\\",\\n \\\"results\\\": [\\n {\\n \\\"categories\\\": + {\\n \\\"hate\\\": false,\\n \\\"hate/threatening\\\": true,\\n \\\"self-harm\\\": + false,\\n \\\"sexual\\\": false,\\n \\\"sexual/minors\\\": false,\\n \\\"violence\\\": + true,\\n \\\"violence/graphic\\\": false\\n },\\n \\\"category_scores\\\": + {\\n \\\"hate\\\": 0.22714105248451233,\\n \\\"hate/threatening\\\": + 0.4132447838783264,\\n \\\"self-harm\\\": 0.005232391878962517,\\n \\\"sexual\\\": + 0.01407341007143259,\\n \\\"sexual/minors\\\": 0.0038522258400917053,\\n \\\"violence\\\": + 0.9223177433013916,\\n \\\"violence/graphic\\\": 0.036865197122097015\\n },\\n \\\"flagged\\\": + true\\n }\\n ]\\n}\\n\"}}}}, \"components\": {\"schemas\": {\"ChatCompletionRequestMessage\": + {\"properties\": {\"content\": {\"description\": \"The contents of the message\", + \"type\": \"string\"}, \"name\": {\"description\": \"The name of the user in + a multi-user chat\", \"type\": \"string\"}, \"role\": {\"description\": \"The + role of the author of this message.\", \"enum\": [\"system\", \"user\", \"assistant\"], + \"type\": \"string\"}}, \"required\": [\"role\", \"content\"], \"type\": \"object\"}, + \"ChatCompletionResponseMessage\": {\"properties\": {\"content\": {\"description\": + \"The contents of the message\", \"type\": \"string\"}, \"role\": {\"description\": + \"The role of the author of this message.\", \"enum\": [\"system\", \"user\", + \"assistant\"], \"type\": \"string\"}}, \"required\": [\"role\", \"content\"], + \"type\": \"object\"}, \"CreateAnswerRequest\": {\"additionalProperties\": false, + \"properties\": {\"documents\": {\"description\": \"List of documents from which + the answer for the input `question` should be derived. If this is an empty list, + the question will be answered based on the question-answer examples.\\n\\nYou + should specify either `documents` or a `file`, but not both.\\n\", \"example\": + \"[''Japan is an island country in East Asia, located in the northwest Pacific + Ocean.'', ''Tokyo is the capital and most populous prefecture of Japan.'']\", + \"items\": {\"type\": \"string\"}, \"maxItems\": 200, \"nullable\": true, \"type\": + \"array\"}, \"examples\": {\"description\": \"List of (question, answer) pairs + that will help steer the model towards the tone and answer format you''d like. + We recommend adding 2 to 3 examples.\", \"example\": \"[[''What is the capital + of Canada?'', ''Ottawa''], [''Which province is Ottawa in?'', ''Ontario'']]\", + \"items\": {\"items\": {\"minLength\": 1, \"type\": \"string\"}, \"maxItems\": + 2, \"minItems\": 2, \"type\": \"array\"}, \"maxItems\": 200, \"minItems\": 1, + \"type\": \"array\"}, \"examples_context\": {\"description\": \"A text snippet + containing the contextual information used to generate the answers for the `examples` + you provide.\", \"example\": \"Ottawa, Canada''s capital, is located in the + east of southern Ontario, near the city of Montr\\u00e9al and the U.S. border.\", + \"type\": \"string\"}, \"expand\": {\"default\": [], \"description\": \"If an + object name is in the list, we provide the full information of the object; otherwise, + we only provide the object ID. Currently we support `completion` and `file` + objects for expansion.\", \"items\": {}, \"nullable\": true, \"type\": \"array\"}, + \"file\": {\"description\": \"The ID of an uploaded file that contains documents + to search over. See [upload file](/docs/api-reference/files/upload) for how + to upload a file of the desired format and purpose.\\n\\nYou should specify + either `documents` or a `file`, but not both.\\n\", \"nullable\": true, \"type\": + \"string\"}, \"logit_bias\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/logit_bias\"}, + \"logprobs\": {\"default\": null, \"description\": \"Include the log probabilities + on the `logprobs` most likely tokens, as well the chosen tokens. For example, + if `logprobs` is 5, the API will return a list of the 5 most likely tokens. + The API will always return the `logprob` of the sampled token, so there may + be up to `logprobs+1` elements in the response.\\n\\nThe maximum value for `logprobs` + is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) + and describe your use case.\\n\\nWhen `logprobs` is set, `completion` will be + automatically added into `expand` to get the logprobs.\\n\", \"maximum\": 5, + \"minimum\": 0, \"nullable\": true, \"type\": \"integer\"}, \"max_rerank\": + {\"default\": 200, \"description\": \"The maximum number of documents to be + ranked by [Search](/docs/api-reference/searches/create) when using `file`. Setting + it to a higher value leads to improved accuracy but with increased latency and + cost.\", \"nullable\": true, \"type\": \"integer\"}, \"max_tokens\": {\"default\": + 16, \"description\": \"The maximum number of tokens allowed for the generated + answer\", \"nullable\": true, \"type\": \"integer\"}, \"model\": {\"description\": + \"ID of the model to use for completion. You can select one of `ada`, `babbage`, + `curie`, or `davinci`.\", \"type\": \"string\"}, \"n\": {\"default\": 1, \"description\": + \"How many answers to generate for each question.\", \"maximum\": 10, \"minimum\": + 1, \"nullable\": true, \"type\": \"integer\"}, \"question\": {\"description\": + \"Question to get answered.\", \"example\": \"What is the capital of Japan?\", + \"minLength\": 1, \"type\": \"string\"}, \"return_metadata\": {\"$ref\": \"#/components/schemas/CreateSearchRequest/properties/return_metadata\"}, + \"return_prompt\": {\"default\": false, \"description\": \"If set to `true`, + the returned JSON will include a \\\"prompt\\\" field containing the final prompt + that was used to request a completion. This is mainly useful for debugging purposes.\", + \"nullable\": true, \"type\": \"boolean\"}, \"search_model\": {\"default\": + \"ada\", \"description\": \"ID of the model to use for [Search](/docs/api-reference/searches/create). + You can select one of `ada`, `babbage`, `curie`, or `davinci`.\", \"nullable\": + true, \"type\": \"string\"}, \"stop\": {\"default\": null, \"description\": + \"Up to 4 sequences where the API will stop generating further tokens. The returned + text will not contain the stop sequence.\\n\", \"nullable\": true, \"oneOf\": + [{\"default\": \"<|endoftext|>\", \"example\": \"\\n\", \"type\": \"string\"}, + {\"items\": {\"example\": \"[\\\"\\\\n\\\"]\", \"type\": \"string\"}, \"maxItems\": + 4, \"minItems\": 1, \"type\": \"array\"}]}, \"temperature\": {\"default\": 0, + \"description\": \"What sampling temperature to use, between 0 and 2. Higher + values like 0.8 will make the output more random, while lower values like 0.2 + will make it more focused and deterministic.\", \"nullable\": true, \"type\": + \"number\"}, \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"model\", \"question\", \"examples\", \"examples_context\"], + \"type\": \"object\"}, \"CreateAnswerResponse\": {\"properties\": {\"answers\": + {\"items\": {\"type\": \"string\"}, \"type\": \"array\"}, \"completion\": {\"type\": + \"string\"}, \"model\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, + \"search_model\": {\"type\": \"string\"}, \"selected_documents\": {\"items\": + {\"properties\": {\"document\": {\"type\": \"integer\"}, \"text\": {\"type\": + \"string\"}}, \"type\": \"object\"}, \"type\": \"array\"}}, \"type\": \"object\"}, + \"CreateChatCompletionRequest\": {\"properties\": {\"frequency_penalty\": {\"default\": + 0, \"description\": \"Number between -2.0 and 2.0. Positive values penalize + new tokens based on their existing frequency in the text so far, decreasing + the model''s likelihood to repeat the same line verbatim.\\n\\n[See more information + about frequency and presence penalties.](/docs/api-reference/parameter-details)\\n\", + \"maximum\": 2, \"minimum\": -2, \"nullable\": true, \"type\": \"number\"}, + \"logit_bias\": {\"default\": null, \"description\": \"Modify the likelihood + of specified tokens appearing in the completion.\\n\\nAccepts a json object + that maps tokens (specified by their token ID in the tokenizer) to an associated + bias value from -100 to 100. Mathematically, the bias is added to the logits + generated by the model prior to sampling. The exact effect will vary per model, + but values between -1 and 1 should decrease or increase likelihood of selection; + values like -100 or 100 should result in a ban or exclusive selection of the + relevant token.\\n\", \"nullable\": true, \"type\": \"object\", \"x-oaiTypeLabel\": + \"map\"}, \"max_tokens\": {\"default\": \"inf\", \"description\": \"The maximum + number of tokens allowed for the generated answer. By default, the number of + tokens the model can return will be (4096 - prompt tokens).\\n\", \"type\": + \"integer\"}, \"messages\": {\"description\": \"The messages to generate chat + completions for, in the [chat format](/docs/guides/chat/introduction).\", \"items\": + {\"$ref\": \"#/components/schemas/ChatCompletionRequestMessage\"}, \"minItems\": + 1, \"type\": \"array\"}, \"model\": {\"description\": \"ID of the model to use. + Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.\", \"type\": + \"string\"}, \"n\": {\"default\": 1, \"description\": \"How many chat completion + choices to generate for each input message.\", \"example\": 1, \"maximum\": + 128, \"minimum\": 1, \"nullable\": true, \"type\": \"integer\"}, \"presence_penalty\": + {\"default\": 0, \"description\": \"Number between -2.0 and 2.0. Positive values + penalize new tokens based on whether they appear in the text so far, increasing + the model''s likelihood to talk about new topics.\\n\\n[See more information + about frequency and presence penalties.](/docs/api-reference/parameter-details)\\n\", + \"maximum\": 2, \"minimum\": -2, \"nullable\": true, \"type\": \"number\"}, + \"stop\": {\"default\": null, \"description\": \"Up to 4 sequences where the + API will stop generating further tokens.\\n\", \"oneOf\": [{\"nullable\": true, + \"type\": \"string\"}, {\"items\": {\"type\": \"string\"}, \"maxItems\": 4, + \"minItems\": 1, \"type\": \"array\"}]}, \"stream\": {\"default\": false, \"description\": + \"If set, partial message deltas will be sent, like in ChatGPT. Tokens will + be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) + as they become available, with the stream terminated by a `data: [DONE]` message.\\n\", + \"nullable\": true, \"type\": \"boolean\"}, \"temperature\": {\"default\": 1, + \"description\": \"What sampling temperature to use, between 0 and 2. Higher + values like 0.8 will make the output more random, while lower values like 0.2 + will make it more focused and deterministic.\\n\\nWe generally recommend altering + this or `top_p` but not both.\\n\", \"example\": 1, \"maximum\": 2, \"minimum\": + 0, \"nullable\": true, \"type\": \"number\"}, \"top_p\": {\"default\": 1, \"description\": + \"An alternative to sampling with temperature, called nucleus sampling, where + the model considers the results of the tokens with top_p probability mass. So + 0.1 means only the tokens comprising the top 10% probability mass are considered.\\n\\nWe + generally recommend altering this or `temperature` but not both.\\n\", \"example\": + 1, \"maximum\": 1, \"minimum\": 0, \"nullable\": true, \"type\": \"number\"}, + \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"model\", \"messages\"], \"type\": \"object\"}, \"CreateChatCompletionResponse\": + {\"properties\": {\"choices\": {\"items\": {\"properties\": {\"finish_reason\": + {\"type\": \"string\"}, \"index\": {\"type\": \"integer\"}, \"message\": {\"$ref\": + \"#/components/schemas/ChatCompletionResponseMessage\"}}, \"type\": \"object\"}, + \"type\": \"array\"}, \"created\": {\"type\": \"integer\"}, \"id\": {\"type\": + \"string\"}, \"model\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, + \"usage\": {\"properties\": {\"completion_tokens\": {\"type\": \"integer\"}, + \"prompt_tokens\": {\"type\": \"integer\"}, \"total_tokens\": {\"type\": \"integer\"}}, + \"required\": [\"prompt_tokens\", \"completion_tokens\", \"total_tokens\"], + \"type\": \"object\"}}, \"required\": [\"id\", \"object\", \"created\", \"model\", + \"choices\"], \"type\": \"object\"}, \"CreateClassificationRequest\": {\"additionalProperties\": + false, \"properties\": {\"examples\": {\"description\": \"A list of examples + with labels, in the following format:\\n\\n`[[\\\"The movie is so interesting.\\\", + \\\"Positive\\\"], [\\\"It is quite boring.\\\", \\\"Negative\\\"], ...]`\\n\\nAll + the label strings will be normalized to be capitalized.\\n\\nYou should specify + either `examples` or `file`, but not both.\\n\", \"example\": \"[[''Do not see + this film.'', ''Negative''], [''Smart, provocative and blisteringly funny.'', + ''Positive'']]\", \"items\": {\"items\": {\"minLength\": 1, \"type\": \"string\"}, + \"maxItems\": 2, \"minItems\": 2, \"type\": \"array\"}, \"maxItems\": 200, \"minItems\": + 2, \"nullable\": true, \"type\": \"array\"}, \"expand\": {\"$ref\": \"#/components/schemas/CreateAnswerRequest/properties/expand\"}, + \"file\": {\"description\": \"The ID of the uploaded file that contains training + examples. See [upload file](/docs/api-reference/files/upload) for how to upload + a file of the desired format and purpose.\\n\\nYou should specify either `examples` + or `file`, but not both.\\n\", \"nullable\": true, \"type\": \"string\"}, \"labels\": + {\"default\": null, \"description\": \"The set of categories being classified. + If not specified, candidate labels will be automatically collected from the + examples you provide. All the label strings will be normalized to be capitalized.\", + \"example\": [\"Positive\", \"Negative\"], \"items\": {\"type\": \"string\"}, + \"maxItems\": 200, \"minItems\": 2, \"nullable\": true, \"type\": \"array\"}, + \"logit_bias\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/logit_bias\"}, + \"logprobs\": {\"$ref\": \"#/components/schemas/CreateAnswerRequest/properties/logprobs\"}, + \"max_examples\": {\"default\": 200, \"description\": \"The maximum number of + examples to be ranked by [Search](/docs/api-reference/searches/create) when + using `file`. Setting it to a higher value leads to improved accuracy but with + increased latency and cost.\", \"nullable\": true, \"type\": \"integer\"}, \"model\": + {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/model\"}, + \"query\": {\"description\": \"Query to be classified.\", \"example\": \"The + plot is not very attractive.\", \"minLength\": 1, \"type\": \"string\"}, \"return_metadata\": + {\"$ref\": \"#/components/schemas/CreateSearchRequest/properties/return_metadata\"}, + \"return_prompt\": {\"$ref\": \"#/components/schemas/CreateAnswerRequest/properties/return_prompt\"}, + \"search_model\": {\"$ref\": \"#/components/schemas/CreateAnswerRequest/properties/search_model\"}, + \"temperature\": {\"default\": 0, \"description\": \"What sampling temperature + to use, between 0 and 2. Higher values like 0.8 will make the output more random, + while lower values like 0.2 will make it more focused and deterministic.\", + \"example\": 0, \"maximum\": 2, \"minimum\": 0, \"nullable\": true, \"type\": + \"number\"}, \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"model\", \"query\"], \"type\": \"object\"}, \"CreateClassificationResponse\": + {\"properties\": {\"completion\": {\"type\": \"string\"}, \"label\": {\"type\": + \"string\"}, \"model\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, + \"search_model\": {\"type\": \"string\"}, \"selected_examples\": {\"items\": + {\"properties\": {\"document\": {\"type\": \"integer\"}, \"label\": {\"type\": + \"string\"}, \"text\": {\"type\": \"string\"}}, \"type\": \"object\"}, \"type\": + \"array\"}}, \"type\": \"object\"}, \"CreateCompletionRequest\": {\"properties\": + {\"best_of\": {\"default\": 1, \"description\": \"Generates `best_of` completions + server-side and returns the \\\"best\\\" (the one with the highest log probability + per token). Results cannot be streamed.\\n\\nWhen used with `n`, `best_of` controls + the number of candidate completions and `n` specifies how many to return \\u2013 + `best_of` must be greater than `n`.\\n\\n**Note:** Because this parameter generates + many completions, it can quickly consume your token quota. Use carefully and + ensure that you have reasonable settings for `max_tokens` and `stop`.\\n\", + \"maximum\": 20, \"minimum\": 0, \"nullable\": true, \"type\": \"integer\"}, + \"echo\": {\"default\": false, \"description\": \"Echo back the prompt in addition + to the completion\\n\", \"nullable\": true, \"type\": \"boolean\"}, \"frequency_penalty\": + {\"default\": 0, \"description\": \"Number between -2.0 and 2.0. Positive values + penalize new tokens based on their existing frequency in the text so far, decreasing + the model''s likelihood to repeat the same line verbatim.\\n\\n[See more information + about frequency and presence penalties.](/docs/api-reference/parameter-details)\\n\", + \"maximum\": 2, \"minimum\": -2, \"nullable\": true, \"type\": \"number\"}, + \"logit_bias\": {\"default\": null, \"description\": \"Modify the likelihood + of specified tokens appearing in the completion.\\n\\nAccepts a json object + that maps tokens (specified by their token ID in the GPT tokenizer) to an associated + bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) + (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, + the bias is added to the logits generated by the model prior to sampling. The + exact effect will vary per model, but values between -1 and 1 should decrease + or increase likelihood of selection; values like -100 or 100 should result in + a ban or exclusive selection of the relevant token.\\n\\nAs an example, you + can pass `{\\\"50256\\\": -100}` to prevent the <|endoftext|> token from being + generated.\\n\", \"nullable\": true, \"type\": \"object\", \"x-oaiTypeLabel\": + \"map\"}, \"logprobs\": {\"default\": null, \"description\": \"Include the log + probabilities on the `logprobs` most likely tokens, as well the chosen tokens. + For example, if `logprobs` is 5, the API will return a list of the 5 most likely + tokens. The API will always return the `logprob` of the sampled token, so there + may be up to `logprobs+1` elements in the response.\\n\\nThe maximum value for + `logprobs` is 5. If you need more than this, please contact us through our [Help + center](https://help.openai.com) and describe your use case.\\n\", \"maximum\": + 5, \"minimum\": 0, \"nullable\": true, \"type\": \"integer\"}, \"max_tokens\": + {\"default\": 16, \"description\": \"The maximum number of [tokens](/tokenizer) + to generate in the completion.\\n\\nThe token count of your prompt plus `max_tokens` + cannot exceed the model''s context length. Most models have a context length + of 2048 tokens (except for the newest models, which support 4096).\\n\", \"example\": + 16, \"minimum\": 0, \"nullable\": true, \"type\": \"integer\"}, \"model\": {\"description\": + \"ID of the model to use. You can use the [List models](/docs/api-reference/models/list) + API to see all of your available models, or see our [Model overview](/docs/models/overview) + for descriptions of them.\", \"type\": \"string\"}, \"n\": {\"default\": 1, + \"description\": \"How many completions to generate for each prompt.\\n\\n**Note:** + Because this parameter generates many completions, it can quickly consume your + token quota. Use carefully and ensure that you have reasonable settings for + `max_tokens` and `stop`.\\n\", \"example\": 1, \"maximum\": 128, \"minimum\": + 1, \"nullable\": true, \"type\": \"integer\"}, \"presence_penalty\": {\"default\": + 0, \"description\": \"Number between -2.0 and 2.0. Positive values penalize + new tokens based on whether they appear in the text so far, increasing the model''s + likelihood to talk about new topics.\\n\\n[See more information about frequency + and presence penalties.](/docs/api-reference/parameter-details)\\n\", \"maximum\": + 2, \"minimum\": -2, \"nullable\": true, \"type\": \"number\"}, \"prompt\": {\"default\": + \"<|endoftext|>\", \"description\": \"The prompt(s) to generate completions + for, encoded as a string, array of strings, array of tokens, or array of token + arrays.\\n\\nNote that <|endoftext|> is the document separator that the model + sees during training, so if a prompt is not specified the model will generate + as if from the beginning of a new document.\\n\", \"nullable\": true, \"oneOf\": + [{\"default\": \"\", \"example\": \"This is a test.\", \"type\": \"string\"}, + {\"items\": {\"default\": \"\", \"example\": \"This is a test.\", \"type\": + \"string\"}, \"type\": \"array\"}, {\"example\": \"[1212, 318, 257, 1332, 13]\", + \"items\": {\"type\": \"integer\"}, \"minItems\": 1, \"type\": \"array\"}, {\"example\": + \"[[1212, 318, 257, 1332, 13]]\", \"items\": {\"items\": {\"type\": \"integer\"}, + \"minItems\": 1, \"type\": \"array\"}, \"minItems\": 1, \"type\": \"array\"}]}, + \"stop\": {\"default\": null, \"description\": \"Up to 4 sequences where the + API will stop generating further tokens. The returned text will not contain + the stop sequence.\\n\", \"nullable\": true, \"oneOf\": [{\"default\": \"<|endoftext|>\", + \"example\": \"\\n\", \"nullable\": true, \"type\": \"string\"}, {\"items\": + {\"example\": \"[\\\"\\\\n\\\"]\", \"type\": \"string\"}, \"maxItems\": 4, \"minItems\": + 1, \"type\": \"array\"}]}, \"stream\": {\"default\": false, \"description\": + \"Whether to stream back partial progress. If set, tokens will be sent as data-only + [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) + as they become available, with the stream terminated by a `data: [DONE]` message.\\n\", + \"nullable\": true, \"type\": \"boolean\"}, \"suffix\": {\"default\": null, + \"description\": \"The suffix that comes after a completion of inserted text.\", + \"example\": \"test.\", \"nullable\": true, \"type\": \"string\"}, \"temperature\": + {\"default\": 1, \"description\": \"What sampling temperature to use, between + 0 and 2. Higher values like 0.8 will make the output more random, while lower + values like 0.2 will make it more focused and deterministic.\\n\\nWe generally + recommend altering this or `top_p` but not both.\\n\", \"example\": 1, \"maximum\": + 2, \"minimum\": 0, \"nullable\": true, \"type\": \"number\"}, \"top_p\": {\"default\": + 1, \"description\": \"An alternative to sampling with temperature, called nucleus + sampling, where the model considers the results of the tokens with top_p probability + mass. So 0.1 means only the tokens comprising the top 10% probability mass are + considered.\\n\\nWe generally recommend altering this or `temperature` but not + both.\\n\", \"example\": 1, \"maximum\": 1, \"minimum\": 0, \"nullable\": true, + \"type\": \"number\"}, \"user\": {\"description\": \"A unique identifier representing + your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\\n\", + \"example\": \"user-1234\", \"type\": \"string\"}}, \"required\": [\"model\"], + \"type\": \"object\"}, \"CreateCompletionResponse\": {\"properties\": {\"choices\": + {\"items\": {\"properties\": {\"finish_reason\": {\"type\": \"string\"}, \"index\": + {\"type\": \"integer\"}, \"logprobs\": {\"nullable\": true, \"properties\": + {\"text_offset\": {\"items\": {\"type\": \"integer\"}, \"type\": \"array\"}, + \"token_logprobs\": {\"items\": {\"type\": \"number\"}, \"type\": \"array\"}, + \"tokens\": {\"items\": {\"type\": \"string\"}, \"type\": \"array\"}, \"top_logprobs\": + {\"items\": {\"type\": \"object\"}, \"type\": \"array\"}}, \"type\": \"object\"}, + \"text\": {\"type\": \"string\"}}, \"type\": \"object\"}, \"type\": \"array\"}, + \"created\": {\"type\": \"integer\"}, \"id\": {\"type\": \"string\"}, \"model\": + {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, \"usage\": {\"properties\": + {\"completion_tokens\": {\"type\": \"integer\"}, \"prompt_tokens\": {\"type\": + \"integer\"}, \"total_tokens\": {\"type\": \"integer\"}}, \"required\": [\"prompt_tokens\", + \"completion_tokens\", \"total_tokens\"], \"type\": \"object\"}}, \"required\": + [\"id\", \"object\", \"created\", \"model\", \"choices\"], \"type\": \"object\"}, + \"CreateEditRequest\": {\"properties\": {\"input\": {\"default\": \"\", \"description\": + \"The input text to use as a starting point for the edit.\", \"example\": \"What + day of the wek is it?\", \"nullable\": true, \"type\": \"string\"}, \"instruction\": + {\"description\": \"The instruction that tells the model how to edit the prompt.\", + \"example\": \"Fix the spelling mistakes.\", \"type\": \"string\"}, \"model\": + {\"description\": \"ID of the model to use. You can use the `text-davinci-edit-001` + or `code-davinci-edit-001` model with this endpoint.\", \"type\": \"string\"}, + \"n\": {\"default\": 1, \"description\": \"How many edits to generate for the + input and instruction.\", \"example\": 1, \"maximum\": 20, \"minimum\": 1, \"nullable\": + true, \"type\": \"integer\"}, \"temperature\": {\"default\": 1, \"description\": + \"What sampling temperature to use, between 0 and 2. Higher values like 0.8 + will make the output more random, while lower values like 0.2 will make it more + focused and deterministic.\\n\\nWe generally recommend altering this or `top_p` + but not both.\\n\", \"example\": 1, \"maximum\": 2, \"minimum\": 0, \"nullable\": + true, \"type\": \"number\"}, \"top_p\": {\"default\": 1, \"description\": \"An + alternative to sampling with temperature, called nucleus sampling, where the + model considers the results of the tokens with top_p probability mass. So 0.1 + means only the tokens comprising the top 10% probability mass are considered.\\n\\nWe + generally recommend altering this or `temperature` but not both.\\n\", \"example\": + 1, \"maximum\": 1, \"minimum\": 0, \"nullable\": true, \"type\": \"number\"}}, + \"required\": [\"model\", \"instruction\"], \"type\": \"object\"}, \"CreateEditResponse\": + {\"properties\": {\"choices\": {\"items\": {\"properties\": {\"finish_reason\": + {\"type\": \"string\"}, \"index\": {\"type\": \"integer\"}, \"logprobs\": {\"nullable\": + true, \"properties\": {\"text_offset\": {\"items\": {\"type\": \"integer\"}, + \"type\": \"array\"}, \"token_logprobs\": {\"items\": {\"type\": \"number\"}, + \"type\": \"array\"}, \"tokens\": {\"items\": {\"type\": \"string\"}, \"type\": + \"array\"}, \"top_logprobs\": {\"items\": {\"type\": \"object\"}, \"type\": + \"array\"}}, \"type\": \"object\"}, \"text\": {\"type\": \"string\"}}, \"type\": + \"object\"}, \"type\": \"array\"}, \"created\": {\"type\": \"integer\"}, \"object\": + {\"type\": \"string\"}, \"usage\": {\"properties\": {\"completion_tokens\": + {\"type\": \"integer\"}, \"prompt_tokens\": {\"type\": \"integer\"}, \"total_tokens\": + {\"type\": \"integer\"}}, \"required\": [\"prompt_tokens\", \"completion_tokens\", + \"total_tokens\"], \"type\": \"object\"}}, \"required\": [\"object\", \"created\", + \"choices\", \"usage\"], \"type\": \"object\"}, \"CreateEmbeddingRequest\": + {\"additionalProperties\": false, \"properties\": {\"input\": {\"description\": + \"Input text to get embeddings for, encoded as a string or array of tokens. + To get embeddings for multiple inputs in a single request, pass an array of + strings or array of token arrays. Each input must not exceed 8192 tokens in + length.\\n\", \"example\": \"The quick brown fox jumped over the lazy dog\", + \"oneOf\": [{\"default\": \"\", \"example\": \"This is a test.\", \"type\": + \"string\"}, {\"items\": {\"default\": \"\", \"example\": \"This is a test.\", + \"type\": \"string\"}, \"type\": \"array\"}, {\"example\": \"[1212, 318, 257, + 1332, 13]\", \"items\": {\"type\": \"integer\"}, \"minItems\": 1, \"type\": + \"array\"}, {\"example\": \"[[1212, 318, 257, 1332, 13]]\", \"items\": {\"items\": + {\"type\": \"integer\"}, \"minItems\": 1, \"type\": \"array\"}, \"minItems\": + 1, \"type\": \"array\"}]}, \"model\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/model\"}, + \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"model\", \"input\"], \"type\": \"object\"}, \"CreateEmbeddingResponse\": + {\"properties\": {\"data\": {\"items\": {\"properties\": {\"embedding\": {\"items\": + {\"type\": \"number\"}, \"type\": \"array\"}, \"index\": {\"type\": \"integer\"}, + \"object\": {\"type\": \"string\"}}, \"required\": [\"index\", \"object\", \"embedding\"], + \"type\": \"object\"}, \"type\": \"array\"}, \"model\": {\"type\": \"string\"}, + \"object\": {\"type\": \"string\"}, \"usage\": {\"properties\": {\"prompt_tokens\": + {\"type\": \"integer\"}, \"total_tokens\": {\"type\": \"integer\"}}, \"required\": + [\"prompt_tokens\", \"total_tokens\"], \"type\": \"object\"}}, \"required\": + [\"object\", \"model\", \"data\", \"usage\"], \"type\": \"object\"}, \"CreateFileRequest\": + {\"additionalProperties\": false, \"properties\": {\"file\": {\"description\": + \"Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file + to be uploaded.\\n\\nIf the `purpose` is set to \\\"fine-tune\\\", each line + is a JSON record with \\\"prompt\\\" and \\\"completion\\\" fields representing + your [training examples](/docs/guides/fine-tuning/prepare-training-data).\\n\", + \"format\": \"binary\", \"type\": \"string\"}, \"purpose\": {\"description\": + \"The intended purpose of the uploaded documents.\\n\\nUse \\\"fine-tune\\\" + for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate + the format of the uploaded file.\\n\", \"type\": \"string\"}}, \"required\": + [\"file\", \"purpose\"], \"type\": \"object\"}, \"CreateFineTuneRequest\": {\"properties\": + {\"batch_size\": {\"default\": null, \"description\": \"The batch size to use + for training. The batch size is the number of\\ntraining examples used to train + a single forward and backward pass.\\n\\nBy default, the batch size will be + dynamically configured to be\\n~0.2% of the number of examples in the training + set, capped at 256 -\\nin general, we''ve found that larger batch sizes tend + to work better\\nfor larger datasets.\\n\", \"nullable\": true, \"type\": \"integer\"}, + \"classification_betas\": {\"default\": null, \"description\": \"If this is + provided, we calculate F-beta scores at the specified\\nbeta values. The F-beta + score is a generalization of F-1 score.\\nThis is only used for binary classification.\\n\\nWith + a beta of 1 (i.e. the F-1 score), precision and recall are\\ngiven the same + weight. A larger beta score puts more weight on\\nrecall and less on precision. + A smaller beta score puts more weight\\non precision and less on recall.\\n\", + \"example\": [0.6, 1, 1.5, 2], \"items\": {\"type\": \"number\"}, \"nullable\": + true, \"type\": \"array\"}, \"classification_n_classes\": {\"default\": null, + \"description\": \"The number of classes in a classification task.\\n\\nThis + parameter is required for multiclass classification.\\n\", \"nullable\": true, + \"type\": \"integer\"}, \"classification_positive_class\": {\"default\": null, + \"description\": \"The positive class in binary classification.\\n\\nThis parameter + is needed to generate precision, recall, and F1\\nmetrics when doing binary + classification.\\n\", \"nullable\": true, \"type\": \"string\"}, \"compute_classification_metrics\": + {\"default\": false, \"description\": \"If set, we calculate classification-specific + metrics such as accuracy\\nand F-1 score using the validation set at the end + of every epoch.\\nThese metrics can be viewed in the [results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\\n\\nIn + order to compute classification metrics, you must provide a\\n`validation_file`. + Additionally, you must\\nspecify `classification_n_classes` for multiclass classification + or\\n`classification_positive_class` for binary classification.\\n\", \"nullable\": + true, \"type\": \"boolean\"}, \"learning_rate_multiplier\": {\"default\": null, + \"description\": \"The learning rate multiplier to use for training.\\nThe fine-tuning + learning rate is the original learning rate used for\\npretraining multiplied + by this value.\\n\\nBy default, the learning rate multiplier is the 0.05, 0.1, + or 0.2\\ndepending on final `batch_size` (larger learning rates tend to\\nperform + better with larger batch sizes). We recommend experimenting\\nwith values in + the range 0.02 to 0.2 to see what produces the best\\nresults.\\n\", \"nullable\": + true, \"type\": \"number\"}, \"model\": {\"default\": \"curie\", \"description\": + \"The name of the base model to fine-tune. You can select one of \\\"ada\\\",\\n\\\"babbage\\\", + \\\"curie\\\", \\\"davinci\\\", or a fine-tuned model created after 2022-04-21.\\nTo + learn more about these models, see the\\n[Models](https://platform.openai.com/docs/models) + documentation.\\n\", \"nullable\": true, \"type\": \"string\"}, \"n_epochs\": + {\"default\": 4, \"description\": \"The number of epochs to train the model + for. An epoch refers to one\\nfull cycle through the training dataset.\\n\", + \"nullable\": true, \"type\": \"integer\"}, \"prompt_loss_weight\": {\"default\": + 0.01, \"description\": \"The weight to use for loss on the prompt tokens. This + controls how\\nmuch the model tries to learn to generate the prompt (as compared\\nto + the completion which always has a weight of 1.0), and can add\\na stabilizing + effect to training when completions are short.\\n\\nIf prompts are extremely + long (relative to completions), it may make\\nsense to reduce this weight so + as to avoid over-prioritizing\\nlearning the prompt.\\n\", \"nullable\": true, + \"type\": \"number\"}, \"suffix\": {\"default\": null, \"description\": \"A + string of up to 40 characters that will be added to your fine-tuned model name.\\n\\nFor + example, a `suffix` of \\\"custom-model-name\\\" would produce a model name + like `ada:ft-your-org:custom-model-name-2022-02-15-04-21-04`.\\n\", \"maxLength\": + 40, \"minLength\": 1, \"nullable\": true, \"type\": \"string\"}, \"training_file\": + {\"description\": \"The ID of an uploaded file that contains training data.\\n\\nSee + [upload file](/docs/api-reference/files/upload) for how to upload a file.\\n\\nYour + dataset must be formatted as a JSONL file, where each training\\nexample is + a JSON object with the keys \\\"prompt\\\" and \\\"completion\\\".\\nAdditionally, + you must upload your file with the purpose `fine-tune`.\\n\\nSee the [fine-tuning + guide](/docs/guides/fine-tuning/creating-training-data) for more details.\\n\", + \"example\": \"file-ajSREls59WBbvgSzJSVWxMCB\", \"type\": \"string\"}, \"validation_file\": + {\"description\": \"The ID of an uploaded file that contains validation data.\\n\\nIf + you provide this file, the data is used to generate validation\\nmetrics periodically + during fine-tuning. These metrics can be viewed in\\nthe [fine-tuning results + file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\\nYour train + and validation data should be mutually exclusive.\\n\\nYour dataset must be + formatted as a JSONL file, where each validation\\nexample is a JSON object + with the keys \\\"prompt\\\" and \\\"completion\\\".\\nAdditionally, you must + upload your file with the purpose `fine-tune`.\\n\\nSee the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) + for more details.\\n\", \"example\": \"file-XjSREls59WBbvgSzJSVWxMCa\", \"nullable\": + true, \"type\": \"string\"}}, \"required\": [\"training_file\"], \"type\": \"object\"}, + \"CreateImageEditRequest\": {\"properties\": {\"image\": {\"description\": \"The + image to edit. Must be a valid PNG file, less than 4MB, and square. If mask + is not provided, image must have transparency, which will be used as the mask.\", + \"format\": \"binary\", \"type\": \"string\"}, \"mask\": {\"description\": \"An + additional image whose fully transparent areas (e.g. where alpha is zero) indicate + where `image` should be edited. Must be a valid PNG file, less than 4MB, and + have the same dimensions as `image`.\", \"format\": \"binary\", \"type\": \"string\"}, + \"n\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/n\"}, + \"prompt\": {\"description\": \"A text description of the desired image(s). + The maximum length is 1000 characters.\", \"example\": \"A cute baby sea otter + wearing a beret\", \"type\": \"string\"}, \"response_format\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/response_format\"}, + \"size\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/size\"}, + \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"prompt\", \"image\"], \"type\": \"object\"}, \"CreateImageRequest\": + {\"properties\": {\"n\": {\"default\": 1, \"description\": \"The number of images + to generate. Must be between 1 and 10.\", \"example\": 1, \"maximum\": 10, \"minimum\": + 1, \"nullable\": true, \"type\": \"integer\"}, \"prompt\": {\"description\": + \"A text description of the desired image(s). The maximum length is 1000 characters.\", + \"example\": \"A cute baby sea otter\", \"type\": \"string\"}, \"response_format\": + {\"default\": \"url\", \"description\": \"The format in which the generated + images are returned. Must be one of `url` or `b64_json`.\", \"enum\": [\"url\", + \"b64_json\"], \"example\": \"url\", \"nullable\": true, \"type\": \"string\"}, + \"size\": {\"default\": \"1024x1024\", \"description\": \"The size of the generated + images. Must be one of `256x256`, `512x512`, or `1024x1024`.\", \"enum\": [\"256x256\", + \"512x512\", \"1024x1024\"], \"example\": \"1024x1024\", \"nullable\": true, + \"type\": \"string\"}, \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"prompt\"], \"type\": \"object\"}, \"CreateImageVariationRequest\": + {\"properties\": {\"image\": {\"description\": \"The image to use as the basis + for the variation(s). Must be a valid PNG file, less than 4MB, and square.\", + \"format\": \"binary\", \"type\": \"string\"}, \"n\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/n\"}, + \"response_format\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/response_format\"}, + \"size\": {\"$ref\": \"#/components/schemas/CreateImageRequest/properties/size\"}, + \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"image\"], \"type\": \"object\"}, \"CreateModerationRequest\": + {\"properties\": {\"input\": {\"description\": \"The input text to classify\", + \"oneOf\": [{\"default\": \"\", \"example\": \"I want to kill them.\", \"type\": + \"string\"}, {\"items\": {\"default\": \"\", \"example\": \"I want to kill them.\", + \"type\": \"string\"}, \"type\": \"array\"}]}, \"model\": {\"default\": \"text-moderation-latest\", + \"description\": \"Two content moderations models are available: `text-moderation-stable` + and `text-moderation-latest`.\\n\\nThe default is `text-moderation-latest` which + will be automatically upgraded over time. This ensures you are always using + our most accurate model. If you use `text-moderation-stable`, we will provide + advanced notice before updating the model. Accuracy of `text-moderation-stable` + may be slightly lower than for `text-moderation-latest`.\\n\", \"example\": + \"text-moderation-stable\", \"nullable\": false, \"type\": \"string\"}}, \"required\": + [\"input\"], \"type\": \"object\"}, \"CreateModerationResponse\": {\"properties\": + {\"id\": {\"type\": \"string\"}, \"model\": {\"type\": \"string\"}, \"results\": + {\"items\": {\"properties\": {\"categories\": {\"properties\": {\"hate\": {\"type\": + \"boolean\"}, \"hate/threatening\": {\"type\": \"boolean\"}, \"self-harm\": + {\"type\": \"boolean\"}, \"sexual\": {\"type\": \"boolean\"}, \"sexual/minors\": + {\"type\": \"boolean\"}, \"violence\": {\"type\": \"boolean\"}, \"violence/graphic\": + {\"type\": \"boolean\"}}, \"required\": [\"hate\", \"hate/threatening\", \"self-harm\", + \"sexual\", \"sexual/minors\", \"violence\", \"violence/graphic\"], \"type\": + \"object\"}, \"category_scores\": {\"properties\": {\"hate\": {\"type\": \"number\"}, + \"hate/threatening\": {\"type\": \"number\"}, \"self-harm\": {\"type\": \"number\"}, + \"sexual\": {\"type\": \"number\"}, \"sexual/minors\": {\"type\": \"number\"}, + \"violence\": {\"type\": \"number\"}, \"violence/graphic\": {\"type\": \"number\"}}, + \"required\": [\"hate\", \"hate/threatening\", \"self-harm\", \"sexual\", \"sexual/minors\", + \"violence\", \"violence/graphic\"], \"type\": \"object\"}, \"flagged\": {\"type\": + \"boolean\"}}, \"required\": [\"flagged\", \"categories\", \"category_scores\"], + \"type\": \"object\"}, \"type\": \"array\"}}, \"required\": [\"id\", \"model\", + \"results\"], \"type\": \"object\"}, \"CreateSearchRequest\": {\"properties\": + {\"documents\": {\"description\": \"Up to 200 documents to search over, provided + as a list of strings.\\n\\nThe maximum document length (in tokens) is 2034 minus + the number of tokens in the query.\\n\\nYou should specify either `documents` + or a `file`, but not both.\\n\", \"example\": \"[''White House'', ''hospital'', + ''school'']\", \"items\": {\"type\": \"string\"}, \"maxItems\": 200, \"minItems\": + 1, \"nullable\": true, \"type\": \"array\"}, \"file\": {\"description\": \"The + ID of an uploaded file that contains documents to search over.\\n\\nYou should + specify either `documents` or a `file`, but not both.\\n\", \"nullable\": true, + \"type\": \"string\"}, \"max_rerank\": {\"default\": 200, \"description\": \"The + maximum number of documents to be re-ranked and returned by search.\\n\\nThis + flag only takes effect when `file` is set.\\n\", \"minimum\": 1, \"nullable\": + true, \"type\": \"integer\"}, \"query\": {\"description\": \"Query to search + against the documents.\", \"example\": \"the president\", \"minLength\": 1, + \"type\": \"string\"}, \"return_metadata\": {\"default\": false, \"description\": + \"A special boolean flag for showing metadata. If set to `true`, each document + entry in the returned JSON will contain a \\\"metadata\\\" field.\\n\\nThis + flag only takes effect when `file` is set.\\n\", \"nullable\": true, \"type\": + \"boolean\"}, \"user\": {\"$ref\": \"#/components/schemas/CreateCompletionRequest/properties/user\"}}, + \"required\": [\"query\"], \"type\": \"object\"}, \"CreateSearchResponse\": + {\"properties\": {\"data\": {\"items\": {\"properties\": {\"document\": {\"type\": + \"integer\"}, \"object\": {\"type\": \"string\"}, \"score\": {\"type\": \"number\"}}, + \"type\": \"object\"}, \"type\": \"array\"}, \"model\": {\"type\": \"string\"}, + \"object\": {\"type\": \"string\"}}, \"type\": \"object\"}, \"CreateTranscriptionRequest\": + {\"additionalProperties\": false, \"properties\": {\"file\": {\"description\": + \"The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, + m4a, wav, or webm.\\n\", \"format\": \"binary\", \"type\": \"string\"}, \"language\": + {\"description\": \"The language of the input audio. Supplying the input language + in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format + will improve accuracy and latency.\\n\", \"type\": \"string\"}, \"model\": {\"description\": + \"ID of the model to use. Only `whisper-1` is currently available.\\n\", \"type\": + \"string\"}, \"prompt\": {\"description\": \"An optional text to guide the model''s + style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) + should match the audio language.\\n\", \"type\": \"string\"}, \"response_format\": + {\"default\": \"json\", \"description\": \"The format of the transcript output, + in one of these options: json, text, srt, verbose_json, or vtt.\\n\", \"type\": + \"string\"}, \"temperature\": {\"default\": 0, \"description\": \"The sampling + temperature, between 0 and 1. Higher values like 0.8 will make the output more + random, while lower values like 0.2 will make it more focused and deterministic. + If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) + to automatically increase the temperature until certain thresholds are hit.\\n\", + \"type\": \"number\"}}, \"required\": [\"file\", \"model\"], \"type\": \"object\"}, + \"CreateTranscriptionResponse\": {\"properties\": {\"text\": {\"type\": \"string\"}}, + \"required\": [\"text\"], \"type\": \"object\"}, \"CreateTranslationRequest\": + {\"additionalProperties\": false, \"properties\": {\"file\": {\"description\": + \"The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, + m4a, wav, or webm.\\n\", \"format\": \"binary\", \"type\": \"string\"}, \"model\": + {\"description\": \"ID of the model to use. Only `whisper-1` is currently available.\\n\", + \"type\": \"string\"}, \"prompt\": {\"description\": \"An optional text to guide + the model''s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) + should be in English.\\n\", \"type\": \"string\"}, \"response_format\": {\"default\": + \"json\", \"description\": \"The format of the transcript output, in one of + these options: json, text, srt, verbose_json, or vtt.\\n\", \"type\": \"string\"}, + \"temperature\": {\"default\": 0, \"description\": \"The sampling temperature, + between 0 and 1. Higher values like 0.8 will make the output more random, while + lower values like 0.2 will make it more focused and deterministic. If set to + 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) + to automatically increase the temperature until certain thresholds are hit.\\n\", + \"type\": \"number\"}}, \"required\": [\"file\", \"model\"], \"type\": \"object\"}, + \"CreateTranslationResponse\": {\"properties\": {\"text\": {\"type\": \"string\"}}, + \"required\": [\"text\"], \"type\": \"object\"}, \"DeleteFileResponse\": {\"properties\": + {\"deleted\": {\"type\": \"boolean\"}, \"id\": {\"type\": \"string\"}, \"object\": + {\"type\": \"string\"}}, \"required\": [\"id\", \"object\", \"deleted\"], \"type\": + \"object\"}, \"DeleteModelResponse\": {\"properties\": {\"deleted\": {\"type\": + \"boolean\"}, \"id\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}}, + \"required\": [\"id\", \"object\", \"deleted\"], \"type\": \"object\"}, \"Engine\": + {\"properties\": {\"created\": {\"nullable\": true, \"type\": \"integer\"}, + \"id\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, \"ready\": + {\"type\": \"boolean\"}}, \"required\": [\"id\", \"object\", \"created\", \"ready\"], + \"title\": \"Engine\"}, \"FineTune\": {\"properties\": {\"created_at\": {\"type\": + \"integer\"}, \"events\": {\"items\": {\"$ref\": \"#/components/schemas/FineTuneEvent\"}, + \"type\": \"array\"}, \"fine_tuned_model\": {\"nullable\": true, \"type\": \"string\"}, + \"hyperparams\": {\"type\": \"object\"}, \"id\": {\"type\": \"string\"}, \"model\": + {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}, \"organization_id\": + {\"type\": \"string\"}, \"result_files\": {\"items\": {\"$ref\": \"#/components/schemas/OpenAIFile\"}, + \"type\": \"array\"}, \"status\": {\"type\": \"string\"}, \"training_files\": + {\"items\": {\"$ref\": \"#/components/schemas/OpenAIFile\"}, \"type\": \"array\"}, + \"updated_at\": {\"type\": \"integer\"}, \"validation_files\": {\"items\": {\"$ref\": + \"#/components/schemas/OpenAIFile\"}, \"type\": \"array\"}}, \"required\": [\"id\", + \"object\", \"created_at\", \"updated_at\", \"model\", \"fine_tuned_model\", + \"organization_id\", \"status\", \"hyperparams\", \"training_files\", \"validation_files\", + \"result_files\"], \"title\": \"FineTune\"}, \"FineTuneEvent\": {\"properties\": + {\"created_at\": {\"type\": \"integer\"}, \"level\": {\"type\": \"string\"}, + \"message\": {\"type\": \"string\"}, \"object\": {\"type\": \"string\"}}, \"required\": + [\"object\", \"created_at\", \"level\", \"message\"], \"title\": \"FineTuneEvent\"}, + \"ImagesResponse\": {\"properties\": {\"created\": {\"type\": \"integer\"}, + \"data\": {\"items\": {\"properties\": {\"b64_json\": {\"type\": \"string\"}, + \"url\": {\"type\": \"string\"}}, \"type\": \"object\"}, \"type\": \"array\"}}, + \"required\": [\"created\", \"data\"]}, \"ListEnginesResponse\": {\"properties\": + {\"data\": {\"items\": {\"$ref\": \"#/components/schemas/Engine\"}, \"type\": + \"array\"}, \"object\": {\"type\": \"string\"}}, \"required\": [\"object\", + \"data\"], \"type\": \"object\"}, \"ListFilesResponse\": {\"properties\": {\"data\": + {\"items\": {\"$ref\": \"#/components/schemas/OpenAIFile\"}, \"type\": \"array\"}, + \"object\": {\"type\": \"string\"}}, \"required\": [\"object\", \"data\"], \"type\": + \"object\"}, \"ListFineTuneEventsResponse\": {\"properties\": {\"data\": {\"items\": + {\"$ref\": \"#/components/schemas/FineTuneEvent\"}, \"type\": \"array\"}, \"object\": + {\"type\": \"string\"}}, \"required\": [\"object\", \"data\"], \"type\": \"object\"}, + \"ListFineTunesResponse\": {\"properties\": {\"data\": {\"items\": {\"$ref\": + \"#/components/schemas/FineTune\"}, \"type\": \"array\"}, \"object\": {\"type\": + \"string\"}}, \"required\": [\"object\", \"data\"], \"type\": \"object\"}, \"ListModelsResponse\": + {\"properties\": {\"data\": {\"items\": {\"$ref\": \"#/components/schemas/Model\"}, + \"type\": \"array\"}, \"object\": {\"type\": \"string\"}}, \"required\": [\"object\", + \"data\"], \"type\": \"object\"}, \"Model\": {\"properties\": {\"created\": + {\"type\": \"integer\"}, \"id\": {\"type\": \"string\"}, \"object\": {\"type\": + \"string\"}, \"owned_by\": {\"type\": \"string\"}}, \"required\": [\"id\", \"object\", + \"created\", \"owned_by\"], \"title\": \"Model\"}, \"OpenAIFile\": {\"properties\": + {\"bytes\": {\"type\": \"integer\"}, \"created_at\": {\"type\": \"integer\"}, + \"filename\": {\"type\": \"string\"}, \"id\": {\"type\": \"string\"}, \"object\": + {\"type\": \"string\"}, \"purpose\": {\"type\": \"string\"}, \"status\": {\"type\": + \"string\"}, \"status_details\": {\"nullable\": true, \"type\": \"object\"}}, + \"required\": [\"id\", \"object\", \"bytes\", \"created_at\", \"filename\", + \"purpose\"], \"title\": \"OpenAIFile\"}}}, \"x-oaiMeta\": {\"groups\": [{\"description\": + \"List and describe the various models available in the API. You can refer to + the [Models](/docs/models) documentation to understand what models are available + and the differences between them.\\n\", \"id\": \"models\", \"title\": \"Models\"}, + {\"description\": \"Given a prompt, the model will return one or more predicted + completions, and can also return the probabilities of alternative tokens at + each position.\\n\", \"id\": \"completions\", \"title\": \"Completions\"}, {\"description\": + \"Given a chat conversation, the model will return a chat completion response.\\n\", + \"id\": \"chat\", \"title\": \"Chat\"}, {\"description\": \"Given a prompt and + an instruction, the model will return an edited version of the prompt.\\n\", + \"id\": \"edits\", \"title\": \"Edits\"}, {\"description\": \"Given a prompt + and/or an input image, the model will generate a new image.\\n\\nRelated guide: + [Image generation](/docs/guides/images)\\n\", \"id\": \"images\", \"title\": + \"Images\"}, {\"description\": \"Get a vector representation of a given input + that can be easily consumed by machine learning models and algorithms.\\n\\nRelated + guide: [Embeddings](/docs/guides/embeddings)\\n\", \"id\": \"embeddings\", \"title\": + \"Embeddings\"}, {\"description\": \"Learn how to turn audio into text.\\n\\nRelated + guide: [Speech to text](/docs/guides/speech-to-text)\\n\", \"id\": \"audio\", + \"title\": \"Audio\"}, {\"description\": \"Files are used to upload documents + that can be used with features like [Fine-tuning](/docs/api-reference/fine-tunes).\\n\", + \"id\": \"files\", \"title\": \"Files\"}, {\"description\": \"Manage fine-tuning + jobs to tailor a model to your specific training data.\\n\\nRelated guide: [Fine-tune + models](/docs/guides/fine-tuning)\\n\", \"id\": \"fine-tunes\", \"title\": \"Fine-tunes\"}, + {\"description\": \"Given a input text, outputs if the model classifies it as + violating OpenAI''s content policy.\\n\\nRelated guide: [Moderations](/docs/guides/moderation)\\n\", + \"id\": \"moderations\", \"title\": \"Moderations\"}, {\"description\": \"Given + a query and a set of documents or labels, the model ranks each document based + on its semantic similarity to the provided query.\\n\\nRelated guide: [Search](/docs/guides/search)\\n\", + \"id\": \"searches\", \"title\": \"Searches\", \"warning\": {\"message\": \"We\\u2019ve + developed new methods with better performance. [Learn more](https://help.openai.com/en/articles/6272952-search-transition-guide).\", + \"title\": \"This endpoint is deprecated and will be removed on December 3rd, + 2022\"}}, {\"description\": \"Given a query and a set of labeled examples, the + model will predict the most likely label for the query. Useful as a drop-in + replacement for any ML classification or text-to-label task.\\n\\nRelated guide: + [Classification](/docs/guides/classifications)\\n\", \"id\": \"classifications\", + \"title\": \"Classifications\", \"warning\": {\"message\": \"We\\u2019ve developed + new methods with better performance. [Learn more](https://help.openai.com/en/articles/6272941-classifications-transition-guide).\", + \"title\": \"This endpoint is deprecated and will be removed on December 3rd, + 2022\"}}, {\"description\": \"Given a question, a set of documents, and some + examples, the API generates an answer to the question based on the information + in the set of documents. This is useful for question-answering applications + on sources of truth, like company documentation or a knowledge base.\\n\\nRelated + guide: [Question answering](/docs/guides/answers)\\n\", \"id\": \"answers\", + \"title\": \"Answers\", \"warning\": {\"message\": \"We\\u2019ve developed new + methods with better performance. [Learn more](https://help.openai.com/en/articles/6233728-answers-transition-guide).\", + \"title\": \"This endpoint is deprecated and will be removed on December 3rd, + 2022\"}}, {\"description\": \"These endpoints describe and provide access to + the various engines available in the API.\", \"id\": \"engines\", \"title\": + \"Engines\", \"warning\": {\"message\": \"Please use their replacement, [Models](/docs/api-reference/models), + instead. [Learn more](https://help.openai.com/TODO).\", \"title\": \"The Engines + endpoints are deprecated.\"}}]}}"}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + Content-Length: + - '112972' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi/importSpecification?api-version=2024-03-01 + response: + body: + string: '' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '0' + date: + - Wed, 29 Nov 2023 00:37:43 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi/operationResults/b86151fd-4624-4a2f-acc6-70a5c131ff4c?api-version=2024-03-01 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-msedge-ref: + - 'Ref A: DE9FB46FEDB047789A4625B6B5763FED Ref B: DM2AA1091211051 Ref C: 2023-11-29T00:37:42Z' + x-powered-by: + - ASP.NET + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi/operationResults/b86151fd-4624-4a2f-acc6-70a5c131ff4c?api-version=2024-03-01 + response: + body: + string: '{"apiName":"default","apiVersion":"1-2-0","catalogName":"contosoeuap","provisioningState":"Succeeded","error":{"message":""}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '125' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:43 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-msedge-ref: + - 'Ref A: FC3AE84FAE2F45A8B607EE3A5AE71298 Ref B: DM2AA1091211051 Ref C: 2023-11-29T00:37:43Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/environments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/environments/cli-test-public","name":"cli-test-public","systemData":{"createdAt":"2023-11-22T16:52:05.746898Z","lastModifiedAt":"2023-11-29T00:37:20.325193Z"},"properties":{"title":"Public + cloud","kind":"development","server":{"type":"Azure API Management","managementPortalUri":["management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service"]},"customProperties":{}}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '691' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:43 GMT + etag: + - 0800337f-0000-3300-0000-656687c00000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"definitionId": "/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi", + "description": "clitestopenaiapi105deployment", "environmentId": "/workspaces/default/environments/cli-test-public", + "server": {"runtimeUri": ["https://api.openai.com/v1"]}, "state": "active", + "title": "clitestopenaiapi105deployment"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic api register + Connection: + - keep-alive + Content-Length: + - '354' + Content-Type: + - application/json + ParameterSetName: + - -g -s --api-location --environment-name + User-Agent: + - AZURECLI/2.53.0 (AAZ) azsdk-python-core/1.26.0 Python/3.8.10 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/deployments/mock-deployment?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services/deployments","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/api-center-test/providers/Microsoft.ApiCenter/services/contosoeuap/workspaces/default/apis/cli-test-openai-api-105/deployments/clitestopenaiapi105deployment","name":"clitestopenaiapi105deployment","systemData":{"createdAt":"2023-11-29T00:37:44.5969176Z","lastModifiedAt":"2023-11-29T00:37:44.5969176Z"},"properties":{"title":"clitestopenaiapi105deployment","description":"clitestopenaiapi105deployment","environmentId":"/workspaces/default/environments/cli-test-public","definitionId":"/workspaces/default/apis/cli-test-openai-api-105/versions/1-2-0/definitions/openapi","server":{"runtimeUri":["https://api.openai.com/v1"]},"customProperties":{},"recommended":false}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01 + cache-control: + - no-cache + content-length: + - '792' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 29 Nov 2023 00:37:44 GMT + etag: + - 0c00fd9a-0000-3300-0000-656687d80000 + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/test_apic_extension.py b/src/apic-extension/azext_apic_extension/tests/latest/test_apic_extension.py new file mode 100644 index 00000000000..6dacb2e995a --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/test_apic_extension.py @@ -0,0 +1,266 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * +import unittest + + +class ApicExtensionScenario(ScenarioTest): + + @unittest.skip('Test account does not have permissions to create service') + def test_apic_scenarios(self): + + # create service - TODO in future. Use fixed service for now + + #parameters for common use + from datetime import datetime + self.kwargs.update({ + 'resource_group': 'api-center-test', + 'service_name': 'contosoeuap', + 'api_name': 'cli-test-api-106', + 'api_version': 'cli-test-2023-01-02', + 'api_definition_name': 'cli-test-openapi-106', + }) + + # ------------------------------------------- Environment ------------------------------------------- + # create environment + server_details = { + "type": "Azure API Management", + "managementPortalUri": [ + "management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service-0" + ] + } + self.kwargs.update({ + 'server_details': server_details, + 'environment_name': 'cli-test-public' + }) + self.cmd('az apic environment create -g {resource_group} -s {service_name} --name {environment_name} --title "Public cloud" --kind "development" --server "{server_details}"', + checks=[ + self.check('name', self.kwargs['environment_name']), + self.check('title', 'Public cloud'), + self.check('kind', 'development')]) + + # update environment + server_details = { + "type": "Azure API Management", + "managementPortalUri": [ + "management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ApiManagement/service/my-api-management-service" + ] + } + self.kwargs.update({ + 'server_details': server_details, + }) + self.cmd('az apic environment update -g {resource_group} -s {service_name} --name {environment_name} --title "Public cloud" --kind "development" --server "{server_details}" -w default', + checks=[ + self.check('name', self.kwargs['environment_name']), + self.check('title', 'Public cloud'), + self.check('kind', 'development'), + self.check('server', self.kwargs['server_details'])]) + + # show environment + self.cmd('az apic environment show -g {resource_group} -s {service_name} --name {environment_name}', + checks=[ + self.check('name', self.kwargs['environment_name']), + self.check('title', 'Public cloud'), + self.check('kind', 'development')]) + + # list environment + list_env_reult = self.cmd('az apic environment list -g {resource_group} -s {service_name}') + + # ------------------------------------------- API ------------------------------------------- + # create api + self.kwargs.update({ + 'api_description': "CLI Test API 106", + 'api_title': "CLI Test API 106" + }) + self.cmd('az apic api create -g {resource_group} -s {service_name} --api-name {api_name} --description "{api_description}" --kind rest --title "{api_title}"', + checks=[ + self.check('name', self.kwargs['api_name']), + self.check('title', self.kwargs['api_title']), + self.check('description', self.kwargs['api_description']), + self.check('kind', 'rest')]) + + # show api + self.cmd('az apic api show -g {resource_group} -s {service_name} --api-name {api_name}', + checks=[ + self.check('name', self.kwargs['api_name']), + self.check('title', self.kwargs['api_title']), + self.check('description', self.kwargs['api_description']), + self.check('kind', 'rest')]) + + # list api + list_api_result = self.cmd('az apic api list -g {resource_group} -s {service_name}') + + + # ------------------------------------------- API Version ------------------------------------------- + # create api version + self.cmd('az apic api version create -g {resource_group} -s {service_name} --api-name {api_name} --name {api_version} --title {api_version}') + + # update api version + self.kwargs.update({ + 'api_version_title_update': "CLI Test API Version 0" + }) + self.cmd('az apic api version update -g {resource_group} -s {service_name} --api-name {api_name} --name {api_version} --title "{api_version_title_update}" -w default', + checks=[ + self.check('name', self.kwargs['api_version']), + self.check('title', self.kwargs['api_version_title_update'])]) + + # show api version + self.cmd('az apic api version show -g {resource_group} -s {service_name} --api-name {api_name} --name {api_version}', + checks=[ + self.check('name', self.kwargs['api_version']), + self.check('title', self.kwargs['api_version_title_update'])]) + + # list api version + list_api_version_result = self.cmd('az apic api version list -g {resource_group} -s {service_name} --api-name {api_name}') + + + # ------------------------------------------- API Definition ------------------------------------------- + + # create api definition + self.cmd('az apic api definition create -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version} --name {api_definition_name} --title "OpenAPI" ') + + # update api definition + self.kwargs.update({ + 'api_definition_title_update': "CLI Test API Definition 0" + }) + self.cmd('az apic api definition update -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version} --name {api_definition_name} --title "{api_definition_title_update}" -w default', + checks=[ + self.check('name', self.kwargs['api_definition_name']), + self.check('title', self.kwargs['api_definition_title_update'])]) + + # show api definition + self.cmd('az apic api definition show -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version} --name {api_definition_name}', + checks=[ + self.check('name', self.kwargs['api_definition_name']), + self.check('title', self.kwargs['api_definition_title_update'])]) + + # list api definition + list_api_definition_result = self.cmd('az apic api definition list -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version}') + + #------------------------------------------------ Import Specification ------------------------------------------- + # import specification + import os + TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + templateFile = os.path.join( + TEST_DIR, + "data", + "import_spec_payload.json", + ) + specification_details = '{"name":"openapi","version":"3.0.0"}' + self.kwargs.update({ + 'templateFile': templateFile, + 'specification_details': specification_details + }) + self.cmd('az apic api definition import-specification -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version} --name {api_definition_name} --format inline --specification {specification_details} --file-name "{templateFile}"') + + # export specification + templateOutputFile = os.path.join( + TEST_DIR, + "data", + "exported_spec.json", + ) + self.kwargs.update({ + 'templateFile': templateOutputFile + }) + self.cmd('az apic api definition export-specification -g {resource_group} -s {service_name} --api-name {api_name} --version {api_version} --name {api_definition_name} --file-name "{templateFile}"') + + # ------------------------------------------- Deployment ------------------------------------------- + + # create deployment + environment_id = "/workspaces/default/environments/"+self.kwargs['environment_name'] + definition_id = "/workspaces/default/apis/"+self.kwargs['api_name']+"/versions/"+self.kwargs['api_version']+"/definitions/"+self.kwargs['api_definition_name'] + server = {"runtime-uri": ["https://api.contoso.com"]} + self.kwargs.update({ + 'environment_id': environment_id, + 'definition_id' : definition_id, + 'deployment_name': 'production', + 'server': server, + }) + self.cmd('az apic api deployment create -g {resource_group} -s {service_name} --api-name {api_name} --name {deployment_name} --title "CLI Test Production deployment" --description "CLI Test Public cloud production deployment." --environment-id {environment_id} --definition-id {definition_id} --server "{server}"', + checks=[ + self.check('name', self.kwargs['deployment_name']), + self.check('title', 'CLI Test Production deployment'), + self.check('description', 'CLI Test Public cloud production deployment.')]) + + # show deployment + self.cmd('az apic api deployment show -g {resource_group} -s {service_name} --api-name {api_name} --name {deployment_name}', + checks=[ + self.check('name', self.kwargs['deployment_name'])]) + + # update deployment + self.kwargs.update({ + 'deployment_title_update': 'CLI Test Production deployment update' + }) + self.cmd('az apic api deployment update -g {resource_group} -s {service_name} --api-name {api_name} --name {deployment_name} --title "{deployment_title_update}" -w default', + checks=[ + self.check('name', self.kwargs['deployment_name']), + self.check('title', self.kwargs['deployment_title_update'])]) + + # list deployment + list_deployment_result = self.cmd('az apic api deployment list -g {resource_group} -s {service_name} --api-name {api_name}') + + # ------------------------------------------- Metadata Schema ------------------------------------------- + # create metadata schema + templateInputSchemaFile = os.path.join( + TEST_DIR, + "data", + "import_metadataschema_input.json", + ) + self.kwargs.update({ + 'schemaName': 'cli-test-metadata-schema-1', + 'templateFile': templateInputSchemaFile + + }) + self.cmd('az apic metadata-schema create -g {resource_group} -s {service_name} --name {schemaName} --file-name "{templateFile}"') + + # export metadata schema + templateOutputApiSchemaFile = os.path.join( + TEST_DIR, + "data", + "exported_md_schema_api.json", + ) + templateOutputDeploymentSchemaFile = os.path.join( + TEST_DIR, + "data", + "exported_md_schema_deployment.json", + ) + templateOutputEnvSchemaFile = os.path.join( + TEST_DIR, + "data", + "exported_md_schema_env.json", + ) + self.kwargs.update({ + 'templateFileApi': templateOutputApiSchemaFile, + 'templateFileDeployment': templateOutputDeploymentSchemaFile, + 'templateFileEnvironment': templateOutputEnvSchemaFile + }) + self.cmd('az apic metadata-schema export-metadata-schema -g {resource_group} -s {service_name} --assigned-to api --file-name "{templateFileApi}"') + self.cmd('az apic metadata-schema export-metadata-schema -g {resource_group} -s {service_name} --assigned-to deployment --file-name "{templateFileDeployment}"') + self.cmd('az apic metadata-schema export-metadata-schema -g {resource_group} -s {service_name} --assigned-to environment --file-name "{templateFileEnvironment}"') + + # show metadata schema + self.kwargs.update({ + 'schemaName': 'cli-test-metadata-schema-1' + }) + self.cmd('az apic metadata-schema show -g {resource_group} -s {service_name} --name {schemaName}', + checks=[ + self.check('name', self.kwargs['schemaName'])]) + + + # ------------------------------------------- Quick Add ------------------------------------------- + # register api - quick add + templateQuickAddFile = os.path.join( + TEST_DIR, + "data", + "register_quickadd_openai_spec.json", + ) + self.kwargs.update({ + 'templateFile': templateQuickAddFile, + 'environment_name': self.kwargs['environment_name'] + }) + self.cmd('az apic api register -g {resource_group} -s {service_name} --api-location "{templateFile}" --environment-name {environment_name}') \ No newline at end of file diff --git a/src/apic-extension/setup.cfg b/src/apic-extension/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/apic-extension/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/apic-extension/setup.py b/src/apic-extension/setup.py new file mode 100644 index 00000000000..01b070c19d8 --- /dev/null +++ b/src/apic-extension/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# 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 aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# 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', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +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='apic-extension', + version=VERSION, + description='Microsoft Azure Command-Line Tools ApicExtension Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/apic-extension', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_apic_extension': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +) diff --git a/src/service_name.json b/src/service_name.json index 0ef9770fb6a..492b87269fd 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -39,6 +39,11 @@ "AzureServiceName": "Azure Operator Service Manager", "URL": "https://learn.microsoft.com/azure/operator-service-manager" }, + { + "Command": "az apic", + "AzureServiceName": "ApiCenter Services", + "URL": "https://learn.microsoft.com/en-us/azure/api-center" + }, { "Command": "az appservice", "AzureServiceName": "App Services",