Skip to content

Extension draft api #1749

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions guides/multitenancy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ There are several ways to run the update of the database schema.

#### MTX Sidecar API

Please check the [Upgrade API](./mtxs#upgrade-tenants-→-jobs) to see how the database schema update can be run for single or all tenants using the API endpoint.
Please check the [Upgrade API](./mtxs#upgrade-options) to see how the database schema update can be run for single or all tenants using the API endpoint.

#### `cds-mtx upgrade` Command

Expand Down Expand Up @@ -993,14 +993,14 @@ cds watch --profile dev
## SaaS Dependencies {#saas-dependencies}
Some of the xsuaa-based services your application consumes need to be registered as _reuse services_ to work in multitenant environments. This holds true for the usage of both the SaaS Registry service and the Subscription Manager Service (SMS).

CAP Java as well as `@sap/cds-mtxs`, each offer an easy way to integrate these dependencies. They support some services out of the box and also provide a simple API for applications. Most notably, you need such dependencies for the following SAP BTP services: [Audit Log](https://discovery-center.cloud.sap/serviceCatalog/audit-log-service), [Event Mesh](https://discovery-center.cloud.sap/serviceCatalog/event-mesh), [Destination](https://discovery-center.cloud.sap/serviceCatalog/destination), [HTML5 Application Repository](https://discovery-center.cloud.sap/serviceCatalog/html5-application-repository-service), and [Cloud Portal](https://discovery-center.cloud.sap/serviceCatalog/cloud-portal-service).
CAP Java as well as `@sap/cds-mtxs`, each offer an easy way to integrate these dependencies. They support some services out of the box and also provide a simple API for applications. Most notably, you need such dependencies for the following SAP BTP services: [Audit Log](https://discovery-center.cloud.sap/serviceCatalog/audit-log-service), [Event Mesh](https://discovery-center.cloud.sap/serviceCatalog/event-mesh), [Destination](https://discovery-center.cloud.sap/serviceCatalog/destination), [HTML5 Application Repository](https://discovery-center.cloud.sap/serviceCatalog/html5-application-repository-service), and [Cloud Portal](https://discovery-center.cloud.sap/serviceCatalog/cloud-portal-service).

For CAP Java, all these services are supported natively and SaaS dependencies are automatically created if such a service instance is bound to the CAP Java application, that is, the `srv` module.

:::tip Explicitly activate the Destination service
SaaS dependency for Destination service needs to be activated explicitly in the `application.yaml` due to security reasons. SaaS dependencies for some of the other services can be **de**activated by setting the corresponding property to `false` in the `application.yaml`.

Refer to the `cds.multiTenancy.dependencies` section in the [CDS properties](/java/developing-applications/properties#cds-properties).
Refer to the `cds.multiTenancy.dependencies` section in the [CDS properties](/java/developing-applications/properties#cds-properties).
:::

For CAP Node.js, all these services are supported natively and can be activated individually by providing configuration in `cds.requires`. In the most common case, you simply activate service dependencies like so:
Expand Down Expand Up @@ -1049,7 +1049,7 @@ The Boolean values in the _mtx/sidecar/package.json_ activate the default config

### Additional Services

If your CAP Java application uses a service that isn't supported out of the box, you can add a custom dependency by providing a custom handler. Refer to [Define Dependent Services](../../java/multitenancy#define-dependent-services) for details.
If your CAP Java application uses a service that isn't supported out of the box, you can add a custom dependency by providing a custom handler. Refer to [Define Dependent Services](../../java/multitenancy#define-dependent-services) for details.


In Node.js, you can use the `subscriptionDependency` setting to provide a dependency configuration similar to the standard configuration shown before. Use your application's or CAP plugin's _package.json_:
Expand Down
122 changes: 114 additions & 8 deletions guides/multitenancy/mtxs.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,15 @@ The _ModelProviderService_ serves model variants, which may include tenant-speci
- `in-sidecar` — provides defaults for usage in sidecars
- `from-sidecar` — shortcut for `{ "kind": "rest" }`

### `getCsn` _(tenant, toggles) → CSN_
### `getCsn` _(tenant, toggles) → CSN_ {#modelprovider-get-csn}

Returns the application's effective CSN document for the given tenant + feature toggles vector. CAP runtimes call that method to obtain the effective models to serve.

| Arguments | Description |
| --------- | ----------------------------------------------------------- |
| `tenant` | A string identifying the tenant |
| `toggles` | An array listing toggled features; `['*']` for all features |
| Arguments | Description |
| ----------- | ----------------------------------------------------------- |
| `tenant` | A string identifying the tenant |
| `toggles` | An array listing toggled features; `['*']` for all features |
| `activated` | <Beta/> `false` to include also extension drafts, default is `true` |

#### Example Usage {#example-get-csn }

Expand Down Expand Up @@ -893,6 +894,11 @@ Content-Type: application/json

Creates a new tenant-specific extension.

Extensions can be created as draft. In that case, the extensions need to be activate using action [`activate`](#activate-extension-draft) to get visible for everyone.

To get the full model including draft extensions, the [Model Provider Service](#modelprovider-get-csn) has to be called accordingly.


#### HTTP Request Options

| Request Header | Example Value | Description |
Expand All @@ -911,6 +917,7 @@ Creates a new tenant-specific extension.
| **Body**
| `csn` | Array of extension CDL or CSN to apply |
| `i18n` | Texts and translations |
| `status` | <beta/> Activation status ( `1` for draft, `2` for active, default is `2`) |

</div>

Expand Down Expand Up @@ -1012,6 +1019,9 @@ Deletes a tenant-specific extension.
| **Parameters** | Description |
| - | - |
| `ID` | String uniquely identifying the extension |
| - | - |
| **Query parameters** | Description |
| `status` | `status` of the deletion. `2` for active deletion (default), `1` for deletion as draft |

</div>

Expand All @@ -1020,11 +1030,19 @@ Deletes a tenant-specific extension.
#### Example Usage

```http [Request]
DELETE /-/cds/extensibility/Extensions/isbn-extension HTTP/1.1
DELETE /-/cds/extensibility/Extensions/isbn-extension?status=1 HTTP/1.1
Content-Type: application/json
```

The request can also be triggered asynchronously by setting the `Prefer: respond-async` header.
Using query parameter `?status=1`, the extension with `ID` `isbn-extension` is deleted as draft. If the extension exists as draft, the draft will be discarded (similar to [discard](#discard-id)).
If the extension is active, the deletion is stored as draft and requires an [activation](#activate-extension-draft) to be deployed to the database.

::: warning Deployment of extension deletions
The deployment of extension deletions only works for the SAP HANA Database, it it is configured accordingly.

:::

The `DELETE` request can also be triggered asynchronously by setting the `Prefer: respond-async` header.
You can use the URL returned in the `Location` response header to poll the job status.

In addition, you can poll the status for individual tenants using its individual task ID:
Expand All @@ -1044,6 +1062,94 @@ The response is similar to the following:

The job and task status can take on the values `QUEUED`, `RUNNING`, `FINISHED` and `FAILED`.

### `validate` _(ID)_ _→ { errors: [], messages: [] }_ <beta/>

Validates extension draft `ID`. The validation checks the syntax and the permissions of an extension.

Returns errors and messages in case if the validation fails.

#### Request Format

| **Parameters** | Description |
| - | - |
| `ID` | String uniquely identifying the extension |


#### Example Usage

```http [Request]
POST /-/cds/extensibility/validate
Content-Type: application/json
Authorization: Basic carol:

{
"ID": "isbn-extension"
}
```

### `activate` _(ID, level, options) → Jobs_ <beta/> {#activate-extension-draft}

Activates extension draft `ID` and makes it publicly visible.

#### HTTP Request Options

| Request Header | Example Value | Description |
| ---------------- | -------------------------------------------------------|--------------|
| `prefer` | `respond-async` | Trigger asynchronous extension activation |


<div class="cols-2">

<div>

#### Request Format

| **Parameters** | Description |
| - | - |
| `ID` | String uniquely identifying the extension |
| `level` | Target activation level, `1` or `2`, default is `2`, `1` is a no-op currently |
| `options` | Various options, including deployment options (similar to [upgrade in SaasProvisioningService](#upgrade-options) ) |

</div>

</div>

#### Example Usage

```http [Request]
POST /-/cds/extensibility/activate
Content-Type: application/json
Authorization: Basic carol:

{
"ID": "isbn-extension",
"level": 2
}
```

### `discard` _(ID)_ <beta/>

Discards extension draft `ID`.

#### Request Format

| **Parameters** | Description |
| - | - |
| `ID` | String uniquely identifying the extension |


#### Example Usage

```http [Request]
POST /-/cds/extensibility/discard
Content-Type: application/json
Authorization: Basic carol:

{
"ID": "isbn-extension"
}
```

## DeploymentService

The _DeploymentService_ handles `subscribe`, `unsubscribe`, and `upgrade` events for single tenants and single apps or micro services. Actual implementation is provided through internal plugins, for example, for SAP HANA and SQLite.
Expand Down Expand Up @@ -1289,7 +1395,7 @@ Returns configured SAP BTP SaaS Provisioning service dependencies.

[Learn how to configure SaaS dependencies](./#saas-dependencies){.learn-more}

### `upgrade` _[tenants] → Jobs_
### `upgrade` _[tenants] → Jobs_ {#upgrade-options}

Use the `upgrade` endpoint to upgrade tenant base models.

Expand Down