Skip to content
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

CAPI: Consolidate database examples and add Essentials information #1000

Merged
merged 8 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
5 changes: 1 addition & 4 deletions content/operate/rc/api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ 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. [Manage cloud accounts]({{< relref "/operate/rc/api/examples/manage-cloud-accounts.md" >}})
1. [Estimate costs]({{< relref "/operate/rc/api/examples/dryrun-cost-estimates.md" >}})
1. [View account info]({{< relref "/operate/rc/api/examples/view-account-information.md" >}})

## More info

Expand Down
78 changes: 56 additions & 22 deletions content/operate/rc/api/examples/create-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 in order to create a database:
cmilesb marked this conversation as resolved.
Show resolved Hide resolved

- `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 in order to create a database:
cmilesb marked this conversation as resolved.
Show resolved Hide resolved

- `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" >}}).
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.
3 changes: 3 additions & 0 deletions content/operate/rc/api/examples/manage-cloud-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ description: Cloud accounts specify which account to use when creating and modif
infrastructure resources.
linkTitle: Manage cloud accounts
weight: 80
draft: true
---
<!-- This article is removed since it was duplicated with the REST API reference. I decided to keep it as a draft just in case. -->

You can use the Redis Cloud REST API to create and manage cloud accounts.

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.
Expand Down
158 changes: 113 additions & 45 deletions content/operate/rc/api/examples/manage-subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,142 @@ categories:
- docs
- operate
- rc
description: This article describes how to create and manage a subscription using
`cURL` commands.
description: Describes how to create and manage a subscription using the Redis Cloud API.
weight: 10
---

The Redis Cloud REST API lets you create and manage all kinds of subscriptions. The examples in this article refer to Redis Cloud Pro subscriptions.
The Redis Cloud REST API lets you create and manage all kinds of subscriptions.

## Create a subscription
## Redis Cloud Essentials

Use `POST /v1/subscriptions` to create a subscription.
### Create an Essentials subscription

