11.17 REST

The REST command enables you to export Oracle REST Data Services 3.x services. This is applicable for Oracle REST Data Services release 3.0.5 or later.

If you have an earlier version of Oracle REST Data Services, you will need to upgrade. See the Installing Oracle REST Data Services section in Oracle REST Data Services Installation, Configuration, and Development Guide for details.

The REST command contains the following subcommands:

List Commands

Command Description
modules Lists modules in a schema.
clients Lists OAuth clients in a schema.
schemas Lists REST-enabled schemas.
privileges Lists privileges in a schema.

Export Commands

Command Description
export module Exports a REST module by name or prefix.
export client Exports an OAuth client by name.
export schema Exports a REST-enabled schema.

Import Command

Command Description
import Imports a REST definition form a JSON file.

11.17.1 modules

Lists all modules in the current schema or the specified schema.

Syntax

REST modules {OPTIONS}

Options

Option Description
-schema-name

Specifies the name of the schema whose modules are to be listed. If you omit this parameter, the command lists the objects in the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To list modules in the current schema, enter:

SQL> REST modules

Example 2

To list modules in a schema named my_other_schema, enter:

SQL> REST modules -schema-name my_other_schema

11.17.2 clients

Lists all OAuth clients in the current schema or the specified schema.

Syntax

REST clients {OPTIONS}

Options

Option Description
-schema-name

Specifies the name of the schema whose OAuth clients are to be listed. If you omit this parameter, the command lists the objects in the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To list OAuth clients in the current schema, enter:

SQL> REST clients

Example 2

To list OAuth clients in a schema named my_other_schema, enter:

SQL> REST clients -schema-name my_other_schema

11.17.3 schemas

Lists all REST-enabled schemas. If you run this command with the ORDS_ADMINISTRATOR_ROLE, it lists all REST-enabled schemas; otherwise, it lists only the current REST-enabled schema.

Syntax

REST schemas

Example

To list REST-enabled schemas, enter:

SQL> REST schemas

11.17.4 privileges

Lists all privileges in the current schema or the specified schema.

Syntax

REST privileges {OPTIONS}

Options

Option Description
-schema-name

Specifies the name of the schema whose privileges are to be listed. If you omit this parameter, the command lists the objects in the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To list privileges in the current schema, enter:

SQL> REST privileges

Example 2

To list privileges in a schema named my_other_schema, enter:

SQL> REST privileges -schema-name my_other_schema

11.17.5 export module

Exports a REST module by name or prefix in the current schema or the specified schema. Requires Oracle REST Data Services (ORDS) 25.1.0 or later.

Syntax

REST export module <item_name> {OPTIONS}

Parameters

Parameter Description

Required

<item_name>

Specifies the module to export, using either:
  • The REST module name, for example, my-module1 or hr-module.

  • The REST module prefix, for example, /module1/ or /hr/.

Options

Option Description
-schema-name

Specifies the name of the schema owning the module.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

-runnable-as-admin

Flag option.

When present, generates a script utilizing the ORDS_ADMIN package, allowing object creation in schemas other than the connected schema.

When absent, generates a script using the standard ORDS package restricting operations to the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To export a module in the current schema, enter:

SQL> REST export module my-module1

or

SQL> REST export module /module1/

Example 2

To export a module in a schema named my_other_schema using the standard ORDS package in the output, enter:

SQL> REST export module my-module1 -schema-name my_other_schema

or

SQL> REST export module /module1/ -schema-name my_other_schema

Example 3

To export a module in a schema named my_other_schema using the ORDS_ADMIN package in the output, enter:

SQL> REST export module my-module1 -schema-name my_other_schema -runnable-as-admin

or

SQL> REST export module /module1/ -schema-name my_other_schema -runnable-as-admin

11.17.6 export client

Exports an OAuth client in the current schema or the specified schema. Requires Oracle REST Data Services (ORDS) 25.3.0 or later.

Syntax

REST export client <item_name> {OPTIONS}

Parameters

Parameter Description

Required

<item_name>

Specifies the name of the OAuth client to export.

Options

Option Description
-schema-name

Specifies the name of the schema owning the OAuth client.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

-runnable-as-admin

Flag option.

When present, generates a script utilizing the ORDS_ADMIN package, allowing object creation in schemas other than the connected schema.

When absent, generates a script using the standard ORDS package restricting operations to the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To export an OAuth client in the current schema, enter:

SQL> REST export client client_name

Example 2

To export an OAuth client in a schema named my_other_schema using the standard ORDS package in the output, enter:

SQL> REST export client client_name -schema-name my_other_schema

Example 3

To export an OAuth client in a schema named my_other_schema using the ORDS_ADMIN package in the output, enter:

SQL> REST export client client_name -schema-name my_other_schema -runnable-as-admin

11.17.7 export schema

Exports a full schema. Requires Oracle REST Data Services (ORDS) 25.1.0 or later.

Syntax

REST export schema {OPTIONS}

Options

Option Description
-schema-name

Specifies the name of the schema to export.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

-runnable-as-admin

Flag option.

When present, generates a script utilizing the ORDS_ADMIN package, allowing object creation in schemas other than the connected schema.

When absent, generates a script using the standard ORDS package restricting operations to the current schema.

The ORDS_ADMINISTRATOR_ROLE is required to use this parameter.

Example 1

To export the current schema, enter:

SQL> REST export schema

Example 2

To export a schema named my_other_schema using the standard ORDS package in the output, enter:

SQL> REST export schema -schema-name my_other_schema

Example 3

To export a schema named my_other_schema using the ORDS_ADMIN package in the output, enter:

SQL> REST export schema -schema-name my_other_schema -runnable-as-admin

11.17.8 import

Imports a REST definition form a JSON file.

This command imports a Swagger 2.0 or an OpenAPI 3.0 specification file and generates skeleton calls that can recreate a similar service in ORDS.

Syntax

REST import json_file_path

Parameters

Parameter Description

Required

json_file_path

Provides the absolute path to the json file.

Example

To import a REST definition form a JSON file, enter:

SQL> REST import /path/to/file.json