diff --git a/content/operate/rc/api/_index.md b/content/operate/rc/api/_index.md index bbe884b29..ee728f981 100644 --- a/content/operate/rc/api/_index.md +++ b/content/operate/rc/api/_index.md @@ -33,8 +33,7 @@ You can use the API to: 1. [Manage subscriptions]({{< relref "/operate/rc/api/examples/manage-subscriptions.md" >}}) 1. Database examples - - [Create database]({{< relref "/operate/rc/api/examples/create-database" >}}) - - [Update database]({{< relref "/operate/rc/api/examples/update-database.md" >}}) + - [Create and manage databases]({{< relref "/operate/rc/api/examples/create-database" >}}) - [Back up and import data]({{< relref "/operate/rc/api/examples/back-up-and-import-data.md" >}}) 1. [Estimate costs]({{< relref "/operate/rc/api/examples/dryrun-cost-estimates.md" >}}) diff --git a/content/operate/rc/api/examples/create-database.md b/content/operate/rc/api/examples/create-database.md index f0c82f28f..afb011f46 100644 --- a/content/operate/rc/api/examples/create-database.md +++ b/content/operate/rc/api/examples/create-database.md @@ -5,45 +5,79 @@ categories: - docs - operate - rc -description: This article describes how to create and manage a database using `cURL` - commands. -linkTitle: Create databases +description: This article describes how to create and manage a database using the Redis Cloud API. +linkTitle: Create and manage databases weight: 20 --- -You can use the Redis Cloud REST API to create databases. +You can use the Redis Cloud REST API to create and manage databases. -These examples use the [`cURL` utility]({{< relref "/operate/rc/api/get-started/use-rest-api#use-the-curl-http-client" >}}). You can use any REST client to work with the Redis Cloud REST API. The examples in this article refer to Redis Cloud Pro databases. +## Redis Cloud Essentials -## Create a database +### Create an Essentials database -To create a database, use `POST /subscriptions/{subscription-id}/databases` +To create a Redis Cloud Essentials database, use [`POST /fixed/subscriptions/{subscriptionId}/databases`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/createFixedDatabase" >}}). -The database is created in an existing or a newly created subscription. +This call creates a database in the specified subscription. Use [`GET /fixed/subscriptions`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getAllSubscriptions_1" >}}) to get a list of Essentials subscriptions and their IDs. -When a subscription is created, it is created with at least one database. +```shell +POST "https://[host]/v1/fixed/subscriptions/{subscriptionId}/databases" +{ + "name": "Basic-essentials-database-example" +} +``` + +This example JSON body contains only the most basic, required parameters to create a database: + +- `name`: The database name. A unique name per subscription that can contain only alphanumeric characters and hyphens + +There are other additional parameters and settings that can be defined on database creation. Review the database parameters and options in the [full API reference]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/createFixedDatabase" >}}). + +Some options may not be compatible with your selected plan. Use [`GET /fixed/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getFixedSubscriptionsPlansBySubscriptionId" >}}) to view the plan you have selected and what options it supports. + +The response body contains the `taskId` for the task that creates the database. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status. + +### Update an Essentials database -You can add databases to the subscription; you can also update or delete existing databases. +To update a Redis Cloud Essentials database, use [`PUT /fixed/subscriptions/{subscriptionId}/databases/{databaseId}`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/deleteFixedDatabaseByID" >}}). -Creating a database is an [asynchronous operation]({{< relref "/operate/rc/api/get-started/process-lifecycle" >}}). +The primary component of a database update request is the JSON request body that contains the details of the requested database changes. You can see the full set of changes you can make in the [full API reference]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/deleteFixedDatabaseByID" >}}). -The following API call creates a database. +Some options may not be compatible with your selected plan. Use [`GET /fixed/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getFixedSubscriptionsPlansBySubscriptionId" >}}) to view the plan you have selected and what options it supports. + +The response body contains the `taskId` for the task that updates the database. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status. + +## Redis Cloud Pro + +### Create a Pro database + +If you want to create a Pro database in a new subscription, see [Create a Pro subscription]({{< relref "/operate/rc/api/examples/manage-subscriptions#create-a-pro-subscription" >}}). + +To create a Redis Cloud Pro database in an existing subscription, use [`POST /subscriptions/{subscriptionId}/databases`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Pro/operation/createDatabase" >}}). + +This call creates a database in the specified subscription. Use [`GET /subscriptions`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Pro/operation/getAllSubscriptions" >}}) to get a list of subscriptions and their IDs. ```shell -POST "https://[host]/v1/subscriptions/$SUBSCRIPTION_ID/databases" +POST "https://[host]/v1/subscriptions/{subscriptionId}/databases" { - "name": "Database-example-basic", - "memoryLimitInGb": 10, - "password": "P@ssw0rd" + "name": "Basic-database-example", + "datasetSizeInGb": 1 } ``` -The JSON body contains only the most basic, required parameters in order to create a database: +This example JSON body contains only the most basic, required parameters to create a database: + +- `name`: The database name. A unique name per subscription that can contain only alphanumeric characters and hyphens +- `datasetSizeInGb`: Maximum dataset size in GB + +There are many additional parameters and settings that can be defined on database creation. Review the database parameters and options in the [full API reference]({{< relref "/operate/rc/api/api-reference#tag/Databases-Pro/operation/createDatabase" >}}). + +The response body contains the `taskId` for the task that creates the database. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status. + +### Update a Redis Cloud Pro database -- Database name - A unique name per subscription that can contain only alphanumeric characters and hyphens -- Maximum database size in GB -- Database password +To update a Redis Cloud Pro database, use [`PUT /subscriptions/{subscriptionId}/databases/{databaseId}`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Pro/operation/updateDatabase" >}}). -### Additional database parameters +The primary component of a database update request is the JSON request body that contains the details of the requested database changes. You can see the full set of changes you can make in the [full API reference]({{< relref "/operate/rc/api/api-reference#tag/Databases-Pro/operation/updateDatabase" >}}). -There are many additional parameters and settings that can be defined on database creation. Review the database parameters and options in the [Full API documentation]({{< relref "/operate/rc/api/api-reference#tag/Databases-Pro/operation/createDatabase" >}}). \ No newline at end of file +The response body contains the `taskId` for the task that updates the database. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status. \ No newline at end of file diff --git a/content/operate/rc/api/examples/manage-subscriptions.md b/content/operate/rc/api/examples/manage-subscriptions.md index f470fc738..662c2da07 100644 --- a/content/operate/rc/api/examples/manage-subscriptions.md +++ b/content/operate/rc/api/examples/manage-subscriptions.md @@ -38,7 +38,7 @@ Modify the following parameters in the sample JSON document to create a subscrip Use [`GET /v1/fixed/plans`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getAllFixedSubscriptionsPlans" >}}) to get a list of plan IDs. -After you create an Essentials subscription, you must use the [`POST /v1/fixed/subscriptions/{subscriptionId}/databases`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/createFixedDatabase" >}}) endpoint to create the database. +After you create an Essentials subscription, you must use the [`POST /v1/fixed/subscriptions/{subscriptionId}/databases`]({{< relref "/operate/rc/api/api-reference#tag/Databases-Essentials/operation/createFixedDatabase" >}}) endpoint to [create the database]({{< relref "/operate/rc/api/examples/create-database#redis-cloud-essentials" >}}). You can include the contents of the JSON document in the `POST /v1/fixed/subscriptions` operation in the [Swagger UI](https://api.redislabs.com/v1/swagger-ui.html). See [Swagger user interface]({{< relref "/operate/rc/api/get-started/use-rest-api#swagger-user-interface" >}}) for more details. diff --git a/content/operate/rc/api/examples/update-database.md b/content/operate/rc/api/examples/update-database.md deleted file mode 100644 index 7e5a2e796..000000000 --- a/content/operate/rc/api/examples/update-database.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -Title: Update databases -alwaysopen: false -categories: -- docs -- operate -- rc -description: How to construct requests that update an existing database. -weight: 30 ---- - -The API operation that updates an existing database is: `PUT /subscriptions/{subscription-id}/databases/{database-id}` - -This API operation uses the same [provisioning lifecycle]({{< relref "/operate/rc/api/get-started/process-lifecycle.md" >}}) as the [create database]({{< relref "/operate/rc/api/examples/create-database" >}}) operation. The examples in this article refer to Redis Cloud Pro databases. - -## Database update request JSON body - -The primary component of a database update request is the JSON request body that contains the details of the requested database changes. - -You can see [the complete set of JSON elements]({{< relref "/operate/rc/api/get-started/use-rest-api#inputs-for-operations-in-swagger" >}}) accepted by the database update API operation in the [Swagger UI](https://api.redislabs.com/v1/swagger-ui.html). -To see the JSON elements, expand the specific API operation and, in the request section, click **Model**. - -Here are several examples of JSON requests to update a database: - -### Add or remove Replica Of - -Setting one or more source Redis databases configures the updated database as a Replica Of destination database for the specified Redis databases. - -#### Add a source database - -The following JSON request specifies two source databases for the updated database: - -```json -{ - "replicaOf": [ - "redis://redis-12345.c9876.us-east-1-mz.ec2.cloud.rlrcp.com:12345" - , "redis://redis-54321.internal.c9876.us-east-1-mz.ec2.cloud.rlrcp.com:54321" - ] -} -``` - -- The `replicaOf` array contains one or more URIs with the format: `redis://user:password@host:port` -- If the URI provided belongs to the same account, you can provide just the host and port (example: `["redis://endpoint1:6379', "redis://endpoint2:6380"]`) - -{{< warning >}} -If a source database is already defined for a specific database, and the goal is to add an additional source database, the source databases URI for the existing source must be included in the database updates JSON request. -{{< /warning >}} - -#### Remove a source database - -To remove a source database from the `replicaOf` list, submit a JSON request that does not include the specific source database URI. - -##### Example: - -Given a database that has two defined source databases: - -```json -{ - "replicaOf": [ - "redis://redis-12345.c9876.us-east-1-mz.ec2.cloud.rlrcp.com:12345" - , "redis://redis-54321.internal.c9876.us-east-1-mz.ec2.cloud.rlrcp.com:54321" - ] -} -``` - -- You can use this JSON request to remove one of the two source databases: - -```json -{ - "replicaOf": [ - "redis://redis-12345.c9876.us-east-1-mz.ec2.cloud.rlrcp.com:12345" - ] -} -``` - -- You can use this JSON request to remove all source databases: - -```json -{ - "replicaOf": [] -} -``` - -#### Viewing database Replica Of information - -The API operation `GET /subscriptions/{subscription-id}/databases/{database-id}` returns information on a specific database, including the Replica Of endpoints defined for the specific database.