Use [`POST /v1/fixed/subscriptions`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/createSubscription_1" >}}) to create an Essentials subscription.

```sh
POST "https://[host]/v1/subscriptions"
POST "https://[host]/v1/fixed/subscriptions"
{
"name": "Basic subscription example",
"paymentMethodId": <payment_id>,
"cloudProviders": [
{
"cloudAccountId": <account_id>,
"regions": [
{
"region": "us-east-1",
"networking": {
"deploymentCIDR": "10.0.0.0/24"
}
}
]
}
],
"databases": [
{
"name": "Redis-database-example",
"memoryLimitInGb": 1.1
}
]
"name": "My new subscription",
"planId": <plan_id>,
"paymentMethodId": <payment_id>
}
```

Modify the following parameters in the sample JSON document to create a subscription on your own account:

- **`paymentMethodId`** - Specify a payment method connected to your account.

Use `GET /payment-methods` to find a payment method ID.

You don't need to pass this field in your API request if you subscribed to Redis Cloud through Google Cloud Marketplace.
Use [`GET /v1/payment-methods`]({{< relref "/operate/rc/api/api-reference#tag/Account/operation/getAccountPaymentMethods" >}}) to find a payment method ID.

- **`cloudAccountId`** - Set a cloud account ID connected to your account.
You don't need to pass this field in your API request if you subscribed to Redis Cloud through a marketplace integration.

To list cloud account IDs, use `GET /cloud-accounts`. To use internal resources, set it to `"cloudAccountId": 1`.
- **`planId`** - Specify an essentials plan to create.

If you subscribed to Redis Cloud through Google Cloud Marketplace, use `1` for this field.
Use [`GET /v1/fixed/plans`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getAllFixedSubscriptionsPlans" >}}) to get a list of plan IDs.

The request JSON body contains two primary segments: subscription specification and databases specification. When you create a subscription, you must specify one or more databases in the "`databases`" array.
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 /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.
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.

{{< note >}}
The Swagger UI generates default JSON examples for `POST` and `PUT` operations. You can reference these examples and modify them to fit your specific needs and account settings. The examples will fail if used as-is.
{{< /note >}}

The response body contains the `taskId` for the task that creates the subscription. You can use `GET /v1/tasks/<taskId>` to track the task's status.
The response body contains the `taskId` for the task that creates the subscription. 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 subscription

Use [`PUT /v1/fixed/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/updateSubscription_1" >}}) to update an Essentials subscription.

```sh
PUT "https://[host]/v1/fixed/subscriptions/{subscriptionId}"
{
"name": "new-subscription-name",
"planId": <plan_id>,
"paymentMethodId": <payment_id>
}
```

You can only change the following settings with this endpoint:
- **`name`** - Specify a new name for your subscription.

- **`planId`** - Specify a new Essentials plan to change to.

Use [`GET /v1/fixed/plans`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/getAllFixedSubscriptionsPlans" >}}) to get a list of plan IDs.

You can only change to a plan that:
- Is in the same cloud provider and region of your current plan.
- Has a compatible [High-availability option]({{< relref "/operate/rc/databases/configuration/high-availability" >}}) to your current plan. For example, if your current plan has single-zone replication, you cannot switch to a plan with multi-zone replication, but you can switch to a plan with no replication. If your current plan has multi-zone replication, you must switch to a plan with multi-zone replication.

- **`paymentMethodId`** - Specify a different payment method connected to your account.

Use [`GET /v1/payment-methods`]({{< relref "/operate/rc/api/api-reference#tag/Account/operation/getAccountPaymentMethods" >}}) to find a payment method ID.

The response body contains the `taskId` for the task that updates the subscription. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status.

### Delete an Essentials subscription

Use [`DELETE /v1/fixed/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Essentials/operation/deleteSubscriptionById_1" >}}) to delete a subscription.

```sh
DELETE "https://[host]/v1/fixed/subscriptions/{subscriptionId}"
```
The response body contains the `taskId` for the task that deletes the subscription. 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 subscription

Use [`POST /v1/subscriptions`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Pro/operation/createSubscription" >}}) to create a Pro subscription.

```sh
POST "https://[host]/v1/subscriptions"
{
"name": "Basic Subscription Example",
"paymentMethodId": <payment_id>,
"cloudProviders": [
{
"provider": "AWS",
"regions": [
{
"region": "us-east-1",
"networking": {
"deploymentCIDR": "10.0.1.0/24"
}
}
]
}
],
"databases": [
{
"name": "Redis-database-example",
"protocol": "redis",
"datasetSizeInGb": 1
}
]
}
```

Modify the following parameters in the sample JSON document to create a subscription on your own account:

- **`paymentMethodId`** - Specify a payment method connected to your account.

Use [`GET /v1/payment-methods`]({{< relref "/operate/rc/api/api-reference#tag/Account/operation/getAccountPaymentMethods" >}}) to find a payment method ID.

You don't need to pass this field in your API request if you subscribed to Redis Cloud through a marketplace integration.

The request JSON body contains two primary segments: subscription specification and databases specification. When you create a subscription, you must specify one or more databases in the "`databases`" array.

There are many additional parameters and settings that can be defined on subscription and database creation. Review the subscription parameters and options in the [Full API documentation]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Pro/operation/createSubscription" >}}).

The response body contains the `taskId` for the task that creates the subscription. 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 subscription
### Update a Pro subscription

Use `PUT /v1/subscriptions/<subscriptionId>` to update a subscription.
Use [`PUT /v1/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Pro/operation/updateSubscription" >}}) to update a Pro subscription.

```sh
PUT "https://[host]/v1/subscriptions/<subscriptionId>"
PUT "https://[host]/v1/subscriptions/{subscriptionId}"
{
"name": "new-subscription-name",
"paymentMethodId": <payment_id>
Expand All @@ -84,15 +152,15 @@ You can only change the following settings with this endpoint:

- **`paymentMethodId`** - Specify a different payment method connected to your account.

Use `GET /payment-methods` to find a payment method ID.
Use [`GET /v1/payment-methods`]({{< relref "/operate/rc/api/api-reference#tag/Account/operation/getAccountPaymentMethods" >}}) to find a payment method ID.

The response body contains the `taskId` for the task that updates the subscription. You can use `GET /v1/tasks/<taskId>` to track the task's status.
The response body contains the `taskId` for the task that updates the subscription. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status.

## Delete a subscription
### Delete a Pro subscription

Use `DELETE /v1/subscriptions/<subscriptionId>` to delete a subscription.
Use [`DELETE /v1/subscriptions/{subscriptionId}`]({{< relref "/operate/rc/api/api-reference#tag/Subscriptions-Pro/operation/deleteSubscriptionById" >}}) to delete a subscription.

```sh
DELETE "https://[host]/v1/subscriptions/<subscriptionId>"
DELETE "https://[host]/v1/subscriptions/{subscriptionId}"
```
The response body contains the `taskId` for the task that deletes the subscription. You can use `GET /v1/tasks/<taskId>` to track the task's status.
The response body contains the `taskId` for the task that deletes the subscription. You can use [`GET /v1/tasks/{taskId}`]({{< relref "/operate/rc/api/api-reference#tag/Tasks/operation/getTaskById" >}}) to track the task's status.
Loading
Loading