Repository: scaleway/scaleway-cli
Pull request #2480 (2022-08-31 15:25:51)

feat: update Account URL and endpoints
### Community Note

* Please vote on this pull request by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original pull request comment to help the community and maintainers prioritize this request.
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

<!--- Thank you for keeping this note for the community --->

<!--- If your PR fully resolves and should automatically close the linked issue, use Closes. Otherwise, use Relates --->
Relates OR Closes #0000

Release note for [CHANGELOG](https://github.com/scaleway/scaleway-cli/blob/master/CHANGELOG.md):
<!--
If the change is not user facing, just write "NONE" in the release-note block below.
-->

```release-note

```


codecov-commenter: # [Codecov](https://codecov.io/gh/scaleway/scaleway-cli/pull/2480?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway) Report
> Merging [#2480](https://codecov.io/gh/scaleway/scaleway-cli/pull/2480?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway) (a8667b6) into [master](https://codecov.io/gh/scaleway/scaleway-cli/commit/8dddb0e984dc8669e6d04268f14e9931f1096006?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway) (8dddb0e) will **not change** coverage.
> The diff coverage is `0.00%`.

```diff
@@           Coverage Diff           @@
##           master    #2480   +/-   ##
=======================================
  Coverage   76.35%   76.35%           
=======================================
  Files         125      125           
  Lines       21408    21408           
=======================================
  Hits        16347    16347           
  Misses       4508     4508           
  Partials      553      553           
```


| [Impacted Files](https://codecov.io/gh/scaleway/scaleway-cli/pull/2480?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway) | Coverage Δ | |
|---|---|---|
| [internal/core/testing.go](https://codecov.io/gh/scaleway/scaleway-cli/pull/2480/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway#diff-aW50ZXJuYWwvY29yZS90ZXN0aW5nLmdv) | `64.50% <0.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scaleway)


Patch:
diff --git a/docs/migration_guide_v2.md b/docs/migration_guide_v2.md
index c0bd49a5..96df77d4 100644
--- a/docs/migration_guide_v2.md
+++ b/docs/migration_guide_v2.md
@@ -281,11 +281,11 @@ scw marketplace image list
 The constant URLs are not changing with the new CLI.
 You can still access them using their address.
 
-| Service     | URL                                    |
-|-------------|----------------------------------------|
-| account     | <https://account.scaleway.com>         |
-| metadata    | <http://169.254.42.42>                 |
-| marketplace | <https://api-marketplace.scaleway.com> |
+| Service     | URL                                        |
+|-------------|--------------------------------------------|
+| account     | <https://api.scaleway.com/account/v1>      |
+| metadata    | <http://169.254.42.42>                     |
+| marketplace | <https://api.scaleway.com/marketplace/v1>  |
 
 #### Quotas
 
@@ -293,16 +293,7 @@ CLI v2 does not support quotas at the moment.
 Your quotas can still be accessed through the [console](https://console.scaleway.com/account/user/profile) and the API:
 
 ```shell
-curl -H "X-Auth-Token: $SCW_SECRET_KEY" https://account.scaleway.com/organizations/$SCW_DEFAULT_ORGANIZATION_ID/quotas
-```
-
-#### Permissions
-
-Permission management is scoped at the organization level at the moment.
-You can still access the complete list of your permissions using the API:
-
-```shell
-curl -H "X-Auth-Token: $SCW_SECRET_KEY" https://account.scaleway.com/tokens/$SCW_SECRET_KEY/permissions
+curl -H "X-Auth-Token: $SCW_SECRET_KEY" https://api.scaleway.com/account/v1/organizations/$SCW_DEFAULT_ORGANIZATION_ID/quotas
 ```
 
 ### `scw inspect`
diff --git a/internal/account/account.go b/internal/account/account.go
index fdd2977b..cd28c199 100644
--- a/internal/account/account.go
+++ b/internal/account/account.go
@@ -33,7 +33,7 @@ type LoginRequest struct {
 }
 
 var (
-	accountURL = "https://account.scaleway.com"
+	accountURL = "https://api.scaleway.com/account/v1"
 )
 
 func GetAPIKey(ctx context.Context, secretKey string) (*Token, error) {


Test patch:
diff --git a/internal/core/testing.go b/internal/core/testing.go
index 8737c996..19963865 100644
--- a/internal/core/testing.go
+++ b/internal/core/testing.go
@@ -641,7 +641,7 @@ func getHTTPRecoder(t *testing.T, update bool) (client *http.Client, cleanup fun
 		delete(i.Request.Headers, "x-auth-token")
 		delete(i.Request.Headers, "X-Auth-Token")
 		i.Request.URL = regexp.MustCompile("organization_id=[0-9a-f-]{36}").ReplaceAllString(i.Request.URL, "organization_id=11111111-1111-1111-1111-111111111111")
-		i.Request.URL = regexp.MustCompile(`account\.scaleway\.com/tokens/[0-9a-f-]{36}`).ReplaceAllString(i.Request.URL, "account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111")
+		i.Request.URL = regexp.MustCompile(`api\.scaleway\.com/account/v1/tokens/[0-9a-f-]{36}`).ReplaceAllString(i.Request.URL, "api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111")
 		return nil
 	})
 
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-bash.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-bash.cassette.yaml
index 9e9525cf..d2111b74 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-bash.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-bash.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-fish.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-fish.cassette.yaml
index a9cac525..163bfa9f 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-fish.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-fish.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-without.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-without.cassette.yaml
index 3649268e..61587bda 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-without.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-without.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-zsh.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-zsh.cassette.yaml
index 6ffe3284..dfc94b81 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-darwin-zsh.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-darwin-zsh.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-linux-bash.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-linux-bash.cassette.yaml
index 0db329d2..b576b488 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-linux-bash.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-linux-bash.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-linux-fish.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-linux-fish.cassette.yaml
index 0db329d2..b576b488 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-linux-fish.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-linux-fish.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-linux-without.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-linux-without.cassette.yaml
index 0db329d2..b576b488 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-linux-without.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-linux-without.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-linux-zsh.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-linux-zsh.cassette.yaml
index 0db329d2..b576b488 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-linux-zsh.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-linux-zsh.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-windows-bash.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-windows-bash.cassette.yaml
index cc07045c..82f7d63d 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-windows-bash.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-windows-bash.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-windows-fish.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-windows-fish.cassette.yaml
index cc07045c..82f7d63d 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-windows-fish.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-windows-fish.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-windows-without.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-windows-without.cassette.yaml
index cc07045c..82f7d63d 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-windows-without.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-windows-without.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-autocomplete-windows-zsh.cassette.yaml b/internal/namespaces/init/testdata/test-init-autocomplete-windows-zsh.cassette.yaml
index cc07045c..82f7d63d 100644
--- a/internal/namespaces/init/testdata/test-init-autocomplete-windows-zsh.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-autocomplete-windows-zsh.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCW8XT5JRAV4B0WQSHPE", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-cl-iv2-config-overwrite.cassette.yaml b/internal/namespaces/init/testdata/test-init-cl-iv2-config-overwrite.cassette.yaml
index 36fded58..84dd39dc 100644
--- a/internal/namespaces/init/testdata/test-init-cl-iv2-config-overwrite.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-cl-iv2-config-overwrite.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-configuration-path.cassette.yaml b/internal/namespaces/init/testdata/test-init-configuration-path.cassette.yaml
index f3e89348..1c07e55e 100644
--- a/internal/namespaces/init/testdata/test-init-configuration-path.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-configuration-path.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-profile.cassette.yaml b/internal/namespaces/init/testdata/test-init-profile.cassette.yaml
index c7a319b4..918d213f 100644
--- a/internal/namespaces/init/testdata/test-init-profile.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-profile.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-simple.cassette.yaml b/internal/namespaces/init/testdata/test-init-simple.cassette.yaml
index c20d5073..71ea8d1f 100644
--- a/internal/namespaces/init/testdata/test-init-simple.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-simple.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-ssh-key-registered.cassette.yaml b/internal/namespaces/init/testdata/test-init-ssh-key-registered.cassette.yaml
index eca5d4ec..9ec797db 100644
--- a/internal/namespaces/init/testdata/test-init-ssh-key-registered.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-ssh-key-registered.cassette.yaml
@@ -42,7 +42,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-ssh-key-unregistered.cassette.yaml b/internal/namespaces/init/testdata/test-init-ssh-key-unregistered.cassette.yaml
index 25072b49..9c06d453 100644
--- a/internal/namespaces/init/testdata/test-init-ssh-key-unregistered.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-ssh-key-unregistered.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-ssh-no-local-key.cassette.yaml b/internal/namespaces/init/testdata/test-init-ssh-no-local-key.cassette.yaml
index affae6e9..d257de88 100644
--- a/internal/namespaces/init/testdata/test-init-ssh-no-local-key.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-ssh-no-local-key.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",
diff --git a/internal/namespaces/init/testdata/test-init-ssh-with-local-ed25519-key.cassette.yaml b/internal/namespaces/init/testdata/test-init-ssh-with-local-ed25519-key.cassette.yaml
index 50e1a03c..f04a0b52 100644
--- a/internal/namespaces/init/testdata/test-init-ssh-with-local-ed25519-key.cassette.yaml
+++ b/internal/namespaces/init/testdata/test-init-ssh-with-local-ed25519-key.cassette.yaml
@@ -5,7 +5,7 @@ interactions:
     body: ""
     form: {}
     headers: {}
-    url: https://account.scaleway.com/tokens/11111111-1111-1111-1111-111111111111
+    url: https://api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111
     method: GET
   response:
     body: '{"token": {"access_key": "SCWFEREJ5D3PW6WTVEH1", "user_id": "721f2fde-1a01-4854-822b-fcca5638d73e",