diff --git a/pages/billing/api-cli/retrieve-monthly-consumption.mdx b/pages/billing/api-cli/retrieve-monthly-consumption.mdx index 1694be84a9..11ed500067 100644 --- a/pages/billing/api-cli/retrieve-monthly-consumption.mdx +++ b/pages/billing/api-cli/retrieve-monthly-consumption.mdx @@ -36,10 +36,8 @@ Open a terminal and run the following command to export your API secret key and Run the following command to obtain your consumption over the current month. ```bash - curl -X GET \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - -H "Content-Type: application/json" \ - "https://api.scaleway.com/billing/v2beta1/consumptions?organization_id=$SCW_ORGANIZATION_ID" + scw billing consumption list \ + --organization-id=$SCW_ORGANIZATION_ID ``` ## Consumption of a product category @@ -63,10 +61,9 @@ Run the following command to obtain your consumption over the current month for - `Subscription` ```bash - curl -X GET \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - -H "Content-Type: application/json" \ - "https://api.scaleway.com/billing/v2beta1/consumptions?organization_id=$SCW_ORGANIZATION_ID&category_name=Compute" + scw billing consumption list \ + --organization-id=$SCW_ORGANIZATION_ID \ + --category-name=Compute ``` ## Consumption of a specific month @@ -76,10 +73,9 @@ Run the following command to obtain your consumption for a specific month. Specify the target billing period as `YYYY-MM`, e.g. `2023-11`. ```bash - curl -X GET \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - -H "Content-Type: application/json" \ - "https://api.scaleway.com/billing/v2beta1/consumptions?organization_id=$SCW_ORGANIZATION_ID&billing_period=2023-11" + scw billing consumption list \ + --organization-id=$SCW_ORGANIZATION_ID \ + --billing-period=2023-11 ``` ## Consumption of a specific Project @@ -95,8 +91,6 @@ Run the following command to obtain your consumption for a specific Project only Then inject it in your API request: ```bash - curl -X GET \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - -H "Content-Type: application/json" \ - "https://api.scaleway.com/billing/v2beta1/consumptions?project_id=SCW_PROJECT_ID" + scw billing consumption list \ + --project-id=SCW_PROJECT_ID ``` \ No newline at end of file diff --git a/pages/iot-hub/api-cli/getting-started-with-iot-hub-api.mdx b/pages/iot-hub/api-cli/getting-started-with-iot-hub-api.mdx index a099e488a0..3d94fb8e52 100644 --- a/pages/iot-hub/api-cli/getting-started-with-iot-hub-api.mdx +++ b/pages/iot-hub/api-cli/getting-started-with-iot-hub-api.mdx @@ -8,7 +8,7 @@ tags: iot iot-hub io-hub-api api curl mqtt jq json import Requirements from '@macros/iam/requirements.mdx' -In this tutorial we will use the API through the well known utility [curl](https://curl.haxx.se/). This will show you how to create Hubs and Devices, as well as more advanced features of the Scaleway IoT Hub: Hub Events and Routes. +In this tutorial we will use the Scaleway CLI. This will show you how to create Hubs and Devices, as well as more advanced features of the Scaleway IoT Hub: Hub Events and Routes. The API reference is here: [IoT API](https://www.scaleway.com/en/developers/api/iot-hub/) @@ -17,7 +17,7 @@ The API reference is here: [IoT API](https://www.scaleway.com/en/developers/api/ - A Scaleway account logged into the [console](https://console.scaleway.com) - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization - A valid [API key](/iam/how-to/create-api-keys/). -- Installed `curl`, `mosquitto-clients` (mqtt client), and `jq` (json parsing tool) +- Installed the Scaleway CLI, `mosquitto-clients` (mqtt client), and `jq` (json parsing tool) You already set the `SCW_SECRET_KEY` variable above, now set the following variables from the same terminal on your local computer: @@ -38,11 +38,10 @@ The Hub creation is done through a REST endpoint. To create a Hub, you will need We will save the output to `hub.json` file: ```bash -curl -sS -H "X-Auth-Token: $SCW_SECRET_KEY" -d '{ - "project_id": "'$SCW_DEFAULT_PROJECT_ID'", - "name": "my_first_hub", - "product_plan": "plan_dedicated" - }' $IOT_API/hubs > hub.json +scw iot hub create \ +--name=my_first_hub \ +--product-plan=plan_dedicated \ +--region=fr-par > hub.json jq < hub.json ``` @@ -74,7 +73,9 @@ jq < hub.json We can poll the hub status until it is ready: ```bash -curl -sS -H "X-Auth-Token: $SCW_SECRET_KEY" $IOT_API/hubs/$(jq -r '.id' hub.json) | jq -r '.status' +scw iot hub get \ +--hub-id=$(jq -r '.id' hub.json) \ +--region=fr-par | jq -r '.status' ``` At some point, the status will switch to `ready`. @@ -93,11 +94,11 @@ Now we need to create 2 devices. You need to provide: We will save the response to a file so we can use the fields later. ```bash -curl -sS -H "X-Auth-Token: $SCW_SECRET_KEY" -d '{ - "hub_id": "'$(jq -r '.id' hub.json)'", - "name": "my_first_device", - "allow_insecure": true - }' $IOT_API/devices > dev1.json +scw iot device create \ +--hub-id=$(jq -r '.id' hub.json) \ +--name=my_first_device \ +--allow-insecure=true \ +--region=fr-par > dev1.json jq < dev1.json ``` @@ -139,11 +140,11 @@ jq < dev1.json Let's now create a second device: ```bash -curl -sS -H "X-Auth-Token: $SCW_SECRET_KEY" -d '{ - "hub_id": "'$(jq -r '.id' hub.json)'", - "name": "my_second_device", - "allow_insecure": true - }' $IOT_API/devices > dev2.json +scw iot device create \ +--hub-id=$(jq -r '.id' hub.json) \ +--name=my_second_device \ +--allow-insecure=true \ +--region=fr-par > dev2.json jq < dev2.json ``` @@ -186,9 +187,8 @@ If you require security, you can also connect your device to the Hub using TLS m First, download the IoT Hub's server CA: ```bash -curl -sS -O https://iot.s3.nl-ams.scw.cloud/certificates/fr-par/iot-hub-ca.pem -sha1sum iot-hub-ca.pem -# 13cf3e59ed52d4c4b6bc249e85539d5fd5d572fb iot-hub-ca.pem +# The certificate is automatically handled by the CLI +# No need to download it manually when using the Scaleway CLI ``` Now, extract the certificates from the device JSON files, so that the mosquitto clients may use them: diff --git a/pages/iot-hub/how-to/setup-use-rest-network.mdx b/pages/iot-hub/how-to/setup-use-rest-network.mdx index 1736e1c349..40363abc3b 100644 --- a/pages/iot-hub/how-to/setup-use-rest-network.mdx +++ b/pages/iot-hub/how-to/setup-use-rest-network.mdx @@ -49,9 +49,13 @@ The required headers are: * `X-Secret`: The network secret that was given while creating the network on a hub. * `X-Topic`: The topic that the message should be published on. -Following an example using [curl](https://curl.haxx.se/): +Following an example using the Scaleway CLI: ``` -> curl -XPOST -H "X-Secret: " -H "X-Topic: " -d +> scw iot network send-message \ +--secret= \ +--topic= \ +--payload= \ +--endpoint= ``` Use the following values: diff --git a/pages/key-manager/api-cli/create-dek-api-cli.mdx b/pages/key-manager/api-cli/create-dek-api-cli.mdx index 9c67d080de..8d8949bbc0 100644 --- a/pages/key-manager/api-cli/create-dek-api-cli.mdx +++ b/pages/key-manager/api-cli/create-dek-api-cli.mdx @@ -52,13 +52,9 @@ An output similar to the following should display: Paste the following command to create your data encryption key via the Key Manager API. Make sure that you replace the placeholder values with your own. ```bash - curl --location 'https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys//generate-data-key' \ - --header 'Content-Type: application/json' \ - --header 'X-Auth-Token: ' \ - --data '{ - "algorithm": "aes_256_gcm" - }' - ``` + scw keymanager key generate-data-key \ + --algorithm=aes_256_gcm \ + --region=fr-par Key Manager also supports the `GenerateDataKey` request without a plaintext operation, which only returns an encrypted data encryption key. diff --git a/pages/transactional-email/api-cli/send-emails-with-api.mdx b/pages/transactional-email/api-cli/send-emails-with-api.mdx index d9a8a6d442..681f1fd953 100644 --- a/pages/transactional-email/api-cli/send-emails-with-api.mdx +++ b/pages/transactional-email/api-cli/send-emails-with-api.mdx @@ -32,17 +32,17 @@ This page shows you how to send a simple transactional email in `JSON` format to 2. Run the following command to retrieve your domain's ID, as you will need it in the next step. The output should return your domain's information. ``` - curl -X GET \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - "https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/domains" + scw tem domain list \ + --region=fr-par ``` 3. Run the following command to ensure that your domain is verified: ``` - curl -X GET "https://api.scaleway.com/transactional-email/v1alpha1/regions/$REGION/domains/" \ - -H "X-Auth-Token: $SCW_SECRET_KEY" + scw tem domain get \ + --domain-id= \ + --region=$REGION ``` 4. Copy the following template. Make sure that you replace the placeholder information with your own. @@ -80,9 +80,13 @@ This page shows you how to send a simple transactional email in `JSON` format to } EOF - curl -X POST "https://api.scaleway.com/transactional-email/v1alpha1/regions/$REGION/emails" \ - -H "X-Auth-Token: $SCW_SECRET_KEY" \ - -d @mail.json + scw tem email create \ + --from-email=me@my.domain.example.com \ + --to-email=your.recipient@mail.fr \ + --subject="This is a subject" \ + --text="This is a short sentence." \ + --project-id= \ + --region=$REGION ``` 5. Once you have added your own information to the template above, run it in your terminal. An output similar to the following should display: @@ -94,10 +98,9 @@ This page shows you how to send a simple transactional email in `JSON` format to 6. Run the following command to check that your email has been sent. Make sure that you replace `$EMAIL_ID` with the ID of the email you retrieved in the output of the previous step. ``` - curl --request GET \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/emails/$EMAIL_ID \ - --header 'X-Auth-Token: $SCW_SECRET_KEY' - + scw tem email get \ + --email-id=$EMAIL_ID \ + --region=fr-par ``` You should get an output similar to the following: diff --git a/pages/transactional-email/api-cli/use-webhooks-with-sns-topics.mdx b/pages/transactional-email/api-cli/use-webhooks-with-sns-topics.mdx index 0190430d2a..ab762c31ec 100644 --- a/pages/transactional-email/api-cli/use-webhooks-with-sns-topics.mdx +++ b/pages/transactional-email/api-cli/use-webhooks-with-sns-topics.mdx @@ -43,19 +43,13 @@ You can set up webhooks for Scaleway Transactional Email and subscribe them to [ 5. Create a Transactional Email Webhook via the Scaleway API. Replace `{{sns_arn_id}}` with the ARN identifier you copied earlier. ```bash - curl --request POST \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks \ - --header 'X-Auth-Token: {{token}}' \ - --data '{ - "domain_id": "{{domain_id}}", - "project_id": "{{project_id}}", - "name": "My webhook name", - "event_types": [ - "email_delivered", - "email_dropped" - ], - "sns_arn": "{{sns_arn_id}}" - }' + scw tem webhook create \ + --domain-id={{domain_id}} \ + --project-id={{project_id}} \ + --name="My webhook name" \ + --event-types=email_delivered,email_dropped \ + --sns-arn={{sns_arn_id}} \ + --region=fr-par ``` @@ -75,48 +69,40 @@ You will find examples of such calls below: ### List Webhooks ```bash -curl --request GET \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks \ - --header 'X-Auth-Token: {{token}}' +scw tem webhook list \ +--region=fr-par ``` ### Get a Webhook ```bash -curl --request GET \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks/{{webhook_id}} \ - --header 'X-Auth-Token: {{token}}' +scw tem webhook get \ +--webhook-id={{webhook_id}} \ +--region=fr-par ``` ### Update a Webhook ```bash -curl --request PATCH \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks/{{webhook_id}} \ - --header 'X-Auth-Token: {{token}}' - --data '{ - "name": "new name", - "event_types": [ - "email_queued", - "email_mailbox_not_found", - "email_delivered", - "email_dropped" - ], - "sns_arn": "{{sns_arn_id}}" -}' +scw tem webhook update \ +--webhook-id={{webhook_id}} \ +--name="new name" \ +--event-types=email_queued,email_mailbox_not_found,email_delivered,email_dropped \ +--sns-arn={{sns_arn_id}} \ +--region=fr-par ``` ### List Webhook events ```bash -curl --request GET \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks/{{webhook_id}}/events \ - --header 'X-Auth-Token: {{token}}' +scw tem webhook list-events \ +--webhook-id={{webhook_id}} \ +--region=fr-par ``` ### Delete a Webhook ```bash -curl --request DELETE \ - --url https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks/{{webhook_id}} \ - --header 'X-Auth-Token: {{token}}' +scw tem webhook delete \ +--webhook-id={{webhook_id}} \ +--region=fr-par ``` diff --git a/pages/transactional-email/how-to/generate-api-keys-for-tem-with-iam.mdx b/pages/transactional-email/how-to/generate-api-keys-for-tem-with-iam.mdx index 37ae1b0af1..570089159c 100644 --- a/pages/transactional-email/how-to/generate-api-keys-for-tem-with-iam.mdx +++ b/pages/transactional-email/how-to/generate-api-keys-for-tem-with-iam.mdx @@ -57,9 +57,13 @@ cat > mail.json < \ +--region=$REGION ``` - If you have not configured your environment on your local machine, make sure you replace `\` with your [Project ID](/organizations-and-projects/concepts/#project), `$REGION` with `fr-par` and `$TOKEN` with your secret key. If you do not replace the Project ID, the API displays a "permission denied" error message.