Skip to content

Commit 33305ef

Browse files
fix(onp): iso quickstart api (#5895)
* fix(onp): iso quickstart api * fix(onp): review
1 parent 21923c2 commit 33305ef

File tree

1 file changed

+112
-128
lines changed

1 file changed

+112
-128
lines changed

pages/organizations-and-projects/api-cli/managing-projects.mdx

Lines changed: 112 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -13,137 +13,121 @@ This page explains how to manage Projects using [Scaleway APIs](https://www.scal
1313

1414
<Requirements />
1515

16-
- A Scaleway account logged into the [console](https://console.scaleway.com)
17-
- [Configured your API keys](/iam/how-to/create-api-keys/)
18-
- An API key with the [`IAMManager` or `ProjectManager` permission sets](/iam/reference-content/permission-sets/)
19-
20-
## Creating a Project
21-
22-
You need your secret key and your Organization ID for the step below.
23-
24-
Open a terminal and type the following command to create a Project. If you have not configured your environment in your local machine, make sure you replace `$SCW_SECRET_KEY` with your secret key and `$SCW_DEFAULT_ORGANIZATION_ID` with the ID of your Organization.
25-
```
26-
curl -XPOST https://api.scaleway.com/account/v2/projects -H 'X-Auth-Token: $SCW_SECRET_KEY' -d '{"organization_id":"$SCW_DEFAULT_ORGANIZATION_ID","name":"name-of-project"}'
27-
```
28-
An output similar to the following displays:
29-
```
30-
{
31-
"id":"6170692e-7363-616c-6577-61792e636f6d",
32-
"name":"test-project",
33-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
34-
"created_at":"2022-07-19T15:02:43.455727Z",
35-
"updated_at":"2022-07-19T15:02:43.455727Z",
36-
"description":""
37-
}
38-
```
39-
40-
## Updating Projects
41-
42-
You need your secret key and the ID of the Project you want to update for the step below. For this use case, we are updating the Project created in the step above.
43-
<Message type="note">
44-
You can only update the name and description of your Project.
45-
</Message>
46-
Type the following command into your terminal to update your Project:
47-
```
48-
curl -XPATCH https://api.scaleway.com/account/v2/projects/<SCW_PROJECT_ID> -H 'X-Auth-Token: $SCW_SECRET_KEY' -d '{"name":"new-project", "description": "This is my updated project" }'
49-
```
50-
An output similar to the following displays:
51-
```
52-
{
53-
"id":"6170692e-7363-616c-6577-61792e636f6d",
54-
"name":"new-project",
55-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
56-
"created_at":"2022-07-19T15:02:43.455727Z",
57-
"updated_at":"2022-07-19T15:29:27.762100Z",
58-
"description":"This is my updated project"
59-
}
60-
```
61-
62-
## Listing all your Projects
63-
64-
<Message type="note">
65-
- There is a default Project in all Organizations.
66-
- The default Project's Project ID is the same as the Organization ID.
67-
- The default Project cannot be deleted.
68-
</Message>
69-
70-
You need your secret key and your Organization ID for the step below.
71-
72-
Type the following command into your terminal to list your Projects:
73-
```
74-
curl -XGET https://api.scaleway.com/account/v2/projects\?organization_id\=<SCW_DEFAULT_ORGANIZATION_ID>&page=1&page_size=10&order_by=created_at_asc -H 'X-Auth-Token: $SCW_SECRET_KEY'
75-
```
76-
An output similar to the following displays:
77-
```
78-
{
79-
"total_count":2,
80-
"projects":[
81-
{
82-
"id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
83-
"name":"default",
84-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
85-
"created_at":"2021-07-06T15:15:48.375181Z",
86-
"updated_at":"2021-07-06T15:15:48.375181Z",
87-
"description":""
88-
},
89-
{
90-
"id":"6170692e-7363-616c-6577-61792e636f6d",
91-
"name":"new-project",
92-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
93-
"created_at":"2022-07-19T15:02:43.455727Z",
94-
"updated_at":"2022-07-19T15:29:27.762100Z",
95-
"description":"This is my updated project"
96-
}
97-
]
98-
}
99-
```
100-
101-
## Retrieving a specific Project
102-
103-
You need your secret key and the ID of the Project you want to get for the step below. For this use case, we are getting the Project we have updated in the [updating Projects step](/organizations-and-projects/api-cli/managing-projects/#updating-projects).
104-
105-
Type the following command to list a specific Project.
106-
```
107-
curl -XGET https://api.scaleway.com/account/v2/projects/<SCW_PROJECT_ID> -H 'X-Auth-Token: $SCW_SECRET_KEY'
108-
```
109-
An output similar to the following displays:
110-
```
111-
{
112-
"id":"6170692e-7363-616c-6577-61792e636f6d",
113-
"name":"new-project",
114-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
115-
"created_at":"2022-07-19T15:02:43.455727Z",
116-
"updated_at":"2022-07-19T15:29:27.762100Z",
117-
"description":"This is my updated project"
118-
}
119-
```
120-
121-
## Deleting a Project
122-
123-
You need your secret key and the ID of the Project you want to delete for the step below. For this use case, we are deleting the Project we have created in the [creating a Project step](/organizations-and-projects/api-cli/managing-projects/#creating-a-project).
124-
125-
1. Type the following command to delete a Project.
16+
- A [Scaleway account](https://console.scaleway.com/) and you know your Organization ID
17+
- An [API key](https://www.scaleway.com/en/docs/iam/how-to/create-api-keys/) and that the API key has sufficient [IAM permissions](https://www.scaleway.com/en/docs/iam/reference-content/permission-sets/) to perform the actions described on this page
18+
- Your [Organization ID](https://console.scaleway.com/organization/settings)
19+
- [Installed `curl`](https://curl.se/download.html)
20+
21+
1. Configure your environment variables.
22+
23+
<Message type="note">
24+
This is an optional step that seeks to simplify your usage of the APIs.
25+
</Message>
26+
27+
```bash
28+
export SCW_SECRET_KEY="<API secret key>"
29+
```
30+
31+
2. Edit the **POST** request payload you will use to create a Project.
32+
33+
Replace the parameters in the following example:
34+
35+
```json
36+
'{
37+
"name": "project-name",
38+
"organization_id": "b12d5c3g-c612-5674-c1e9-92627f36c5b9",
39+
"description": "This is the description of my Project",
40+
}'
12641
```
127-
curl -XDELETE https://api.scaleway.com/account/v2/projects/<YOUR_PROJECT_ID> -H 'X-Auth-Token: $SCW_SECRET_KEY'
42+
43+
| Parameter | Description |
44+
| :---------------- | :------------------------------------------------- |
45+
| `name` | Name for the Project you want to create. |
46+
| `organization_id` | ID of the Organization in which to create the Project. It must be in UUID format. |
47+
| `description` | Description for the Project you want to create. |
48+
49+
3. Run the following command to create a Project:
50+
51+
Make sure you include the payload you edited in the previous step.
52+
53+
```bash
54+
curl -X POST \
55+
-H "X-Auth-Token: $SCW_SECRET_KEY" \
56+
-H "Content-Type: application/json" \
57+
"https://api.scaleway.com/account/v3/projects" \
58+
-d '{
59+
"name": "Dis-Iz-My-Projekt",
60+
"organization_id": "b12d5c3g-c612-5674-c1e9-92627f36c5b9",
61+
"type": "This is the description of my Project"
62+
}'
12863
```
129-
2. Run the following command to list your Projects and make sure you have deleted your Project.
64+
65+
You should get a response like the following:
66+
67+
<Message type="note">
68+
This is a response example, the UUIDs displayed are not real.
69+
</Message>
70+
71+
```bash
72+
{
73+
"id": "6170692e-7363-616c-6577-61792e636f6d",
74+
"name": "Dis-Iz-My-Projekt",
75+
"organization_id": "b12d5c3g-c612-5674-c1e9-92627f36c5b9",
76+
"created_at": "2023-03-02T22:00:28.888380Z",
77+
"updated_at": "2023-03-02T22:00:28.888380Z",
78+
"description": "This is the description of my project"
79+
}
13080
```
131-
curl -XGET https://api.scaleway.com/account/v2/projects\?organization_id\=<SCW_DEFAULT_ORGANIZATION_ID> -H "X-Auth-Token: $SCW_SECRET_KEY"
81+
82+
4. Run the following command to list your Projects. Replace the Organization ID in the endpoint with your own Organization ID.
83+
84+
```bash
85+
curl -X GET \
86+
-H "X-Auth-Token: $SCW_SECRET_KEY" \
87+
-H "Content-Type: application/json" \
88+
"https://api.scaleway.com/account/v3/projects?organization_id=b12d5c3g-c612-5674-c1e9-92627f36c5b9"
13289
```
13390

134-
An output similar to the following displays, confirming that you have one Project left:
135-
```
136-
{
137-
"total_count": 1,
138-
"projects": [
139-
{
140-
"id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
141-
"name":"default",
142-
"organization_id":"3e44a89e-1f75-45f5-9b93-422db94165eb",
143-
"created_at":"2021-07-06T15:15:48.375181Z",
144-
"updated_at":"2021-07-06T15:15:48.375181Z",
145-
"description":""
146-
}
91+
You should get a response like the following:
92+
93+
```bash
94+
{
95+
"total_count": "2",
96+
"projects": [
97+
{
98+
"id": "0fe11800-ddbb-4b62-8906-ed08780cdddb",
99+
"name": "default",
100+
"organization_id": "b12d5c3g-c612-5674-c1e9-92627f36c5b9",
101+
"created_at": "2022-08-31T07:45:53.657735Z",
102+
"updated_at": "2022-08-31T07:45:53.657735Z",
103+
"description": "cannot_be_deleted"
104+
},
105+
{
106+
"id":"6170692e-7363-616c-6577-61792e636f6d",
107+
"name":"Dis-Iz-My-Projekt",
108+
"organization_id":"b12d5c3g-c612-5674-c1e9-92627f36c5b9",
109+
"created_at":"2023-03-02T22:00:28.888380Z",
110+
"updated_at":"2023-03-02T22:00:28.888380Z",
111+
"description":"This is the description of my Project"
112+
},
147113
]
148-
}
149-
```
114+
}
115+
```
116+
117+
5. Run the following command to update a Project's name and description.
118+
<Message type="note">
119+
Do not forget to replace the Project ID in the endpoint, and the Organization ID in the payload, with your own. You can retrieve the Project ID from the "List Project" response above.
120+
</Message>
121+
122+
```bash
123+
curl -X PATCH \
124+
-H "X-Auth-Token: $SCW_SECRET_KEY" \
125+
-H "Content-Type: application/json" \
126+
"https://api.scaleway.com/account/v3/projects/6170692e-7363-616c-6577-61792e636f6d" \
127+
-d '{
128+
"name": "Dis-Iz-My-Updated-Projekt",
129+
"organization_id": "b12d5c3g-c612-5674-c1e9-92627f36c5b9",
130+
"description": "This is the updated description of my Project"
131+
}'
132+
```
133+

0 commit comments

Comments
 (0)