|
Add this skill
npx mdskills install sickn33/azure-mgmt-apicenter-pyComprehensive SDK reference with clear examples but lacks agent-specific triggers and instructions
1---2name: azure-mgmt-apicenter-py3description: |4 Azure API Center Management SDK for Python. Use for managing API inventory, metadata, and governance across your organization.5 Triggers: "azure-mgmt-apicenter", "ApiCenterMgmtClient", "API Center", "API inventory", "API governance".6package: azure-mgmt-apicenter7---89# Azure API Center Management SDK for Python1011Manage API inventory, metadata, and governance in Azure API Center.1213## Installation1415```bash16pip install azure-mgmt-apicenter17pip install azure-identity18```1920## Environment Variables2122```bash23AZURE_SUBSCRIPTION_ID=your-subscription-id24```2526## Authentication2728```python29from azure.identity import DefaultAzureCredential30from azure.mgmt.apicenter import ApiCenterMgmtClient31import os3233client = ApiCenterMgmtClient(34 credential=DefaultAzureCredential(),35 subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]36)37```3839## Create API Center4041```python42from azure.mgmt.apicenter.models import Service4344api_center = client.services.create_or_update(45 resource_group_name="my-resource-group",46 service_name="my-api-center",47 resource=Service(48 location="eastus",49 tags={"environment": "production"}50 )51)5253print(f"Created API Center: {api_center.name}")54```5556## List API Centers5758```python59api_centers = client.services.list_by_subscription()6061for api_center in api_centers:62 print(f"{api_center.name} - {api_center.location}")63```6465## Register an API6667```python68from azure.mgmt.apicenter.models import Api, ApiKind, LifecycleStage6970api = client.apis.create_or_update(71 resource_group_name="my-resource-group",72 service_name="my-api-center",73 workspace_name="default",74 api_name="my-api",75 resource=Api(76 title="My API",77 description="A sample API for demonstration",78 kind=ApiKind.REST,79 lifecycle_stage=LifecycleStage.PRODUCTION,80 terms_of_service={"url": "https://example.com/terms"},81 contacts=[{"name": "API Team", "email": "api-team@example.com"}]82 )83)8485print(f"Registered API: {api.title}")86```8788## Create API Version8990```python91from azure.mgmt.apicenter.models import ApiVersion, LifecycleStage9293version = client.api_versions.create_or_update(94 resource_group_name="my-resource-group",95 service_name="my-api-center",96 workspace_name="default",97 api_name="my-api",98 version_name="v1",99 resource=ApiVersion(100 title="Version 1.0",101 lifecycle_stage=LifecycleStage.PRODUCTION102 )103)104105print(f"Created version: {version.title}")106```107108## Add API Definition109110```python111from azure.mgmt.apicenter.models import ApiDefinition112113definition = client.api_definitions.create_or_update(114 resource_group_name="my-resource-group",115 service_name="my-api-center",116 workspace_name="default",117 api_name="my-api",118 version_name="v1",119 definition_name="openapi",120 resource=ApiDefinition(121 title="OpenAPI Definition",122 description="OpenAPI 3.0 specification"123 )124)125```126127## Import API Specification128129```python130from azure.mgmt.apicenter.models import ApiSpecImportRequest, ApiSpecImportSourceFormat131132# Import from inline content133client.api_definitions.import_specification(134 resource_group_name="my-resource-group",135 service_name="my-api-center",136 workspace_name="default",137 api_name="my-api",138 version_name="v1",139 definition_name="openapi",140 body=ApiSpecImportRequest(141 format=ApiSpecImportSourceFormat.INLINE,142 value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {}}'143 )144)145```146147## List APIs148149```python150apis = client.apis.list(151 resource_group_name="my-resource-group",152 service_name="my-api-center",153 workspace_name="default"154)155156for api in apis:157 print(f"{api.name}: {api.title} ({api.kind})")158```159160## Create Environment161162```python163from azure.mgmt.apicenter.models import Environment, EnvironmentKind164165environment = client.environments.create_or_update(166 resource_group_name="my-resource-group",167 service_name="my-api-center",168 workspace_name="default",169 environment_name="production",170 resource=Environment(171 title="Production",172 description="Production environment",173 kind=EnvironmentKind.PRODUCTION,174 server={"type": "Azure API Management", "management_portal_uri": ["https://portal.azure.com"]}175 )176)177```178179## Create Deployment180181```python182from azure.mgmt.apicenter.models import Deployment, DeploymentState183184deployment = client.deployments.create_or_update(185 resource_group_name="my-resource-group",186 service_name="my-api-center",187 workspace_name="default",188 api_name="my-api",189 deployment_name="prod-deployment",190 resource=Deployment(191 title="Production Deployment",192 description="Deployed to production APIM",193 environment_id="/workspaces/default/environments/production",194 definition_id="/workspaces/default/apis/my-api/versions/v1/definitions/openapi",195 state=DeploymentState.ACTIVE,196 server={"runtime_uri": ["https://api.example.com"]}197 )198)199```200201## Define Custom Metadata202203```python204from azure.mgmt.apicenter.models import MetadataSchema205206metadata = client.metadata_schemas.create_or_update(207 resource_group_name="my-resource-group",208 service_name="my-api-center",209 metadata_schema_name="data-classification",210 resource=MetadataSchema(211 schema='{"type": "string", "title": "Data Classification", "enum": ["public", "internal", "confidential"]}'212 )213)214```215216## Client Types217218| Client | Purpose |219|--------|---------|220| `ApiCenterMgmtClient` | Main client for all operations |221222## Operations223224| Operation Group | Purpose |225|----------------|---------|226| `services` | API Center service management |227| `workspaces` | Workspace management |228| `apis` | API registration and management |229| `api_versions` | API version management |230| `api_definitions` | API definition management |231| `deployments` | Deployment tracking |232| `environments` | Environment management |233| `metadata_schemas` | Custom metadata definitions |234235## Best Practices2362371. **Use workspaces** to organize APIs by team or domain2382. **Define metadata schemas** for consistent governance2393. **Track deployments** to understand where APIs are running2404. **Import specifications** to enable API analysis and linting2415. **Use lifecycle stages** to track API maturity2426. **Add contacts** for API ownership and support243
Full transparency — inspect the skill content before installing.