Skip to content

Commit ea952dd

Browse files
feat: rename project ID to organization ID
1 parent 91b4a64 commit ea952dd

File tree

15 files changed

+106
-106
lines changed

15 files changed

+106
-106
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func main() {
4444
// Create a Scaleway client
4545
client, err := scw.NewClient(
4646
// Get your credentials at https://console.scaleway.com/account/credentials
47-
scw.WithDefaultProjectID("ORGANISATION_ID"),
47+
scw.WithDefaultOrganizationID("ORGANISATION_ID"),
4848
scw.WithAuth("ACCESS_KEY", "SECRET_KEY"),
4949
)
5050
if err != nil {

api/baremetal/v1alpha1/baremetal_sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption)
567567
var err error
568568

569569
if req.OrganizationID == "" {
570-
defaultOrganizationID, _ := s.client.GetDefaultProjectID()
570+
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
571571
req.OrganizationID = defaultOrganizationID
572572
}
573573

api/instance/v1/instance_sdk.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ type ListServersRequest struct {
13681368
func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) {
13691369
var err error
13701370

1371-
defaultOrganization, exist := s.client.GetDefaultProjectID()
1371+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
13721372
if (req.Organization == nil || *req.Organization == "") && exist {
13731373
req.Organization = &defaultOrganization
13741374
}
@@ -1466,7 +1466,7 @@ func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption)
14661466
var err error
14671467

14681468
if req.Organization == "" {
1469-
defaultOrganization, _ := s.client.GetDefaultProjectID()
1469+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
14701470
req.Organization = defaultOrganization
14711471
}
14721472

@@ -1649,7 +1649,7 @@ func (s *API) setServer(req *setServerRequest, opts ...scw.RequestOption) (*setS
16491649
var err error
16501650

16511651
if req.Organization == "" {
1652-
defaultOrganization, _ := s.client.GetDefaultProjectID()
1652+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
16531653
req.Organization = defaultOrganization
16541654
}
16551655

@@ -1948,7 +1948,7 @@ type ListImagesRequest struct {
19481948
func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*ListImagesResponse, error) {
19491949
var err error
19501950

1951-
defaultOrganization, exist := s.client.GetDefaultProjectID()
1951+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
19521952
if (req.Organization == nil || *req.Organization == "") && exist {
19531953
req.Organization = &defaultOrganization
19541954
}
@@ -2075,7 +2075,7 @@ func (s *API) CreateImage(req *CreateImageRequest, opts ...scw.RequestOption) (*
20752075
var err error
20762076

20772077
if req.Organization == "" {
2078-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2078+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
20792079
req.Organization = defaultOrganization
20802080
}
20812081

@@ -2147,7 +2147,7 @@ func (s *API) setImage(req *setImageRequest, opts ...scw.RequestOption) (*setIma
21472147
var err error
21482148

21492149
if req.Organization == "" {
2150-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2150+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
21512151
req.Organization = defaultOrganization
21522152
}
21532153

@@ -2238,7 +2238,7 @@ type ListSnapshotsRequest struct {
22382238
func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption) (*ListSnapshotsResponse, error) {
22392239
var err error
22402240

2241-
defaultOrganization, exist := s.client.GetDefaultProjectID()
2241+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
22422242
if (req.Organization == nil || *req.Organization == "") && exist {
22432243
req.Organization = &defaultOrganization
22442244
}
@@ -2313,7 +2313,7 @@ func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOpti
23132313
var err error
23142314

23152315
if req.Organization == "" {
2316-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2316+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
23172317
req.Organization = defaultOrganization
23182318
}
23192319

@@ -2419,7 +2419,7 @@ func (s *API) setSnapshot(req *setSnapshotRequest, opts ...scw.RequestOption) (*
24192419
var err error
24202420

24212421
if req.Organization == "" {
2422-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2422+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
24232423
req.Organization = defaultOrganization
24242424
}
24252425

@@ -2516,7 +2516,7 @@ type ListVolumesRequest struct {
25162516
func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (*ListVolumesResponse, error) {
25172517
var err error
25182518

2519-
defaultOrganization, exist := s.client.GetDefaultProjectID()
2519+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
25202520
if (req.Organization == nil || *req.Organization == "") && exist {
25212521
req.Organization = &defaultOrganization
25222522
}
@@ -2615,7 +2615,7 @@ func (s *API) CreateVolume(req *CreateVolumeRequest, opts ...scw.RequestOption)
26152615
var err error
26162616

26172617
if req.Organization == "" {
2618-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2618+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
26192619
req.Organization = defaultOrganization
26202620
}
26212621

@@ -2744,7 +2744,7 @@ type ListSecurityGroupsRequest struct {
27442744
func (s *API) ListSecurityGroups(req *ListSecurityGroupsRequest, opts ...scw.RequestOption) (*ListSecurityGroupsResponse, error) {
27452745
var err error
27462746

2747-
defaultOrganization, exist := s.client.GetDefaultProjectID()
2747+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
27482748
if (req.Organization == nil || *req.Organization == "") && exist {
27492749
req.Organization = &defaultOrganization
27502750
}
@@ -2831,7 +2831,7 @@ func (s *API) CreateSecurityGroup(req *CreateSecurityGroupRequest, opts ...scw.R
28312831
var err error
28322832

28332833
if req.Organization == "" {
2834-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2834+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
28352835
req.Organization = defaultOrganization
28362836
}
28372837

@@ -2979,7 +2979,7 @@ func (s *API) setSecurityGroup(req *setSecurityGroupRequest, opts ...scw.Request
29792979
var err error
29802980

29812981
if req.Organization == "" {
2982-
defaultOrganization, _ := s.client.GetDefaultProjectID()
2982+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
29832983
req.Organization = defaultOrganization
29842984
}
29852985

@@ -3335,7 +3335,7 @@ type ListComputeClustersRequest struct {
33353335
func (s *API) ListComputeClusters(req *ListComputeClustersRequest, opts ...scw.RequestOption) (*ListComputeClustersResponse, error) {
33363336
var err error
33373337

3338-
defaultOrganization, exist := s.client.GetDefaultProjectID()
3338+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
33393339
if (req.Organization == nil || *req.Organization == "") && exist {
33403340
req.Organization = &defaultOrganization
33413341
}
@@ -3418,7 +3418,7 @@ func (s *API) CreateComputeCluster(req *CreateComputeClusterRequest, opts ...scw
34183418
var err error
34193419

34203420
if req.Organization == "" {
3421-
defaultOrganization, _ := s.client.GetDefaultProjectID()
3421+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
34223422
req.Organization = defaultOrganization
34233423
}
34243424

@@ -3516,7 +3516,7 @@ func (s *API) SetComputeCluster(req *SetComputeClusterRequest, opts ...scw.Reque
35163516
var err error
35173517

35183518
if req.Organization == "" {
3519-
defaultOrganization, _ := s.client.GetDefaultProjectID()
3519+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
35203520
req.Organization = defaultOrganization
35213521
}
35223522

@@ -3577,7 +3577,7 @@ type UpdateComputeClusterRequest struct {
35773577
func (s *API) UpdateComputeCluster(req *UpdateComputeClusterRequest, opts ...scw.RequestOption) (*UpdateComputeClusterResponse, error) {
35783578
var err error
35793579

3580-
defaultOrganization, exist := s.client.GetDefaultProjectID()
3580+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
35813581
if (req.Organization == nil || *req.Organization == "") && exist {
35823582
req.Organization = &defaultOrganization
35833583
}
@@ -3827,7 +3827,7 @@ type ListIpsRequest struct {
38273827
func (s *API) ListIps(req *ListIpsRequest, opts ...scw.RequestOption) (*ListIpsResponse, error) {
38283828
var err error
38293829

3830-
defaultOrganization, exist := s.client.GetDefaultProjectID()
3830+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
38313831
if (req.Organization == nil || *req.Organization == "") && exist {
38323832
req.Organization = &defaultOrganization
38333833
}
@@ -3900,7 +3900,7 @@ func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*Create
39003900
var err error
39013901

39023902
if req.Organization == "" {
3903-
defaultOrganization, _ := s.client.GetDefaultProjectID()
3903+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
39043904
req.Organization = defaultOrganization
39053905
}
39063906

@@ -3991,7 +3991,7 @@ func (s *API) setIP(req *setIPRequest, opts ...scw.RequestOption) (*setIPRespons
39913991
var err error
39923992

39933993
if req.Organization == "" {
3994-
defaultOrganization, _ := s.client.GetDefaultProjectID()
3994+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
39953995
req.Organization = defaultOrganization
39963996
}
39973997

@@ -4239,7 +4239,7 @@ type GetDashboardRequest struct {
42394239
func (s *API) GetDashboard(req *GetDashboardRequest, opts ...scw.RequestOption) (*GetDashboardResponse, error) {
42404240
var err error
42414241

4242-
defaultOrganization, exist := s.client.GetDefaultProjectID()
4242+
defaultOrganization, exist := s.client.GetDefaultOrganizationID()
42434243
if (req.Organization == nil || *req.Organization == "") && exist {
42444244
req.Organization = &defaultOrganization
42454245
}

api/lb/v1/lb_sdk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ type ListLbsRequest struct {
11921192
func (s *API) ListLbs(req *ListLbsRequest, opts ...scw.RequestOption) (*ListLbsResponse, error) {
11931193
var err error
11941194

1195-
defaultOrganizationID, exist := s.client.GetDefaultProjectID()
1195+
defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
11961196
if (req.OrganizationID == nil || *req.OrganizationID == "") && exist {
11971197
req.OrganizationID = &defaultOrganizationID
11981198
}
@@ -1273,7 +1273,7 @@ func (s *API) CreateLb(req *CreateLbRequest, opts ...scw.RequestOption) (*Lb, er
12731273
var err error
12741274

12751275
if req.OrganizationID == "" {
1276-
defaultOrganizationID, _ := s.client.GetDefaultProjectID()
1276+
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
12771277
req.OrganizationID = defaultOrganizationID
12781278
}
12791279

@@ -1448,7 +1448,7 @@ type ListIPsRequest struct {
14481448
func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIpsResponse, error) {
14491449
var err error
14501450

1451-
defaultOrganizationID, exist := s.client.GetDefaultProjectID()
1451+
defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
14521452
if (req.OrganizationID == nil || *req.OrganizationID == "") && exist {
14531453
req.OrganizationID = &defaultOrganizationID
14541454
}

scw/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Recommended config file:
88
# get your credentials on https://console.scaleway.com/account/credentials
99
access_key: SCWXXXXXXXXXXXXXXXXX
1010
secret_key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
11-
default_project_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
11+
default_organization_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1212
default_region: fr-par
1313
default_zone: fr-par-1
1414
```
@@ -47,7 +47,7 @@ scw.NewClient(
4747
| :------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
4848
| `$SCW_ACCESS_KEY` | Access key of a token ([get yours](https://console.scaleway.com/account/credentials)) | `$SCALEWAY_ACCESS_KEY` (used by terraform) |
4949
| `$SCW_SECRET_KEY` | Secret key of a token ([get yours](https://console.scaleway.com/account/credentials)) | `$SCW_TOKEN` (used by cli), `$SCALEWAY_TOKEN` (used by terraform), `$SCALEWAY_ACCESS_KEY` (used by terraform) |
50-
| `$SCW_DEFAULT_PROJECT_ID` | Your default project ID, if you don't have one use your organization ID ([get yours](https://console.scaleway.com/account/credentials)) | `$SCW_ORGANIZATION` (used by cli),`$SCALEWAY_ORGANIZATION` (used by terraform) |
50+
| `$SCW_DEFAULT_ORGANIZATION_ID` | Your default organization ID, if you don't have one use your organization ID ([get yours](https://console.scaleway.com/account/credentials)) | `$SCW_ORGANIZATION` (used by cli),`$SCALEWAY_ORGANIZATION` (used by terraform) |
5151
| `$SCW_DEFAULT_REGION` | Your default [region](https://developers.scaleway.com/en/quickstart/#region-and-zone) | `$SCW_REGION` (used by cli),`$SCALEWAY_REGION` (used by terraform) |
5252
| `$SCW_DEFAULT_ZONE` | Your default [availability zone](https://developers.scaleway.com/en/quickstart/#region-and-zone) | `$SCW_ZONE` (used by cli),`$SCALEWAY_ZONE` (used by terraform) |
5353
| `$SCW_API_URL` | Url of the API | - |

scw/client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Client struct {
2727
auth auth.Auth
2828
apiURL string
2929
userAgent string
30-
defaultProjectID *string
30+
defaultOrganizationID *string
3131
defaultRegion *Region
3232
defaultZone *Zone
3333
defaultPageSize *int32
@@ -74,19 +74,19 @@ func NewClient(opts ...ClientOption) (*Client, error) {
7474
httpClient: s.httpClient,
7575
apiURL: s.apiURL,
7676
userAgent: s.userAgent,
77-
defaultProjectID: s.defaultProjectID,
77+
defaultOrganizationID: s.defaultOrganizationID,
7878
defaultRegion: s.defaultRegion,
7979
defaultZone: s.defaultZone,
8080
defaultPageSize: s.defaultPageSize,
8181
}, nil
8282
}
8383

84-
// GetDefaultProjectID return the default project ID
84+
// GetDefaultOrganizationID return the default organization ID
8585
// of the client. This value can be set in the client option
86-
// WithDefaultProjectID(). Be aware this value can be empty.
87-
func (c *Client) GetDefaultProjectID() (string, bool) {
88-
if c.defaultProjectID != nil {
89-
return *c.defaultProjectID, true
86+
// WithDefaultOrganizationID(). Be aware this value can be empty.
87+
func (c *Client) GetDefaultOrganizationID() (string, bool) {
88+
if c.defaultOrganizationID != nil {
89+
return *c.defaultOrganizationID, true
9090
}
9191
return "", false
9292
}

scw/client_option.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func WithProfile(p *Profile) ClientOption {
8888
s.insecure = *p.Insecure
8989
}
9090

91-
if p.DefaultProjectID != nil {
92-
projectID := *p.DefaultProjectID
93-
s.defaultProjectID = &projectID
91+
if p.DefaultOrganizationID != nil {
92+
organizationID := *p.DefaultOrganizationID
93+
s.defaultOrganizationID = &organizationID
9494
}
9595

9696
if p.DefaultRegion != nil {
@@ -110,12 +110,12 @@ func WithEnv() ClientOption {
110110
return WithProfile(LoadEnvProfile())
111111
}
112112

113-
// WithDefaultProjectID client option sets the client default project ID.
113+
// WithDefaultOrganizationID client option sets the client default organization ID.
114114
//
115-
// It will be used as the default value of the project_id field in all requests made with this client.
116-
func WithDefaultProjectID(projectID string) ClientOption {
115+
// It will be used as the default value of the organization_id field in all requests made with this client.
116+
func WithDefaultOrganizationID(organizationID string) ClientOption {
117117
return func(s *settings) {
118-
s.defaultProjectID = &projectID
118+
s.defaultOrganizationID = &organizationID
119119
}
120120
}
121121

@@ -153,7 +153,7 @@ type settings struct {
153153
userAgent string
154154
httpClient httpClient
155155
insecure bool
156-
defaultProjectID *string
156+
defaultOrganizationID *string
157157
defaultRegion *Region
158158
defaultZone *Zone
159159
defaultPageSize *int32
@@ -180,9 +180,9 @@ func (s *settings) validate() error {
180180
return errors.Wrap(err, "invalid url %s", s.apiURL)
181181
}
182182

183-
// TODO: Check ProjectID format
184-
if s.defaultProjectID != nil && *s.defaultProjectID == "" {
185-
return errors.New("default project id cannot be empty")
183+
// TODO: Check OrganizationID format
184+
if s.defaultOrganizationID != nil && *s.defaultOrganizationID == "" {
185+
return errors.New("default organization id cannot be empty")
186186
}
187187

188188
// TODO: Check Region format

0 commit comments

Comments
 (0)