Skip to content

Commit 65df83d

Browse files
authored
Merge branch 'master' into feat/rdb-actions
2 parents 0e36c2d + e00b6fe commit 65df83d

File tree

14 files changed

+174
-115
lines changed

14 files changed

+174
-115
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
subcategory: "Cockpit"
3+
page_title: "Scaleway: scaleway_cockpit_trigger_test_alert_action"
4+
---
5+
6+
# scaleway_cockpit_trigger_test_alert_action (Action)
7+
8+
<!-- action schema generated by tfplugindocs -->
9+
## Schema
10+
11+
### Required
12+
13+
- `project_id` (String) ID of the Project
14+
15+
### Optional
16+
17+
- `region` (String) The region you want to attach the resource to
18+
19+
20+

docs/data-sources/account_project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ page_title: "Scaleway: scaleway_account_project"
55

66
# scaleway_account_project
77

8-
The `scaleway_account_project` data source is used to retrieve information about a Scaleway project.
8+
The [`scaleway_account_project`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/account_project) data source is used to retrieve information about a Scaleway project.
99

1010
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.
1111

docs/data-sources/account_projects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ page_title: "Scaleway: scaleway_account_projects"
55

66
# scaleway_account_projects
77

8-
The `scaleway_account_projects` data source is used to list all Scaleway projects in an Organization.
8+
The [`scaleway_account_projects`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/account_projects) data source is used to list all Scaleway projects in an Organization.
99

1010
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.
1111

docs/resources/account_project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ page_title: "Scaleway: scaleway_account_project"
55

66
# Resource: scaleway_account_project
77

8-
The `scaleway_account_project` resource allows you to create and manage the Projects of a Scaleway Organization.
8+
The [`scaleway_account_project`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/account_project) resource allows you to create and manage the Projects of a Scaleway Organization.
99

