1. Operating StreamNative Platform
  2. Protocols

Configure Message Rest API

Set up Message REST API

Before using Rest API, you need to complete the following setup steps.

Step 1: Create a service account

Note

Currently, you can't edit a service account. If you need a service account to have Super Admin access, make sure to enable it when creating the service account. By default, service accounts do not have Super Admin enabled.

To create a service account, follow these steps.

  1. On the left navigation pane, click Service Accounts.

  2. Click Create Service Account.

  3. (Optional) Select Super Admin to grant the service account with Super admin access to a namespace or tenant.

  4. Enter a name for the service account, and then click Confirm.

Step 2: Generate a new token for the service account

Note

  • Before getting the token of a service account, verify that the service account is authorized as a superuser or an admin of the tenants and namespaces.
  • A token has a system-defined Time-To-Live (TTL) of 7 days. Before a token expires, ensure that you generate a new token for your service account.

To get a token using the StreamNative Console, follow these steps.

  1. On the left navigation pane, click Service Accounts.

  2. In the row of the service account you want to use, in the Token column, click Generate new token, then click the Copy icon to copy the token to your clipboard.

Step 3: Grant service account permissions

Note

If you use a Super Admin service account, you can skip this step because a Super Admin service account has the required permissions already.

  1. On the left navigation pane, in the Admin section, click Tenants/Namespaces.

  2. Select the Public tenant, then select the Default namespace under the tenant.

  3. Select the POLICY tab.

  4. In the Authorization area, click ADD ROLE, and select the name of the service account you just created in the previous section.

  5. In the Authorization area, on the drop-down menu below the service name you just added, select the consume and produce roles. The roles are added to your service account.

Step 4: Get the HTTP Service URL of your Pulsar cluster

To get the service URL of a Pulsar cluster through the StreamNative Console, follow these steps.

  1. On the left navigation pane, in the Admin area, click Pulsar Clusters.

  2. Select the Details tab, and in the Access Points area, click Copy at the end of the row of the service URL.

Enable Message Rest API

To enable the message Rest API on StreamNative Platform, you can set broker.pulsarRestMessaging.enabled to true and then use the helm upgrade command to update the configuration.

broker:
  pulsarRestMessaging:
    enabled: true

Note

The message Rest API is enabled on the Pulsar broker. To access the message Rest API outside a Kubernetes cluster, you need to expose the Pulsar proxy service and access the exposed proxy endpoint. The Pulsar proxy will forward the message Rest API requests to the Pulsar broker. For more details, see configure networking.

Previous
Configure WebSocket