diff --git a/.github/styles/base/Dictionary.txt b/.github/styles/base/Dictionary.txt index df37ddefc9..ef0725557a 100644 --- a/.github/styles/base/Dictionary.txt +++ b/.github/styles/base/Dictionary.txt @@ -903,6 +903,7 @@ ungrouped Unicode unicode unix +unlinking unmanaged unmarshalled unnamespaced diff --git a/app/_data/schemas/frontmatter/tags.json b/app/_data/schemas/frontmatter/tags.json index 1e1aa6e4f2..ec23d501f9 100644 --- a/app/_data/schemas/frontmatter/tags.json +++ b/app/_data/schemas/frontmatter/tags.json @@ -12,6 +12,7 @@ "analytics", "anthropic", "api-catalog", + "api-composition", "api-products", "apiops", "application-registration", diff --git a/app/_how-tos/automate-api-catalog-with-terraform.md b/app/_how-tos/automate-api-catalog-with-terraform.md index 46bacd49b9..7ab75bfc89 100644 --- a/app/_how-tos/automate-api-catalog-with-terraform.md +++ b/app/_how-tos/automate-api-catalog-with-terraform.md @@ -36,6 +36,8 @@ related_resources: url: /dev-portal/application-registration/ - text: Application authentication strategies url: /dev-portal/auth-strategies/ + - text: Package APIs with Dev Portal + url: /how-to/package-apis-with-dev-portal/ prereqs: skip_product: true inline: @@ -110,6 +112,8 @@ faqs: next_steps: - text: Apply an authentication strategy to your APIs url: /dev-portal/auth-strategies/ + - text: Create API packages + url: /catalog/api-packaging/ --- ## Create an API diff --git a/app/_how-tos/automate-api-catalog.md b/app/_how-tos/automate-api-catalog.md index 49be951d21..e7dedef924 100644 --- a/app/_how-tos/automate-api-catalog.md +++ b/app/_how-tos/automate-api-catalog.md @@ -52,6 +52,8 @@ related_resources: url: /dev-portal/application-registration/ - text: Application authentication strategies url: /dev-portal/auth-strategies/ + - text: Package APIs with Dev Portal + url: /how-to/package-apis-with-dev-portal/ faqs: - q: I just edited or deleted my spec, document, page, or snippet. Why don't I immediately see these changes live in the Dev Portal? a: If you recently viewed the related content, your browser might be serving a cached version of the page. To fix this, you can clear your browser cache and refresh the page. @@ -68,6 +70,8 @@ faqs: next_steps: - text: Apply an authentication strategy to your APIs url: /dev-portal/auth-strategies/ + - text: Create API packages + url: /catalog/api-packaging/ --- ## Create an API diff --git a/app/_how-tos/discover-and-govern-apis-with-service-catalog.md b/app/_how-tos/discover-and-govern-apis-with-service-catalog.md index b1a9e8d70d..41cf9a440f 100644 --- a/app/_how-tos/discover-and-govern-apis-with-service-catalog.md +++ b/app/_how-tos/discover-and-govern-apis-with-service-catalog.md @@ -21,6 +21,8 @@ related_resources: url: /catalog/integrations/ - text: AWS API Gateway reference url: /catalog/integrations/aws-api-gateway/ + - text: Package APIs with Dev Portal + url: /how-to/package-apis-with-dev-portal/ automated_tests: false tldr: q: How do I discover and govern third-party APIs in {{site.konnect_short_name}}? diff --git a/app/_how-tos/package-apis-with-dev-portal.md b/app/_how-tos/package-apis-with-dev-portal.md new file mode 100644 index 0000000000..899f54f069 --- /dev/null +++ b/app/_how-tos/package-apis-with-dev-portal.md @@ -0,0 +1,323 @@ +--- +title: "Package APIs with Dev Portal" +description: "Learn how to compose existing APIs in Dev Portal into API packages." +content_type: how_to +related_resources: + - text: About Dev Portal + url: /dev-portal/ + - text: API packaging reference + url: /catalog/api-packaging/ +automated_tests: false +products: + - dev-portal + - gateway + - catalog +min_version: + gateway: '3.13' +works_on: + - konnect +tools: + - deck +tags: + - api-catalog + - api-composition + +tldr: + q: How do I create API packages from existing Dev Portal APIs? + a: | + Packaging APIs involves the following steps: + 1. Create an API and attach an OpenAPI spec. + 1. Apply the Access Control Enforcement (ACE) plugin globally on the control plane you want to link. + 1. Link a control plane to the API to allow developer consumption. + 1. Create an API package by adding operations and package rate limits. + 1. Publish the API package to Dev Portal. +prereqs: + inline: + - title: "{{site.konnect_short_name}} roles" + content: | + To recover create API packages, you need the following [roles](/konnect-platform/teams-and-roles/): + * Editor role for APIs + * Publisher role for the API and API package + * API Creator + icon_url: /assets/icons/gateway.svg + - title: Dev Portal + include_content: prereqs/dev-portal-create-ui + icon_url: /assets/icons/dev-portal.svg + - title: Dev Portal APIs + content: | + To complete this guide, you'll need an API in Catalog: + 1. In the {{site.konnect_short_name}} sidebar, click **Catalog**. + 1. Click [**New API**](https://cloud.konghq.com/apis/create). + 1. In the **API name** field, enter `MyAPI`. + 1. Click **Create**. + icon_url: /assets/icons/dev-portal.svg + - title: Required entities + content: | + For this tutorial, you’ll need {{site.base_gateway}} entities, like Gateway Services and Routes, pre-configured. These entities are essential for {{site.base_gateway}} to function but installing them isn’t the focus of this guide. + + 1. Run the following command: + + ```yaml + echo ' + _format_version: "3.0" + services: + - name: example-service + url: http://httpbin.konghq.com/anything + routes: + - name: example-route + paths: + - "/anything" + methods: + - GET + - PUT + - POST + - PATCH + - DELETE + service: + name: example-service + ' | deck gateway apply - + ``` + + To learn more about entities, you can read our [entities documentation](/gateway/entities/). + - title: API specification + content: | + To complete this guide, you'll need an API specification that matches the Route you created. {{site.konnect_catalog}} uses the spec to add operations to your API package. + + ```sh + cat > example-api-spec.yaml << 'EOF' + openapi: 3.0.0 + info: + title: Example API + description: Example API service for testing and documentation + version: 1.0.0 + + servers: + - url: http://httpbin.konghq.com + description: Backend service (HTTP only, port 80) + + paths: + /anything: + get: + summary: Get anything + description: Echo back GET request details + operationId: getAnything + tags: + - Echo + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/EchoResponse' + '426': + description: Upgrade Required (HTTPS redirect) + + post: + summary: Post anything + description: Echo back POST request details + operationId: postAnything + tags: + - Echo + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: true + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/EchoResponse' + '426': + description: Upgrade Required (HTTPS redirect) + + put: + summary: Put anything + description: Echo back PUT request details + operationId: putAnything + tags: + - Echo + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: true + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/EchoResponse' + '426': + description: Upgrade Required (HTTPS redirect) + + patch: + summary: Patch anything + description: Echo back PATCH request details + operationId: patchAnything + tags: + - Echo + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: true + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/EchoResponse' + '426': + description: Upgrade Required (HTTPS redirect) + + delete: + summary: Delete anything + description: Echo back DELETE request details + operationId: deleteAnything + tags: + - Echo + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/EchoResponse' + '426': + description: Upgrade Required (HTTPS redirect) + + components: + schemas: + EchoResponse: + type: object + properties: + args: + type: object + description: Query parameters + data: + type: string + description: Request body data + files: + type: object + description: Uploaded files + form: + type: object + description: Form data + headers: + type: object + description: Request headers + json: + type: object + description: JSON request body + method: + type: string + description: HTTP method used + origin: + type: string + description: Origin IP address + url: + type: string + description: Request URL + + x-kong-service: + name: example-service + host: httpbin.konghq.com + port: 80 + protocol: http + path: /anything + retries: 5 + connect_timeout: 60000 + write_timeout: 60000 + read_timeout: 60000 + + x-kong-route: + name: example-route + protocols: [http, https] + methods: [GET, POST, PUT, PATCH, DELETE] + paths: [/anything] + strip_path: true + preserve_host: false + https_redirect_status_code: 426 + EOF + ``` + icon_url: /assets/icons/dev-portal.svg + + +cleanup: + inline: + - title: Clean up {{site.konnect_short_name}} environment + include_content: cleanup/platform/konnect + icon_url: /assets/icons/gateway.svg +--- + +You can compose [API packages](/catalog/api-packaging/) from existing APIs in Dev Portal. API packages allow you to: +* Create distinct APIs for specific use cases or partners based on existing API operations. +* Link to multiple Gateway Services and/or Routes for developer self-service and application registration. +* Apply rate limiting policies to an API Package, or per operation. +* Manage role-based access control for specific developers and teams. + +## Associate a control plane + +To allow developers to consume your API, you must first link an API Gateway and control plane to your API. + +Operations from your API's OpenAPI spec should overlap with Routes to ensure requests will be routed to the correct Service. Gateway routing configuration isn't directly modified by adding operations. +1. In the {{site.konnect_short_name}} sidebar, click [**Catalog**](https://cloud.konghq.com/apis/). +1. Click **MyAPI**. +1. Click the **Gateway** tab. +1. Click **Link gateway**. +1. From the **Control plane** dropdown menu, select "quickstart". +1. Select **Link to a control plane**. +1. In the Add the Access Control and Enforcement plugin settings, click **Add plugin**. +1. Click **Link gateway**. +1. Click the **API Specification** tab. +1. Click **Upload Spec**. +1. Click **Select file**. +1. Select `example-api-spec.yaml`. +1. Click **Save**. + +## Assign operations to API packages + +Now, you can create an API package by picking operations from your API. Operations are automatically mapped to Routes using your API's OpenAPI spec. The Gateway configuration isn't directly modified – any unmatched operations will be highlighted to indicate that a user needs Gateway Manager permissions to perform an action. + +1. In the {{site.konnect_short_name}} sidebar, click **Catalog**. +1. Click the **API packages** tab. +1. Click **Create API package**. +1. In the **API package name** field, enter `Company package`. +1. Enable the Package rate limit. +1. For the rate limit, enter `5` and select "Minute". +1. In the API operations settings, click **Add operations from APIs**. +1. In the Add API operations pane, click **MyAPI** +1. For GET `/anything`, click **Add**. +1. For PUT `/anything`, click **Add**. +1. For POST `/anything`, click **Add**. +1. Exit the Add API operations pane. +1. Click **Create API package**. +1. Click the **Specifications** tab. +1. Click **Generate spec from operations**. +1. Click **Save**. + +## Publish API packages to Dev Portal +Now you can make the API packages available to developers by publishing them to a Dev Portal. +1. In the {{site.konnect_short_name}} sidebar, click **Catalog**. +1. Click the **API packages** tab. +1. Click **Company package**. +1. Click **Publish API**. +1. From the **Portal** dropdown menu, select your Dev Portal. +1. From the **Authentication strategy** dropdown menu, select "Disabled". +1. Click **Public**. +1. Click **Publish API**. + +Your API package will now be published to your Dev Portal. Published API packages appear the same as published APIs in the Dev Portal, and both allow developers to register applications with them. + +## Validate + +Now that you've published your API package, you can verify that it was successfully published by navigating to your Dev Portal's URL. You can find your Dev Portal's URL by navigating to the [Dev Portal overview](https://cloud.konghq.com/portals/) in the {{site.konnect_short_name}} UI. \ No newline at end of file diff --git a/app/_includes/plugins/ace/ace-overview.md b/app/_includes/plugins/ace/ace-overview.md new file mode 100644 index 0000000000..05e4883371 --- /dev/null +++ b/app/_includes/plugins/ace/ace-overview.md @@ -0,0 +1,10 @@ +The Access Control Enforcement (ACE) plugin manages developer access control to APIs published with Dev Portal. + +Previously, when you created an API catalog in Dev Portal and linked the APIs to a Gateway Service, {{site.konnect_short_name}} would automatically apply the {{site.konnect_short_name}} application auth (KAA) plugin. +API packages use the ACE plugin instead to manage developer access control to APIs. Unlike the KAA plugin, the ACE plugin can link to control planes to configure access control and create operations for Gateway Services. + +The ACE plugin runs *after* all other [authentication plugins](/plugins/?category=authentication) run. +For example, if you have [Key Authentication](/plugins/key-auth/) configured and it rejects a request, the ACE plugin *will not* run. + +To allow for multiple authentication plugins, each one must set the [`config.anonymous`](/plugins/ace/reference/#schema--config-anonymous) plugin configuration. +Additionally, the choice to allow or reject an `anonymous` result after all authentication plugins have run needs to be controlled as described in [using multiple authentication methods](/gateway/authentication/#using-multiple-authentication-methods). \ No newline at end of file diff --git a/app/_includes/plugins/ace/ace-route-matching.md b/app/_includes/plugins/ace/ace-route-matching.md new file mode 100644 index 0000000000..ea27cbf70f --- /dev/null +++ b/app/_includes/plugins/ace/ace-route-matching.md @@ -0,0 +1,40 @@ +When you configure the ACE plugin, you must set either `required` or `present` for [`config.match_policy`](/plugins/ace/reference/#schema--config-match-policy). This determines how the ACE plugin will behave when a request doesn't match an existing Route. + +Keep in mind that misconfigurations can overexpose unintended Routes. + +The following table describes what the `match_policy` values do and when to use each: +{% table %} +columns: + - title: Setting + key: setting + - title: Description + key: description + - title: Limitations + key: limitations + - title: Use cases + key: use-case +rows: + - setting: | + `required` + description: | + Requires every incoming request to match a defined operation from an API or API package in Dev Portal. If a request doesn't match, ACE rejects the request outright with a 404. All traffic will be rejected except operations or Routes in published APIs linked to an ACE-enabled {{site.base_gateway}}. + + {:.danger} + > **Warning:** Setting the [`match_policy`](/plugins/ace/reference/#schema--config-match-policy) to `required` can **block all traffic with a 404**. Any undefined endpoints will be blocked. If you accidentally enable this in your control planes, this could cause a potential outage in production. + limitations: | + * Shuts down all traffic outside of ACE-enabled Dev Portal APIs. + * If the plugin is improperly configured, potentially all traffic could be terminated. + use-case: | + * You want to lock down {{site.konnect_short_name}} so that only traffic that is part of an explicitly defined API operation is allowed through. + * You only plan to provide self-service access via your Dev Portal. + - setting: | + `if_present` + description: | + By default, the ACE plugin only engages with a request when it matches an operation. If a request doesn't match, ACE lets the request pass through untouched. This means that non-matching requests aren't rejected, but ACE also won't perform authentication and authorization on them. This allows a request to still be processed by other plugins with a [lower priority](/gateway/entities/plugin/#plugin-priority) than ACE. + limitations: | + * All traffic outside of published APIs linked to an ACE-enabled {{site.base_gateway}} won't be access controlled; this must be configured with a [different authentication plugin](/plugins/?category=authentication). Dev Portal will not be able to protect all operations. + * Since Routes aren't protected by default in this mode, any mistyped or omitted operation in API entities could result in open access. + use-case: | + * You have an environment where some Gateway Services or Routes are governed by Dev Portal–exposed APIs (with ACE), while others are regular Routes that should be left alone. + * You already have existing traffic and other access controls in place and want to avoid interruption. +{% endtable %} \ No newline at end of file diff --git a/app/_includes/prereqs/dev-portal-create-ui.md b/app/_includes/prereqs/dev-portal-create-ui.md new file mode 100644 index 0000000000..b7bfce4d88 --- /dev/null +++ b/app/_includes/prereqs/dev-portal-create-ui.md @@ -0,0 +1,8 @@ +For this tutorial, you’ll need a Dev Portal pre-configured. If you don't have these settings already configured, follow these steps to pre-configure it: + +1. In the {{site.konnect_short_name}} sidebar, click **Dev Portal**. +1. Click [**New portal**](https://cloud.konghq.com/portals/create). +1. Enter a name for your Dev Portal. +1. Click **Create and continue**. +1. Customize your Dev Portal's appearance. +1. Click **Save**. \ No newline at end of file diff --git a/app/_indices/catalog.yaml b/app/_indices/catalog.yaml index b2b437980d..59ba0e632a 100644 --- a/app/_indices/catalog.yaml +++ b/app/_indices/catalog.yaml @@ -6,9 +6,11 @@ sections: - title: APIs items: - path: /service-catalog/apis/ + - path: /catalog/api-packaging/ - path: /how-to/automate-api-catalog/ - path: /how-to/automate-api-catalog-with-terraform/ - path: /how-to/discover-and-govern-apis-with-service-catalog/ + - path: /how-to/package-apis-with-dev-portal/ - title: Services and scorecards items: - path: /catalog/scorecards/ diff --git a/app/_indices/dev-portal.yaml b/app/_indices/dev-portal.yaml index 86db3c15d4..2c002703e7 100644 --- a/app/_indices/dev-portal.yaml +++ b/app/_indices/dev-portal.yaml @@ -12,8 +12,10 @@ sections: - title: API catalog items: - path: /catalog/apis/ + - path: /catalog/api-packaging/ - path: /how-to/automate-api-catalog/ - path: /how-to/automate-api-catalog-with-terraform/ + - path: /how-to/package-apis-with-dev-portal/ - title: Application registration items: - title: Developer sign-up diff --git a/app/_kong_plugins/ace/index.md b/app/_kong_plugins/ace/index.md index 160f9979ff..c7f05a215b 100644 --- a/app/_kong_plugins/ace/index.md +++ b/app/_kong_plugins/ace/index.md @@ -40,51 +40,8 @@ related_resources: {:.warning} > **Important:** The Access Control Enforcement plugin can only be used with APIs that are linked to a control plane, which is a private beta feature. Contact your account manager for access. -The Access Control Enforcement (ACE) plugin manages developer access control to APIs published with Dev Portal. - -Previously, when you created an API catalog in Dev Portal and linked the APIs to a Gateway Service, {{site.konnect_short_name}} would automatically apply the {{site.konnect_short_name}} application auth (KAA) plugin automatically. API packages uses the ACE plugin instead to manage developer access control to APIs. Unlike the KAA plugin, the ACE plugin can link to control planes to configure access control and create operations for Gateway Services in those control planes. - -The ACE plugin runs *after* all other [authentication plugins](/plugins/?category=authentication) run. For example, if you have [Key Authentication](/plugins/key-auth/) configured and it rejects a request, the ACE plugin *will not* run. To allow for multiple authentication plugins, each must set the [`config.anonymous`](/plugins/ace/reference/#schema--config-anonymous) plugin configuration. Additionally, the choice to allow or reject an `anonymous` result after all authentication plugins have run needs to be controlled as described in [using multiple authentication methods](/gateway/authentication/#using-multiple-authentication-methods). +{% include /plugins/ace/ace-overview.md %} ## Route matching policy -When you configure the ACE plugin, you must set either `required` or `present` for [`config.match_policy`](/plugins/ace/reference/#schema--config-match-policy). This determines how the ACE plugin will behave when a request doesn't match an existing Route. - -Keep in mind that misconfigurations can overexpose unintended Routes. - -The following table describes what the `match_policy` values do and when to use each: -{% table %} -columns: - - title: Setting - key: setting - - title: Description - key: description - - title: Limitations - key: limitations - - title: Use cases - key: use-case -rows: - - setting: | - `required` - description: | - Requires every incoming request to match a defined operation from an API or API package in Dev Portal. If a request doesn't match, ACE rejects the request outright with a 404. All traffic will be rejected except operations or Routes in published APIs linked to an ACE-enabled {{site.base_gateway}}. - - {:.danger} - > **Warning:** Setting the [`match_policy`](/plugins/ace/reference/#schema--config-match-policy) to `required` can **block all traffic with a 404**. Any undefined endpoints will be blocked. If you accidentally enable this in your control planes, this could cause a potential outage in production. - limitations: | - * Shuts down all traffic outside of ACE-enabled Dev Portal APIs. - * If the plugin is improperly configured, potentially all traffic could be terminated. - use-case: | - * You want to lock down {{site.konnect_short_name}} so that only traffic that is part of an explicitly defined API operation is allowed through. - * You only plan to provide self-service access via your Dev Portal. - - setting: | - `if_present` - description: | - By default, the ACE plugin only engages with a request when it matches an operation. If a request doesn't match, ACE lets the request pass through untouched. This means that non-matching requests aren't rejected, but ACE also won't perform authentication and authorization on them. This allows a request to still be processed by other plugins with a [lower priority](/gateway/entities/plugin/#plugin-priority) than ACE. - limitations: | - * All traffic outside of published APIs linked to an ACE-enabled {{site.base_gateway}} won't be access controlled, this must be configured with a different plugin. Dev Portal will not be able to protect all operations. - * Since Routes aren't protected by default in this mode, any mistyped or omitted operation in API entities could result in open access. - use-case: | - * You have an environment where some Gateway Services or Routes are governed by Dev Portal–exposed APIs (with ACE), while others are regular Routes that should be left alone. - * You already have existing traffic and other access controls in place and want to avoid interruption. -{% endtable %} \ No newline at end of file +{% include /plugins/ace/ace-route-matching.md %} diff --git a/app/_landing_pages/catalog.yaml b/app/_landing_pages/catalog.yaml index b9294533c2..748d2d1dee 100644 --- a/app/_landing_pages/catalog.yaml +++ b/app/_landing_pages/catalog.yaml @@ -50,6 +50,8 @@ rows: ctas: - text: APIs reference url: "/catalog/apis/" + - text: API packages + url: /catalog/api-packaging/ - text: Create an API catalog with the {{site.konnect_short_name}} API url: "/how-to/automate-api-catalog/" - text: Create an API catalog with Terraform diff --git a/app/_landing_pages/dev-portal.yaml b/app/_landing_pages/dev-portal.yaml index a2c3608b0f..13a0d09bf0 100644 --- a/app/_landing_pages/dev-portal.yaml +++ b/app/_landing_pages/dev-portal.yaml @@ -122,6 +122,8 @@ rows: url: "/how-to/automate-api-catalog-with-terraform/" - text: Create and publish APIs url: "/catalog/apis/" + - text: Create API packages + url: /catalog/api-packaging/ - text: Discover and govern APIs url: /how-to/discover-and-govern-apis-with-service-catalog/ diff --git a/app/_redirects b/app/_redirects index e68beace51..a775838b30 100644 --- a/app/_redirects +++ b/app/_redirects @@ -143,6 +143,7 @@ /dev-portal/access-and-approval/ /dev-portal/self-service/ /dev-portal/publishing/ /catalog/apis/ /dev-portal/portal-customization/ /dev-portal/customizations/dev-portal-customizations/ +/dev-portal/api-catalog-and-packaging/ /catalog/api-packaging/ # Gateway LTS diff --git a/app/catalog/api-packaging.md b/app/catalog/api-packaging.md new file mode 100644 index 0000000000..07dc6d6017 --- /dev/null +++ b/app/catalog/api-packaging.md @@ -0,0 +1,182 @@ +--- +title: Package APIs +content_type: reference +layout: reference + +products: + - catalog + - dev-portal + +breadcrumbs: + - /catalog/ +tags: + - api-catalog + - api-composition +min_version: + gateway: '3.13' +works_on: + - konnect +api_specs: + - konnect/api-builder +search_aliases: + - publish API specs + - API catalog + - API composition + - API packaging + - API bundle +description: | + Learn how to package APIs in Catalog and Dev Portal and what API packages are. +related_resources: + - text: APIs reference + url: /catalog/apis/ + - text: Automate your API catalog with Dev Portal + url: /how-to/automate-api-catalog/ + - text: Automate your API catalog with Terraform + url: /how-to/automate-api-catalog-with-terraform/ + - text: Application authentication strategies + url: /dev-portal/auth-strategies/ +--- + +{:.success} +> This is a reference guide, you can also follow along with our [Package APIs for partners with Dev Portal](/how-to/package-apis-with-dev-portal/) tutorial. + +You can compose API packages from existing APIs in Dev Portal. API packages allow you to: +* Create distinct APIs for specific use cases or partners based on existing API operations. +* Link to multiple Gateway Services and/or Routes for developer self-service and application registration. +* Apply rate limiting policies to an API Package, or per operation. +* Manage role-based access control to specific developers and teams. + +The following table describes common API package use cases: + +{% table %} +columns: + - title: Use case + key: use-case + - title: Description + key: description + - title: Example + key: example +rows: + - use-case: Customize APIs for partners + description: Using API packages, you can customize which operations/endpoints are included in Dev Portals for partners. + example: | + If you have multiple APIs/services, you can select specific operations from each API (for example, `GET /billing` and `GET /flights`) creating an API package for partners in an external Dev Portal, called "Flight Billing API". Meanwhile, Billing and Flights APIs can also be published to your internal Dev Portal. + - use-case: Apply rate limits to applications + description: While Gateway Services or Routes may have systemic rate limits in place, it's often necessary to apply lower rate limits to applications when exposing those capabilities to partners. + example: | + When creating the "Flight Billing API" package, `GET /billing` may need a lower rate limit of 10 request per minute, while the overall API package could have something higher, like five requests per second. +{% endtable %} + + +## How API packages work + +API packages are composed from operations. Operations allow you to compose REST-style APIs from a combination of the hostname, path, and method that are processed by the control plane. They are used to map between the operations in your API and Gateway Routes. If an OpenAPI spec is added to the API, the operations are autogenerated. + +The following diagram shows an example of how API packages can be composed from operations: + + +{% mermaid %} +flowchart LR + subgraph subGraph0["Control plane"] + 1["Billing Gateway Service"] + 2["Flights Gateway Service"] + end + subgraph subGraph1["Partners API package"] + 3["POST /flights"] + 4["GET /flights"] + end + subgraph subGraph2["Org API package"] + 5["POST /billing"] + 6["GET /billing"] + 7["POST /flights"] + 8["GET /flights"] + end + 1 --> 5 & 6 + 2 --> 7 & 8 & 3 & 4 +{% endmermaid %} + + +Packaging APIs involves the following steps: +1. Create an API and attach an OpenAPI spec. Operations from your API's OpenAPI spec should overlap with Routes to ensure requests will be routed to the correct Service. Gateway routing configuration isn't directly modified by adding operations. +1. Link a control plane to allow developer consumption. +1. Apply the Access Control Enforcement (ACE) plugin globally. +1. Create an API package by adding operations and package rate limits. Operations are automatically mapped to Routes using your API's OpenAPI spec or you can create them manually. The Gateway configuration isn't directly modified – any unmatched operations will be highlighted to indicate that a user needs Gateway Manager permissions needs to perform an action. + +### ACE plugin + +{% include plugins/ace/ace-overview.md %} + +#### Route matching policy + +{% include plugins/ace/ace-route-matching.md %} + +### Package rate limits + +You can set individual rate limits on an API package as well as operations in that package. Keep the following in mind when configuring rate limits: +* API package rate limits apply across all operations in the API package **cumulatively**, not individually. +* Each operation in an API Package can additionally have an individual rate limit defined. When an operation-level override is present, the package-level limit is ignored for that operation. +* API package rate limits are applied simultaneously with rate limits from other plugins on gateway entities: + * Requests that are under the current limit for the Service and API Package will be counted towards both. + * Requests that surpass the rate limit of an API package won't be counted towards rate limits applied from other rate limiting plugins. + * Requests that surpass the rate limit of other rate limiting plugins are still counted towards the rate limits applied for API packages. This is because the ACE plugin runs before other rate limiting plugins under the default plugin priorities. You can adjust this behavior with [custom plugin priority values](/gateway/entities/plugin/#dynamic-plugin-ordering). + * Rate limiting is applied per credential. + +For example, if you have the following rate limits set: +* **API package A**: 10 requests per second +* **Operation 1**: 5 requests per second + +Because an operation-level override is present, the package-level limit is ignored for that operation. This means a request authorized for Operation 1 will only count toward its specific operation-level limit. So, if one request is sent, the authorized application will have four requests remaining for Operation 1 for the configured time period (per second). The package-level limit of API Package A doesn't apply to this request. + +### API package limitations + +When configuring API packages, keep the following limitations in mind: + +* If you have two endpoints in your spec, one with a trailing slash and one without, both are generated as the same operation. +* If two operations have the same path and method, they are generated as the same operation. +* All operations for a control plane are removed when you unlink the control plane. +* APIs can only be mapped to one control plane at a time. +* You can't change a version or edit a spec for an API if it would remove an operation because this would result in a breaking change. To remove an operation, we recommend unlinking the control plane from the API. + +## Package APIs with Dev Portal + +This guide shows you how to create an API package in the {{site.konnect_short_name}} UI. + +For an end-to-end tutorial with sample data that walks you through setting up and using API Packages, see [Package APIs with Dev Portal](/how-to/package-apis-with-dev-portal/). + +### Prerequisites + +To package APIs with Dev Portal, you need: +* A v3 Dev Portal created in {{site.konnect_short_name}} +* A [Gateway Service](/gateway/entities/service/#set-up-a-gateway-service) and/or [Route](/gateway/entities/route/#set-up-a-route) added to your control plane ({{site.base_gateway}} 3.13 or later) +* The following roles: + * Editor role for APIs + * Publisher role for the API and API package + * API Creator +* [An API created](/dev-portal/apis/) with an [OpenAPI spec](/dev-portal/apis/#api-specs) associated with it +* A Gateway control plane linked to your API in **Catalog** > **APIs** + +### Create an API package + +1. In {{site.konnect_short_name}}, click **Catalog**. +1. Click the **API packages** tab. +1. Click **Create API package**. +1. In the **API package name** field, enter a name for your package. +1. Enable the Package rate limit and configure your rate limit. +1. Click **Add operations from APIs** in the API operations settings. +1. In the Add API operations pane, click your API and click **Add** next to the operations you want to package. +1. Click **Create API package**. + +Your operations should now be autogenerated based on how your OpenAPI spec maps to your Routes. + +### Publish packages to Dev Portal + +1. In {{site.konnect_short_name}}, click **Catalog**. +1. Click the **API packages** tab. +1. Click your API package. +1. Click **Publish API**. +1. From the **Portal** dropdown menu, select your Dev Portal. +1. From the **Authentication strategy** dropdown menu, select an auth strategy. +1. Click **Public**. +1. Click **Publish API**. + +Your API package will now be published to your Dev Portal. Published API packages appear the same as published APIs in the Dev Portal, and both allow developers to register applications with them. diff --git a/app/catalog/apis.md b/app/catalog/apis.md index f0a116a5c5..22fd0ceeb7 100644 --- a/app/catalog/apis.md +++ b/app/catalog/apis.md @@ -28,6 +28,10 @@ related_resources: url: /how-to/automate-api-catalog/ - text: Developer self-service and app registration url: /dev-portal/self-service/ + - text: Package APIs with Dev Portal + url: /how-to/package-apis-with-dev-portal/ + - text: API packages reference + url: /catalog/api-packaging/ faqs: - q: I'm using the Try it feature in the spec renderer to send requests from Dev Portal, but I'm getting a `401`. How do I fix it? a: If the published API has an [authentication strategy](/dev-portal/auth-strategies/) configured for it, you must include your key in the request. All requests without a key to the Service linked to the API are blocked if it is published with an auth strategy.