1010
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.
1111

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The [`scaleway_account_project`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/account_project) resource allows you to create and manage the Projects of a Scaleway Organization.
2+
3+
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The [`scaleway_account_project`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/account_project) data source is used to retrieve information about a Scaleway project.
2+
3+
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The [`scaleway_account_projects`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/account_projects) data source is used to list all Scaleway projects in an Organization.
2+
3+
Refer to the Organizations and Projects [documentation](https://www.scaleway.com/en/docs/organizations-and-projects/) and [API documentation](https://www.scaleway.com/en/developers/api/account/project-api/) for more information.

internal/services/account/project.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package account
22

33
import (
44
"context"
5+
_ "embed"
56

67
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
@@ -13,8 +14,12 @@ import (
1314
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
1415
)
1516

17+
//go:embed descriptions/project.md
18+
var projectDescription string
19+
1620
func ResourceProject() *schema.Resource {
1721
return &schema.Resource{
22+
Description: projectDescription,
1823
CreateContext: resourceAccountProjectCreate,
1924
ReadContext: resourceAccountProjectRead,
2025
UpdateContext: resourceAccountProjectUpdate,

internal/services/account/project_data_source.go

Lines changed: 5 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package account
22

33
import (
44
"context"
5+
_ "embed"
56

6-
"github.com/google/uuid"
77
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
99
accountSDK "github.com/scaleway/scaleway-sdk-go/api/account/v3"
@@ -14,6 +14,9 @@ import (
1414
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
1515
)
1616

17+
//go:embed descriptions/project_datasource.md
18+
var projectDataSourceDescription string
19+
1720
func DataSourceProject() *schema.Resource {
1821
dsSchema := datasource.SchemaFromResourceSchema(ResourceProject().SchemaFunc())
1922
datasource.AddOptionalFieldsToSchema(dsSchema, "name", "organization_id")
@@ -30,6 +33,7 @@ func DataSourceProject() *schema.Resource {
3033
return &schema.Resource{
3134
ReadContext: DataSourceAccountProjectRead,
3235
Schema: dsSchema,
36+
Description: projectDataSourceDescription,
3337
}
3438
}
3539

@@ -86,105 +90,3 @@ func DataSourceAccountProjectRead(ctx context.Context, d *schema.ResourceData, m
8690

8791
return nil
8892
}
89-
90-
func DataSourceProjects() *schema.Resource {
91-
dsSchema := datasource.SchemaFromResourceSchema(ResourceProject().SchemaFunc())
92-
datasource.AddOptionalFieldsToSchema(dsSchema, "organization_id")
93-
94-
dsSchema["organization_id"] = &schema.Schema{
95-
Type: schema.TypeString,
96-
Computed: true,
97-
Optional: true,
98-
Description: "The ID of the organization",
99-
ValidateDiagFunc: verify.IsUUID(),
100-
}
101-
dsSchema["projects"] = &schema.Schema{
102-
Type: schema.TypeList,
103-
Computed: true,
104-
Description: "The list of projects",
105-
Elem: &schema.Resource{
106-
Schema: map[string]*schema.Schema{
107-
"id": {
108-
Type: schema.TypeString,
109-
Computed: true,
110-
Description: "ID of the Project",
111-
},
112-
"name": {
113-
Type: schema.TypeString,
114-
Computed: true,
115-
Description: "Name of the Project",
116-
},
117-
"organization_id": {
118-
Type: schema.TypeString,
119-
Computed: true,
120-
Description: "Organization ID of the Project",
121-
},
122-
"created_at": {
123-
Type: schema.TypeString,
124-
Computed: true,
125-
Description: "Creation date of the Project",
126-
},
127-
"updated_at": {
128-
Type: schema.TypeString,
129-
Computed: true,
130-
Description: "Update date of the Project",
131-
},
132-
"description": {
133-
Type: schema.TypeString,
134-
Computed: true,
135-
Description: "Description of the Project",
136-
},
137-
},
138-
},
139-
}
140-
141-
return &schema.Resource{
142-
ReadContext: DataSourceAccountProjectsRead,
143-
Schema: dsSchema,
144-
}
145-
}
146-
147-
func DataSourceAccountProjectsRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
148-
accountAPI := NewProjectAPI(m)
149-
150-
var orgID *string
151-
152-
if v, orgIDExists := d.GetOk("organization_id"); orgIDExists {
153-
orgID = types.ExpandStringPtr(v)
154-
} else {
155-
orgID = GetOrganizationID(m, d)
156-
}
157-
158-
if orgID == nil {
159-
return diag.Errorf("organization_id was not specified nor found in the provider configuration")
160-
}
161-
162-
res, err := accountAPI.ListProjects(&accountSDK.ProjectAPIListProjectsRequest{
163-
OrganizationID: *orgID,
164-
}, scw.WithContext(ctx))
165-
if err != nil {
166-
return diag.FromErr(err)
167-
}
168-
169-
d.SetId(uuid.New().String())
170-
_ = d.Set("projects", flattenProjects(res.Projects))
171-
_ = d.Set("organization_id", orgID)
172-
173-
return nil
174-
}
175-
176-
func flattenProjects(projects []*accountSDK.Project) []map[string]any {
177-
flattenedProjects := make([]map[string]any, len(projects))
178-
for i, project := range projects {
179-
flattenedProjects[i] = map[string]any{
180-
"id": project.ID,
181-
"name": project.Name,
182-
"organization_id": project.OrganizationID,
183-
"created_at": types.FlattenTime(project.CreatedAt),
184-
"updated_at": types.FlattenTime(project.UpdatedAt),
185-
"description": project.Description,
186-
}
187-
}
188-
189-
return flattenedProjects
190-
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package account
2+
3+
import (
4+
"context"
5+
_ "embed"
6+
7+
"github.com/google/uuid"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
accountSDK "github.com/scaleway/scaleway-sdk-go/api/account/v3"
11+
"github.com/scaleway/scaleway-sdk-go/scw"
12+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource"
13+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
14+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
15+
)
16+
17+
//go:embed descriptions/projects_datasource.md
18+
var projectsDataSourceDescription string
19+
20+
func DataSourceProjects() *schema.Resource {
21+
dsSchema := datasource.SchemaFromResourceSchema(ResourceProject().SchemaFunc())
22+
datasource.AddOptionalFieldsToSchema(dsSchema, "organization_id")
23+
24+
dsSchema["organization_id"] = &schema.Schema{
25+
Type: schema.TypeString,
26+
Computed: true,
27+
Optional: true,
28+
Description: "The ID of the organization",
29+
ValidateDiagFunc: verify.IsUUID(),
30+
}
31+
dsSchema["projects"] = &schema.Schema{
32+
Type: schema.TypeList,
33+
Computed: true,
34+
Description: "The list of projects",
35+
Elem: &schema.Resource{
36+
Schema: map[string]*schema.Schema{
37+
"id": {
38+
Type: schema.TypeString,
39+
Computed: true,
40+
Description: "ID of the Project",
41+
},
42+
"name": {
43+
Type: schema.TypeString,
44+
Computed: true,
45+
Description: "Name of the Project",
46+
},
47+
"organization_id": {
48+
Type: schema.TypeString,
49+
Computed: true,
50+
Description: "Organization ID of the Project",
51+
},
52+
"created_at": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
Description: "Creation date of the Project",
56+
},
57+
"updated_at": {
58+
Type: schema.TypeString,
59+
Computed: true,
60+
Description: "Update date of the Project",
61+
},
62+
"description": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
Description: "Description of the Project",
66+
},
67+
},
68+
},
69+
}
70+
71+
return &schema.Resource{
72+
ReadContext: DataSourceAccountProjectsRead,
73+
Schema: dsSchema,
74+
Description: projectsDataSourceDescription,
75+
}
76+
}
77+
78+
func DataSourceAccountProjectsRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
79+
accountAPI := NewProjectAPI(m)
80+
81+
var orgID *string
82+
83+
if v, orgIDExists := d.GetOk("organization_id"); orgIDExists {
84+
orgID = types.ExpandStringPtr(v)
85+
} else {
86+
orgID = GetOrganizationID(m, d)
87+
}
88+
89+
if orgID == nil {
90+
return diag.Errorf("organization_id was not specified nor found in the provider configuration")
91+
}
92+
93+
res, err := accountAPI.ListProjects(&accountSDK.ProjectAPIListProjectsRequest{
94+
OrganizationID: *orgID,
95+
}, scw.WithContext(ctx))
96+
if err != nil {
97+
return diag.FromErr(err)
98+
}
99+
100+
d.SetId(uuid.New().String())
101+
_ = d.Set("projects", flattenProjects(res.Projects))
102+
_ = d.Set("organization_id", orgID)
103+
104+
return nil
105+
}

0 commit comments

Comments
 (0)