diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-create-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-create-usage.golden new file mode 100644 index 0000000000..76575d7af2 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-create-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +You can use the `ipns key` command to list and generate more names and their respective keys. + +USAGE: + scw ipns name create [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [name] Name for your records + [value] Value you want to associate with your records, CID or IPNS key + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for create + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-delete-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-delete-usage.golden new file mode 100644 index 0000000000..73065319ec --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a name by its ID. + +USAGE: + scw ipns name delete [arg=value ...] + +ARGS: + name-id Name ID you wish to delete + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for delete + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-export-key-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-export-key-usage.golden new file mode 100644 index 0000000000..b2a653a911 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-export-key-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Export a private key by its ID. + +USAGE: + scw ipns name export-key [arg=value ...] + +ARGS: + name-id Name ID whose keys you want to export + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for export-key + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-get-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-get-usage.golden new file mode 100644 index 0000000000..cf7b5dcb78 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Retrieve information about a specific name. + +USAGE: + scw ipns name get [arg=value ...] + +ARGS: + name-id Name ID whose information you want to retrieve + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-import-key-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-import-key-usage.golden new file mode 100644 index 0000000000..5f298a9f89 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-import-key-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Import a private key. + +USAGE: + scw ipns name import-key [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [name] Name for your records + private-key Base64 private key + [value] Value you want to associate with your records, CID or IPNS key + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for import-key + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-list-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-list-usage.golden new file mode 100644 index 0000000000..5e7a2180d0 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-list-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Retrieve information about all names from a Project ID. + +USAGE: + scw ipns name list [arg=value ...] + +ARGS: + [project-id] Project ID + [order-by] Sort the order of the returned names (created_at_asc | created_at_desc) + [organization-id] Organization ID + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw | all) + +FLAGS: + -h, --help help for list + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-update-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-update-usage.golden new file mode 100644 index 0000000000..0b0d5430da --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-update-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update name information (CID, tag, name...). + +USAGE: + scw ipns name update [arg=value ...] + +ARGS: + name-id Name ID you wish to update + [name] New name you want to associate with your record + [tags.{index}] New tags you want to associate with your record + [value] Value you want to associate with your records, CID or IPNS key + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) + +FLAGS: + -h, --help help for update + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-ipns-name-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-name-usage.golden new file mode 100644 index 0000000000..a32ce471e0 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-name-usage.golden @@ -0,0 +1,26 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +This is the PKI namespace, where the private key is used to publish (sign) a record. + +USAGE: + scw ipns name + +AVAILABLE COMMANDS: + create Create a new name + delete Delete an existing name + export-key Export your private key + get Get information about a name + import-key Import your private key + list List all names by a Project ID + update Update name information + +FLAGS: + -h, --help help for name + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw ipns name [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-ipns-usage.golden b/cmd/scw/testdata/test-all-usage-ipns-usage.golden new file mode 100644 index 0000000000..e4b76446b0 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-ipns-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +IPFS Naming service API + +USAGE: + scw ipns + +AVAILABLE COMMANDS: + name A name is a hash of the public key within the IPNS (InterPlanetary Name System) + +FLAGS: + -h, --help help for ipns + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw ipns [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-main-usage-usage.golden b/cmd/scw/testdata/test-main-usage-usage.golden index 57cf12656a..3c2cde74a4 100644 --- a/cmd/scw/testdata/test-main-usage-usage.golden +++ b/cmd/scw/testdata/test-main-usage-usage.golden @@ -19,6 +19,7 @@ AVAILABLE COMMANDS: iam IAM API instance Instance API iot This API allows you to manage IoT hubs and devices + ipns IPFS Naming service API k8s Kubernetes API lb This API allows you to manage your Scaleway Load Balancer services marketplace Marketplace API diff --git a/docs/commands/ipns.md b/docs/commands/ipns.md new file mode 100644 index 0000000000..6d22a59830 --- /dev/null +++ b/docs/commands/ipns.md @@ -0,0 +1,169 @@ + +# Documentation for `scw ipns` +IPFS Naming service API + +- [A name is a hash of the public key within the IPNS (InterPlanetary Name System)](#a-name-is-a-hash-of-the-public-key-within-the-ipns-(interplanetary-name-system)) + - [Create a new name](#create-a-new-name) + - [Delete an existing name](#delete-an-existing-name) + - [Export your private key](#export-your-private-key) + - [Get information about a name](#get-information-about-a-name) + - [Import your private key](#import-your-private-key) + - [List all names by a Project ID](#list-all-names-by-a-project-id) + - [Update name information](#update-name-information) + + +## A name is a hash of the public key within the IPNS (InterPlanetary Name System) + +This is the PKI namespace, where the private key is used to publish (sign) a record. + + +### Create a new name + +You can use the `ipns key` command to list and generate more names and their respective keys. + +**Usage:** + +``` +scw ipns name create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| name | | Name for your records | +| value | | Value you want to associate with your records, CID or IPNS key | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + +### Delete an existing name + +Delete a name by its ID. + +**Usage:** + +``` +scw ipns name delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| name-id | Required | Name ID you wish to delete | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + +### Export your private key + +Export a private key by its ID. + +**Usage:** + +``` +scw ipns name export-key [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| name-id | Required | Name ID whose keys you want to export | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + +### Get information about a name + +Retrieve information about a specific name. + +**Usage:** + +``` +scw ipns name get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| name-id | Required | Name ID whose information you want to retrieve | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + +### Import your private key + +Import a private key. + +**Usage:** + +``` +scw ipns name import-key [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| name | | Name for your records | +| private-key | Required | Base64 private key | +| value | | Value you want to associate with your records, CID or IPNS key | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + +### List all names by a Project ID + +Retrieve information about all names from a Project ID. + +**Usage:** + +``` +scw ipns name list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID | +| order-by | One of: `created_at_asc`, `created_at_desc` | Sort the order of the returned names | +| organization-id | | Organization ID | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw`, `all` | Region to target. If none is passed will use default region from the config | + + + +### Update name information + +Update name information (CID, tag, name...). + +**Usage:** + +``` +scw ipns name update [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| name-id | Required | Name ID you wish to update | +| name | | New name you want to associate with your record | +| tags.{index} | | New tags you want to associate with your record | +| value | | Value you want to associate with your records, CID or IPNS key | +| region | Default: `fr-par`
One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config | + + + diff --git a/go.mod b/go.mod index 4118559c7f..7772fe13fb 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/moby/buildkit v0.11.6 github.com/opencontainers/go-digest v1.0.0 github.com/pkg/errors v0.9.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231025134805-9d4d800ad0ce + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231026082000-a1119e5a483e github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index fc177559ac..8be3f821bb 100644 --- a/go.sum +++ b/go.sum @@ -487,8 +487,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231025134805-9d4d800ad0ce h1:h2AZP6SVZbUtuq1hgmKwAT80FHkSwNSyLl4zRHhn0NI= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231025134805-9d4d800ad0ce/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231026082000-a1119e5a483e h1:4avaevgCuKDSd/S16Mndg/ty3FIIgevfvstXnuWBZxU= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231026082000-a1119e5a483e/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/internal/namespaces/instance/v1/testdata/test-create-server-scratch-storage-default-scratch-storage.golden b/internal/namespaces/instance/v1/testdata/test-create-server-scratch-storage-default-scratch-storage.golden index 61fe53d96a..832d9a50ae 100644 --- a/internal/namespaces/instance/v1/testdata/test-create-server-scratch-storage-default-scratch-storage.golden +++ b/internal/namespaces/instance/v1/testdata/test-create-server-scratch-storage-default-scratch-storage.golden @@ -33,12 +33,14 @@ PublicIP.Netmask 32 PublicIP.Family inet PublicIP.Dynamic false PublicIP.ProvisioningMode dhcp +PublicIP.State unknown_state PublicIPs.0.ID 0b94b3a0-db5f-4927-b1c9-98f0d13527f4 PublicIPs.0.Address 51.159.166.126 PublicIPs.0.Netmask 32 PublicIPs.0.Family inet PublicIPs.0.Dynamic false PublicIPs.0.ProvisioningMode dhcp +PublicIPs.0.State unknown_state MacAddress de:00:00:1c:59:5b ModificationDate few seconds ago State archived @@ -127,7 +129,8 @@ Zone fr-par-2 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": [ { @@ -138,7 +141,8 @@ Zone fr-par-2 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" } ], "mac_address": "de:00:00:1c:59:5b", diff --git a/internal/namespaces/instance/v1/testdata/test-create-server-simple-default.golden b/internal/namespaces/instance/v1/testdata/test-create-server-simple-default.golden index 75edd94e2c..bf2b18f0cf 100644 --- a/internal/namespaces/instance/v1/testdata/test-create-server-simple-default.golden +++ b/internal/namespaces/instance/v1/testdata/test-create-server-simple-default.golden @@ -33,12 +33,14 @@ PublicIP.Netmask 32 PublicIP.Family inet PublicIP.Dynamic false PublicIP.ProvisioningMode dhcp +PublicIP.State unknown_state PublicIPs.0.ID 8b31ebc6-fdd9-48cc-9124-1a0f2b02bc26 PublicIPs.0.Address 163.172.158.104 PublicIPs.0.Netmask 32 PublicIPs.0.Family inet PublicIPs.0.Dynamic false PublicIPs.0.ProvisioningMode dhcp +PublicIPs.0.State unknown_state MacAddress de:00:00:29:0a:3b ModificationDate few seconds ago State archived @@ -113,7 +115,8 @@ Zone fr-par-1 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": [] + "tags": [], + "state": "unknown_state" }, "public_ips": [ { @@ -124,7 +127,8 @@ Zone fr-par-1 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": [] + "tags": [], + "state": "unknown_state" } ], "mac_address": "de:00:00:29:0a:3b", diff --git a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden index a4da50e0e2..7fc98e049d 100644 --- a/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-get-server-simple.golden @@ -17,6 +17,7 @@ PublicIP.Netmask 32 PublicIP.Family inet PublicIP.Dynamic false PublicIP.ProvisioningMode dhcp +PublicIP.State unknown_state MacAddress de:00:00:1e:87:b1 ModificationDate few seconds ago State archived @@ -51,8 +52,8 @@ ID NAME EXPORT URI OR 24d7bed8-b88c-4059-87cc-8373145e35ff Ubuntu 18.04 Bionic Beaver - ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b 20 GB l_ssd few seconds ago few seconds ago available ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b false fr-par-1 Public IPs: -ID ADDRESS GATEWAY NETMASK FAMILY DYNAMIC PROVISIONING MODE TAGS -647be9ab-3627-4f02-b205-2ae3fe896c5d 51.15.214.148 - 32 inet false dhcp - +ID ADDRESS GATEWAY NETMASK FAMILY DYNAMIC PROVISIONING MODE TAGS STATE +647be9ab-3627-4f02-b205-2ae3fe896c5d 51.15.214.148 - 32 inet false dhcp - unknown_state IPv6: - @@ -108,7 +109,8 @@ ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": [ { @@ -119,7 +121,8 @@ ID MAC ADDRESS PRIVATE NETWORK NAME PRIVATE NETWORK ID "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" } ], "mac_address": "de:00:00:1e:87:b1", diff --git a/internal/namespaces/instance/v1/testdata/test-list-server-simple.golden b/internal/namespaces/instance/v1/testdata/test-list-server-simple.golden index 38c5ba77ef..2fc21ca282 100644 --- a/internal/namespaces/instance/v1/testdata/test-list-server-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-list-server-simple.golden @@ -55,7 +55,8 @@ c66fe648-06c8-4cab-83d4-d963bf0ef8df kubetest-runner PRO2-S archived fr-par- "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": [ { @@ -66,7 +67,8 @@ c66fe648-06c8-4cab-83d4-d963bf0ef8df kubetest-runner PRO2-S archived fr-par- "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" } ], "mac_address": "de:00:00:13:02:db", diff --git a/internal/namespaces/instance/v1/testdata/test-server-action-manual-poweron.golden b/internal/namespaces/instance/v1/testdata/test-server-action-manual-poweron.golden index 27acafe70c..c8fb2b70be 100644 --- a/internal/namespaces/instance/v1/testdata/test-server-action-manual-poweron.golden +++ b/internal/namespaces/instance/v1/testdata/test-server-action-manual-poweron.golden @@ -36,12 +36,14 @@ PublicIP.Netmask 32 PublicIP.Family inet PublicIP.Dynamic false PublicIP.ProvisioningMode dhcp +PublicIP.State unknown_state PublicIPs.0.ID e6b4161c-85e3-4d3b-bdcc-f881afdf7c46 PublicIPs.0.Address 163.172.133.158 PublicIPs.0.Netmask 32 PublicIPs.0.Family inet PublicIPs.0.Dynamic false PublicIPs.0.ProvisioningMode dhcp +PublicIPs.0.State unknown_state MacAddress de:00:00:1e:f5:b5 ModificationDate few seconds ago State running @@ -119,7 +121,8 @@ Zone fr-par-1 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": [ { @@ -130,7 +133,8 @@ Zone fr-par-1 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" } ], "mac_address": "de:00:00:1e:f5:b5", diff --git a/internal/namespaces/instance/v1/testdata/test-server-enable-routed-ip-simple.golden b/internal/namespaces/instance/v1/testdata/test-server-enable-routed-ip-simple.golden index c84b212939..28cbe5373d 100644 --- a/internal/namespaces/instance/v1/testdata/test-server-enable-routed-ip-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-server-enable-routed-ip-simple.golden @@ -36,6 +36,7 @@ PublicIP.Netmask 32 PublicIP.Family inet PublicIP.Dynamic false PublicIP.ProvisioningMode dhcp +PublicIP.State unknown_state PublicIPs.0.ID 8febb0af-cde7-414a-bff1-a38146808bbf PublicIPs.0.Address 51.159.82.142 PublicIPs.0.Gateway 62.210.0.1 @@ -43,6 +44,7 @@ PublicIPs.0.Netmask 32 PublicIPs.0.Family inet PublicIPs.0.Dynamic false PublicIPs.0.ProvisioningMode dhcp +PublicIPs.0.State unknown_state MacAddress de:00:00:04:c5:5d ModificationDate few seconds ago State running @@ -120,7 +122,8 @@ Zone fr-par-3 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": [ { @@ -131,7 +134,8 @@ Zone fr-par-3 "family": "inet", "dynamic": false, "provisioning_mode": "dhcp", - "tags": null + "tags": null, + "state": "unknown_state" } ], "mac_address": "de:00:00:04:c5:5d", diff --git a/internal/namespaces/instance/v1/testdata/test-server-update-simple.golden b/internal/namespaces/instance/v1/testdata/test-server-update-simple.golden index 019cbc6e02..f1de6276a2 100644 --- a/internal/namespaces/instance/v1/testdata/test-server-update-simple.golden +++ b/internal/namespaces/instance/v1/testdata/test-server-update-simple.golden @@ -32,6 +32,7 @@ Server.PublicIP.Netmask - Server.PublicIP.Family inet Server.PublicIP.Dynamic false Server.PublicIP.ProvisioningMode manual +Server.PublicIP.State unknown_state Server.MacAddress - Server.ModificationDate few seconds ago Server.State archived @@ -106,7 +107,8 @@ Server.Zone fr-par-1 "family": "inet", "dynamic": false, "provisioning_mode": "manual", - "tags": null + "tags": null, + "state": "unknown_state" }, "public_ips": null, "mac_address": "", diff --git a/internal/namespaces/ipfs/v1alpha1/ipfs_cli.go b/internal/namespaces/ipfs/v1alpha1/ipfs_cli.go index 3c6664ac8e..59b491ff4e 100644 --- a/internal/namespaces/ipfs/v1alpha1/ipfs_cli.go +++ b/internal/namespaces/ipfs/v1alpha1/ipfs_cli.go @@ -20,8 +20,10 @@ var ( func GetGeneratedCommands() *core.Commands { return core.NewCommands( ipfsRoot(), + ipnsRoot(), ipfsPin(), ipfsVolume(), + ipnsName(), ipfsVolumeCreate(), ipfsVolumeGet(), ipfsVolumeList(), @@ -32,6 +34,13 @@ func GetGeneratedCommands() *core.Commands { ipfsPinGet(), ipfsPinList(), ipfsPinDelete(), + ipnsNameCreate(), + ipnsNameGet(), + ipnsNameDelete(), + ipnsNameList(), + ipnsNameUpdate(), + ipnsNameExportKey(), + ipnsNameImportKey(), ) } func ipfsRoot() *core.Command { @@ -42,6 +51,14 @@ func ipfsRoot() *core.Command { } } +func ipnsRoot() *core.Command { + return &core.Command{ + Short: `IPFS Naming service API`, + Long: ``, + Namespace: "ipns", + } +} + func ipfsPin() *core.Command { return &core.Command{ Short: `A pin is an abstract object that holds a Content Identifier (CID). It is defined that during the lifespan of a pin, the CID (and all sub-CIDs) must be hosted by the service`, @@ -60,6 +77,15 @@ func ipfsVolume() *core.Command { } } +func ipnsName() *core.Command { + return &core.Command{ + Short: `A name is a hash of the public key within the IPNS (InterPlanetary Name System)`, + Long: `This is the PKI namespace, where the private key is used to publish (sign) a record.`, + Namespace: "ipns", + Resource: "name", + } +} + func ipfsVolumeCreate() *core.Command { return &core.Command{ Short: `Create a new volume`, @@ -496,3 +522,287 @@ This content can therefore be removed and no longer provided on the IPFS network }, } } + +func ipnsNameCreate() *core.Command { + return &core.Command{ + Short: `Create a new name`, + Long: `You can use the ` + "`" + `ipns key` + "`" + ` command to list and generate more names and their respective keys.`, + Namespace: "ipns", + Resource: "name", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPICreateNameRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "name", + Short: `Name for your records`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "value", + Short: `Value you want to associate with your records, CID or IPNS key`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPICreateNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + return api.CreateName(request) + + }, + } +} + +func ipnsNameGet() *core.Command { + return &core.Command{ + Short: `Get information about a name`, + Long: `Retrieve information about a specific name.`, + Namespace: "ipns", + Resource: "name", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIGetNameRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name-id", + Short: `Name ID whose information you want to retrieve`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIGetNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + return api.GetName(request) + + }, + } +} + +func ipnsNameDelete() *core.Command { + return &core.Command{ + Short: `Delete an existing name`, + Long: `Delete a name by its ID.`, + Namespace: "ipns", + Resource: "name", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIDeleteNameRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name-id", + Short: `Name ID you wish to delete`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIDeleteNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + e = api.DeleteName(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "name", + Verb: "delete", + }, nil + }, + } +} + +func ipnsNameList() *core.Command { + return &core.Command{ + Short: `List all names by a Project ID`, + Long: `Retrieve information about all names from a Project ID.`, + Namespace: "ipns", + Resource: "name", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIListNamesRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "project-id", + Short: `Project ID`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "order-by", + Short: `Sort the order of the returned names`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "organization-id", + Short: `Organization ID`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw, scw.Region(core.AllLocalities)), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIListNamesRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + if request.Region == scw.Region(core.AllLocalities) { + opts = append(opts, scw.WithRegions(api.Regions()...)) + request.Region = "" + } + resp, err := api.ListNames(request, opts...) + if err != nil { + return nil, err + } + return resp.Names, nil + + }, + } +} + +func ipnsNameUpdate() *core.Command { + return &core.Command{ + Short: `Update name information`, + Long: `Update name information (CID, tag, name...).`, + Namespace: "ipns", + Resource: "name", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIUpdateNameRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name-id", + Short: `Name ID you wish to update`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "name", + Short: `New name you want to associate with your record`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "tags.{index}", + Short: `New tags you want to associate with your record`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "value", + Short: `Value you want to associate with your records, CID or IPNS key`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIUpdateNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + return api.UpdateName(request) + + }, + } +} + +func ipnsNameExportKey() *core.Command { + return &core.Command{ + Short: `Export your private key`, + Long: `Export a private key by its ID.`, + Namespace: "ipns", + Resource: "name", + Verb: "export-key", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIExportKeyNameRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name-id", + Short: `Name ID whose keys you want to export`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIExportKeyNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + return api.ExportKeyName(request) + + }, + } +} + +func ipnsNameImportKey() *core.Command { + return &core.Command{ + Short: `Import your private key`, + Long: `Import a private key.`, + Namespace: "ipns", + Resource: "name", + Verb: "import-key", + // Deprecated: false, + ArgsType: reflect.TypeOf(ipfs.IpnsAPIImportKeyNameRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "name", + Short: `Name for your records`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "private-key", + Short: `Base64 private key`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "value", + Short: `Value you want to associate with your records, CID or IPNS key`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*ipfs.IpnsAPIImportKeyNameRequest) + + client := core.ExtractClient(ctx) + api := ipfs.NewIpnsAPI(client) + return api.ImportKeyName(request) + + }, + } +}