Skip to content

Commit dc6469d

Browse files
authored
feat(ipfs): add documentation about replacePin (#3483)
1 parent a8aa0b6 commit dc6469d

File tree

6 files changed

+126
-3
lines changed

6 files changed

+126
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Deletes the given resource ID and pins the new CID in its place.
4+
Will fetch and store the content pointed by the provided CID. The content must be available on the public IPFS network.
5+
The content (IPFS blocks) is hosted by the pinning service until the pin is deleted.
6+
While the content is available any other IPFS peer can fetch and host your content. For this reason, we recommend that you pin either public or encrypted content.
7+
Several different pin requests can target the same CID.
8+
A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID.
9+
10+
USAGE:
11+
scw ipfs pin replace [arg=value ...]
12+
13+
ARGS:
14+
[volume-id] Volume ID
15+
pin-id Pin ID whose information you wish to replace
16+
[cid] New CID you want to pin in place of the old one
17+
[name] New name to replace
18+
[origins.{index}] Node containing the content you want to pin
19+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
20+
21+
FLAGS:
22+
-h, --help help for replace
23+
24+
GLOBAL FLAGS:
25+
-c, --config string The path to the config file
26+
-D, --debug Enable debug mode
27+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
28+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-ipfs-pin-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AVAILABLE COMMANDS:
1111
delete Create an unpin request
1212
get Get pin information
1313
list List all pins within a volume
14+
replace Replace pin by CID
1415

1516
FLAGS:
1617
-h, --help help for pin

docs/commands/ipfs.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ IPFS Pinning service API.
88
- [Create an unpin request](#create-an-unpin-request)
99
- [Get pin information](#get-pin-information)
1010
- [List all pins within a volume](#list-all-pins-within-a-volume)
11+
- [Replace pin by CID](#replace-pin-by-cid)
1112
- [A volume is bucket of pins. It is similar to an Object Storage bucket. Volumes are useful to gather pins with similar lifespans](#a-volume-is-bucket-of-pins.-it-is-similar-to-an-object-storage-bucket.-volumes-are-useful-to-gather-pins-with-similar-lifespans)
1213
- [Create a new volume](#create-a-new-volume)
1314
- [Delete an existing volume](#delete-an-existing-volume)
@@ -141,6 +142,35 @@ scw ipfs pin list [arg=value ...]
141142

142143

143144

145+
### Replace pin by CID
146+
147+
Deletes the given resource ID and pins the new CID in its place.
148+
Will fetch and store the content pointed by the provided CID. The content must be available on the public IPFS network.
149+
The content (IPFS blocks) is hosted by the pinning service until the pin is deleted.
150+
While the content is available any other IPFS peer can fetch and host your content. For this reason, we recommend that you pin either public or encrypted content.
151+
Several different pin requests can target the same CID.
152+
A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID.
153+
154+
**Usage:**
155+
156+
```
157+
scw ipfs pin replace [arg=value ...]
158+
```
159+
160+
161+
**Args:**
162+
163+
| Name | | Description |
164+
|------|---|-------------|
165+
| volume-id | | Volume ID |
166+
| pin-id | Required | Pin ID whose information you wish to replace |
167+
| cid | | New CID you want to pin in place of the old one |
168+
| name | | New name to replace |
169+
| origins.{index} | | Node containing the content you want to pin |
170+
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
171+
172+
173+
144174
## A volume is bucket of pins. It is similar to an Object Storage bucket. Volumes are useful to gather pins with similar lifespans
145175

146176
All pins must be attached to a volume. And all volumes must be attached to a Project ID.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/moby/buildkit v0.11.6
2525
github.com/opencontainers/go-digest v1.0.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231109154229-2a1e9a86fb22
27+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231110092605-f891294738f1
2828
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2929
github.com/spf13/cobra v1.8.0
3030
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
490490
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
491491
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
492492
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
493-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231109154229-2a1e9a86fb22 h1:r/XEibTTfo7KvTzs0o6m56KPSWQm34ZyMX1e42bq3go=
494-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231109154229-2a1e9a86fb22/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
493+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231110092605-f891294738f1 h1:XUxEGXbb+jwcPffwdSwnCp8IVq9ciYvZkqOy/QEGZqE=
494+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231110092605-f891294738f1/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
495495
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
496496
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
497497
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=

internal/namespaces/ipfs/v1alpha1/ipfs_cli.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func GetGeneratedCommands() *core.Commands {
3131
ipfsVolumeDelete(),
3232
ipfsPinCreateByURL(),
3333
ipfsPinCreateByCid(),
34+
ipfsPinReplace(),
3435
ipfsPinGet(),
3536
ipfsPinList(),
3637
ipfsPinDelete(),
@@ -373,6 +374,69 @@ A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed
373374
}
374375
}
375376

377+
func ipfsPinReplace() *core.Command {
378+
return &core.Command{
379+
Short: `Replace pin by CID`,
380+
Long: `Deletes the given resource ID and pins the new CID in its place.
381+
Will fetch and store the content pointed by the provided CID. The content must be available on the public IPFS network.
382+
The content (IPFS blocks) is hosted by the pinning service until the pin is deleted.
383+
While the content is available any other IPFS peer can fetch and host your content. For this reason, we recommend that you pin either public or encrypted content.
384+
Several different pin requests can target the same CID.
385+
A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID.`,
386+
Namespace: "ipfs",
387+
Resource: "pin",
388+
Verb: "replace",
389+
// Deprecated: false,
390+
ArgsType: reflect.TypeOf(ipfs.ReplacePinRequest{}),
391+
ArgSpecs: core.ArgSpecs{
392+
{
393+
Name: "volume-id",
394+
Short: `Volume ID`,
395+
Required: false,
396+
Deprecated: false,
397+
Positional: false,
398+
},
399+
{
400+
Name: "pin-id",
401+
Short: `Pin ID whose information you wish to replace`,
402+
Required: true,
403+
Deprecated: false,
404+
Positional: false,
405+
},
406+
{
407+
Name: "cid",
408+
Short: `New CID you want to pin in place of the old one`,
409+
Required: false,
410+
Deprecated: false,
411+
Positional: false,
412+
},
413+
{
414+
Name: "name",
415+
Short: `New name to replace`,
416+
Required: false,
417+
Deprecated: false,
418+
Positional: false,
419+
},
420+
{
421+
Name: "origins.{index}",
422+
Short: `Node containing the content you want to pin`,
423+
Required: false,
424+
Deprecated: false,
425+
Positional: false,
426+
},
427+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
428+
},
429+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
430+
request := args.(*ipfs.ReplacePinRequest)
431+
432+
client := core.ExtractClient(ctx)
433+
api := ipfs.NewAPI(client)
434+
return api.ReplacePin(request)
435+
436+
},
437+
}
438+
}
439+
376440
func ipfsPinGet() *core.Command {
377441
return &core.Command{
378442
Short: `Get pin information`,

0 commit comments

Comments
 (0)