1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940 | // Generated by scripts/gen-api.py from spec/openapi.json — do not edit.
import Foundation
// MARK: - Types
/// Values this build does not know decode as `.unrecognized`.
public enum PinState: RawRepresentable, Codable, Sendable, Hashable {
case awaitingUpload
case queued
case pinning
case pinned
case failed
case deleting
/// A value the server sent that this version of the package does not list.
case unrecognized(String)
/// Every value the spec listed when this file was generated.
public static let known: [PinState] = [.awaitingUpload, .queued, .pinning, .pinned, .failed, .deleting]
public init(rawValue: String) {
switch rawValue {
case "awaiting-upload": self = .awaitingUpload
case "queued": self = .queued
case "pinning": self = .pinning
case "pinned": self = .pinned
case "failed": self = .failed
case "deleting": self = .deleting
default: self = .unrecognized(rawValue)
}
}
public var rawValue: String {
switch self {
case .awaitingUpload: return "awaiting-upload"
case .queued: return "queued"
case .pinning: return "pinning"
case .pinned: return "pinned"
case .failed: return "failed"
case .deleting: return "deleting"
case .unrecognized(let raw): return raw
}
}
public init(from decoder: any Decoder) throws {
self.init(rawValue: try decoder.singleValueContainer().decode(String.self))
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
}
/// Shared by 3 operations.
public struct Pin: Codable, Sendable, Hashable, Identifiable {
/// Pin id — also the Pinning Service API requestid.
public var id: String
/// Null while a direct upload has not delivered bytes yet.
public var cid: String?
/// The CID's base32 CIDv1 spelling — the form gateway URLs carry.
public var cidV1: String?
public var name: String?
public var state: PinState
public var sizeBytes: Int?
/// Where the pinned content serves once fetched.
public var gatewayUrl: String?
public var meta: [String: String]
public var createdAt: String?
public var updatedAt: String?
/// Customer-facing summary of the last node error, if any.
public var lastError: String?
public init(id: String, cid: String? = nil, cidV1: String? = nil, name: String? = nil, state: PinState, sizeBytes: Int? = nil, gatewayUrl: String? = nil, meta: [String: String], createdAt: String? = nil, updatedAt: String? = nil, lastError: String? = nil) {
self.id = id
self.cid = cid
self.cidV1 = cidV1
self.name = name
self.state = state
self.sizeBytes = sizeBytes
self.gatewayUrl = gatewayUrl
self.meta = meta
self.createdAt = createdAt
self.updatedAt = updatedAt
self.lastError = lastError
}
enum CodingKeys: String, CodingKey {
case id
case cid
case cidV1 = "cid_v1"
case name
case state
case sizeBytes = "size_bytes"
case gatewayUrl = "gateway_url"
case meta
case createdAt = "created_at"
case updatedAt = "updated_at"
case lastError = "last_error"
}
/// Explicit so required-but-nullable fields encode as `null` rather than vanishing.
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(cid, forKey: .cid)
try container.encode(cidV1, forKey: .cidV1)
try container.encode(name, forKey: .name)
try container.encode(state, forKey: .state)
try container.encode(sizeBytes, forKey: .sizeBytes)
try container.encode(gatewayUrl, forKey: .gatewayUrl)
try container.encode(meta, forKey: .meta)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(updatedAt, forKey: .updatedAt)
try container.encode(lastError, forKey: .lastError)
}
}
/// Used by GET /ipfs/pins.
public struct ListPinsResponse: Codable, Sendable, Hashable {
public var pins: [Pin]
/// Match count across all pages
public var total: Int
public init(pins: [Pin], total: Int) {
self.pins = pins
self.total = total
}
enum CodingKeys: String, CodingKey {
case pins
case total
}
}
/// Shared by 2 operations.
public struct PinResponse: Codable, Sendable, Hashable {
public var pin: Pin
public init(pin: Pin) {
self.pin = pin
}
enum CodingKeys: String, CodingKey {
case pin
}
}
/// Values this build does not know decode as `.unrecognized`.
public enum UploadFormat: RawRepresentable, Codable, Sendable, Hashable {
case file
case car
/// A value the server sent that this version of the package does not list.
case unrecognized(String)
/// Every value the spec listed when this file was generated.
public static let known: [UploadFormat] = [.file, .car]
public init(rawValue: String) {
switch rawValue {
case "file": self = .file
case "car": self = .car
default: self = .unrecognized(rawValue)
}
}
public var rawValue: String {
switch self {
case .file: return "file"
case .car: return "car"
case .unrecognized(let raw): return raw
}
}
public init(from decoder: any Decoder) throws {
self.init(rawValue: try decoder.singleValueContainer().decode(String.self))
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
}
/// Used by POST /ipfs/uploads.
public struct StartUploadBody: Codable, Sendable, Hashable {
public var name: String?
public var meta: [String: String]?
public var format: UploadFormat?
public init(name: String? = nil, meta: [String: String]? = nil, format: UploadFormat? = nil) {
self.name = name
self.meta = meta
self.format = format
}
enum CodingKeys: String, CodingKey {
case name
case meta
case format
}
}
/// Values this build does not know decode as `.unrecognized`.
public enum UploadStatus: RawRepresentable, Codable, Sendable, Hashable {
case issued
case completed
case failed
case expired
/// A value the server sent that this version of the package does not list.
case unrecognized(String)
/// Every value the spec listed when this file was generated.
public static let known: [UploadStatus] = [.issued, .completed, .failed, .expired]
public init(rawValue: String) {
switch rawValue {
case "issued": self = .issued
case "completed": self = .completed
case "failed": self = .failed
case "expired": self = .expired
default: self = .unrecognized(rawValue)
}
}
public var rawValue: String {
switch self {
case .issued: return "issued"
case .completed: return "completed"
case .failed: return "failed"
case .expired: return "expired"
case .unrecognized(let raw): return raw
}
}
public init(from decoder: any Decoder) throws {
self.init(rawValue: try decoder.singleValueContainer().decode(String.self))
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
}
/// Shared by 2 operations.
public struct Upload: Codable, Sendable, Hashable, Identifiable {
public var id: String
public var pinId: String
/// Direct node URL to POST the raw bytes to (append ?format=car for CAR archives).
public var url: String
/// Bearer token for the upload POST; present while the grant is usable.
public var token: String?
public var maxBytes: Int
public var expiresAt: String?
public var status: UploadStatus
public var cid: String?
public var sizeBytes: Int?
public var error: String?
public init(id: String, pinId: String, url: String, token: String? = nil, maxBytes: Int, expiresAt: String? = nil, status: UploadStatus, cid: String? = nil, sizeBytes: Int? = nil, error: String? = nil) {
self.id = id
self.pinId = pinId
self.url = url
self.token = token
self.maxBytes = maxBytes
self.expiresAt = expiresAt
self.status = status
self.cid = cid
self.sizeBytes = sizeBytes
self.error = error
}
enum CodingKeys: String, CodingKey {
case id
case pinId = "pin_id"
case url
case token
case maxBytes = "max_bytes"
case expiresAt = "expires_at"
case status
case cid
case sizeBytes = "size_bytes"
case error
}
/// Explicit so required-but-nullable fields encode as `null` rather than vanishing.
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(pinId, forKey: .pinId)
try container.encode(url, forKey: .url)
try container.encode(token, forKey: .token)
try container.encode(maxBytes, forKey: .maxBytes)
try container.encode(expiresAt, forKey: .expiresAt)
try container.encode(status, forKey: .status)
try container.encode(cid, forKey: .cid)
try container.encode(sizeBytes, forKey: .sizeBytes)
try container.encode(error, forKey: .error)
}
}
/// Shared by 2 operations.
public struct UploadResponse: Codable, Sendable, Hashable {
public var upload: Upload
public init(upload: Upload) {
self.upload = upload
}
enum CodingKeys: String, CodingKey {
case upload
}
}
/// Values this build does not know decode as `.unrecognized`.
public enum IpnsNameState: RawRepresentable, Codable, Sendable, Hashable {
case creating
case active
case failed
case deleting
/// A value the server sent that this version of the package does not list.
case unrecognized(String)
/// Every value the spec listed when this file was generated.
public static let known: [IpnsNameState] = [.creating, .active, .failed, .deleting]
public init(rawValue: String) {
switch rawValue {
case "creating": self = .creating
case "active": self = .active
case "failed": self = .failed
case "deleting": self = .deleting
default: self = .unrecognized(rawValue)
}
}
public var rawValue: String {
switch self {
case .creating: return "creating"
case .active: return "active"
case .failed: return "failed"
case .deleting: return "deleting"
case .unrecognized(let raw): return raw
}
}
public init(from decoder: any Decoder) throws {
self.init(rawValue: try decoder.singleValueContainer().decode(String.self))
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
}
/// Shared by 4 operations.
public struct IpnsName: Codable, Sendable, Hashable, Identifiable {
public var id: String
public var label: String
/// The k51… IPNS name; null until the node generates the key.
public var name: String?
public var state: IpnsNameState
public var targetCid: String?
public var lastPublishedCid: String?
public var lastPublishedAt: String?
/// Gateway entry for the content the name currently points at (`<gateway>/ipfs/<cid>`, taken from `last_published_cid` and falling back to `target_cid`); null until the name has a target. It moves with every publish — link to `url` for an address that does not.
public var targetUrl: String?
public var url: String?
public var lastError: String?
public var createdAt: String?
public var updatedAt: String?
public init(id: String, label: String, name: String? = nil, state: IpnsNameState, targetCid: String? = nil, lastPublishedCid: String? = nil, lastPublishedAt: String? = nil, targetUrl: String? = nil, url: String? = nil, lastError: String? = nil, createdAt: String? = nil, updatedAt: String? = nil) {
self.id = id
self.label = label
self.name = name
self.state = state
self.targetCid = targetCid
self.lastPublishedCid = lastPublishedCid
self.lastPublishedAt = lastPublishedAt
self.targetUrl = targetUrl
self.url = url
self.lastError = lastError
self.createdAt = createdAt
self.updatedAt = updatedAt
}
enum CodingKeys: String, CodingKey {
case id
case label
case name
case state
case targetCid = "target_cid"
case lastPublishedCid = "last_published_cid"
case lastPublishedAt = "last_published_at"
case targetUrl = "target_url"
case url
case lastError = "last_error"
case createdAt = "created_at"
case updatedAt = "updated_at"
}
/// Explicit so required-but-nullable fields encode as `null` rather than vanishing.
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(label, forKey: .label)
try container.encode(name, forKey: .name)
try container.encode(state, forKey: .state)
try container.encode(targetCid, forKey: .targetCid)
try container.encode(lastPublishedCid, forKey: .lastPublishedCid)
try container.encode(lastPublishedAt, forKey: .lastPublishedAt)
try container.encode(targetUrl, forKey: .targetUrl)
try container.encode(url, forKey: .url)
try container.encode(lastError, forKey: .lastError)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(updatedAt, forKey: .updatedAt)
}
}
/// Used by GET /ipfs/names.
public struct ListNamesResponse: Codable, Sendable, Hashable {
public var names: [IpnsName]
public init(names: [IpnsName]) {
self.names = names
}
enum CodingKeys: String, CodingKey {
case names
}
}
/// Used by POST /ipfs/names.
public struct CreateNameBody: Codable, Sendable, Hashable {
/// A hostname on (or under) one of your ird DNS zones: dot-separated labels of [a-z0-9-], ≤253 chars, unique per account
public var label: String
/// Also attach the hostname as a linked gateway domain and create its DNS records
public var serve: Bool?
public init(label: String, serve: Bool? = nil) {
self.label = label
self.serve = serve
}
enum CodingKeys: String, CodingKey {
case label
case serve
}
}
/// Shared by 5 operations.
public struct GatewayDomain: Codable, Sendable, Hashable, Identifiable {
public var id: String
public var domain: String
public var state: GatewayDomainState
/// Set when the domain is linked to one of your IPNS names — its DNS records (A + `_dnslink` TXT) are then created and maintained for you.
public var ipnsNameId: String?
/// Live pins the domain serves at `/ipfs/<cid>` (unbounded — the pins themselves ride the paged `GET /ipfs/domains/{id}/pins`).
public var pinCount: Int
public var lastError: String?
/// The TXT record to create on your ird-hosted zone (`ird dns set-record` or the DNS panel). Ignore it on linked rows (`ipns_name_id` set) — the record is managed for you.
public var dnslinkHint: String
/// The gateway node's IPv4 the domain's A record must point at — present on the create response (manual-mapping rows need it to set the A record; linked/pins rows get the record created for them). Any AAAA record at the hostname must be removed (on ird-managed rows it is removed for you): the gateway serves IPv4 only and certificate validation prefers IPv6.
public var dnsTarget: String?
public var verifiedAt: String?
public var createdAt: String?
public var updatedAt: String?
/// Present (true) in the list on a gateway domain under a domain another account shared with this one through an ipfs grant: manageable here, billed per the share's payer setting (the owner by default); gateway egress always bills the owner.
public var delegated: Bool?
public init(id: String, domain: String, state: GatewayDomainState, ipnsNameId: String? = nil, pinCount: Int, lastError: String? = nil, dnslinkHint: String, dnsTarget: String? = nil, verifiedAt: String? = nil, createdAt: String? = nil, updatedAt: String? = nil, delegated: Bool? = nil) {
self.id = id
self.domain = domain
self.state = state
self.ipnsNameId = ipnsNameId
self.pinCount = pinCount
self.lastError = lastError
self.dnslinkHint = dnslinkHint
self.dnsTarget = dnsTarget
self.verifiedAt = verifiedAt
self.createdAt = createdAt
self.updatedAt = updatedAt
self.delegated = delegated
}
enum CodingKeys: String, CodingKey {
case id
case domain
case state
case ipnsNameId = "ipns_name_id"
case pinCount = "pin_count"
case lastError = "last_error"
case dnslinkHint = "dnslink_hint"
case dnsTarget = "dns_target"
case verifiedAt = "verified_at"
case createdAt = "created_at"
case updatedAt = "updated_at"
case delegated
}
/// Explicit so required-but-nullable fields encode as `null` rather than vanishing.
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(domain, forKey: .domain)
try container.encode(state, forKey: .state)
try container.encode(ipnsNameId, forKey: .ipnsNameId)
try container.encode(pinCount, forKey: .pinCount)
try container.encode(lastError, forKey: .lastError)
try container.encode(dnslinkHint, forKey: .dnslinkHint)
try container.encodeIfPresent(dnsTarget, forKey: .dnsTarget)
try container.encode(verifiedAt, forKey: .verifiedAt)
try container.encode(createdAt, forKey: .createdAt)
try container.encode(updatedAt, forKey: .updatedAt)
try container.encodeIfPresent(delegated, forKey: .delegated)
}
}
/// Used by POST /ipfs/names.
public struct CreateNameResponse: Codable, Sendable, Hashable {
public var name: IpnsName
public var domain: GatewayDomain?
public init(name: IpnsName, domain: GatewayDomain? = nil) {
self.name = name
self.domain = domain
}
enum CodingKeys: String, CodingKey {
case name
case domain
}
}
/// Shared by 2 operations.
public struct NameResponse: Codable, Sendable, Hashable {
public var name: IpnsName
public init(name: IpnsName) {
self.name = name
}
enum CodingKeys: String, CodingKey {
case name
}
}
/// Used by PUT /ipfs/names/{id}/target.
public struct PublishTargetBody: Codable, Sendable, Hashable {
public var cid: String
public init(cid: String) {
self.cid = cid
}
enum CodingKeys: String, CodingKey {
case cid
}
}
/// Used by GET /ipfs/domains.
public struct ListDomainsResponse: Codable, Sendable, Hashable {
public var domains: [GatewayDomain]
public init(domains: [GatewayDomain]) {
self.domains = domains
}
enum CodingKeys: String, CodingKey {
case domains
}
}
/// Used by POST /ipfs/domains.
public struct IPFSAttachDomainBody: Codable, Sendable, Hashable {
public var domain: String
/// Link the domain to this IPNS name of yours and auto-create its DNS records
public var ipnsNameId: String?
/// Your own live pins to serve at /ipfs/<cid> on the domain right away — any node, any count (content on other nodes replicates to the domain's node). Manage later via POST /ipfs/domains/{id}/pins.
public var pinIds: [String]?
public init(domain: String, ipnsNameId: String? = nil, pinIds: [String]? = nil) {
self.domain = domain
self.ipnsNameId = ipnsNameId
self.pinIds = pinIds
}
enum CodingKeys: String, CodingKey {
case domain
case ipnsNameId = "ipns_name_id"
case pinIds = "pin_ids"
}
}
/// Shared by 3 operations.
public struct GatewayDomainResponse: Codable, Sendable, Hashable {
public var domain: GatewayDomain
public init(domain: GatewayDomain) {
self.domain = domain
}
enum CodingKeys: String, CodingKey {
case domain
}
}
/// Used by GET /ipfs/domains/{id}/pins.
public struct DomainPin: Codable, Sendable, Hashable, Identifiable {
public var id: String
public var cid: String?
/// The CID's base32 CIDv1 spelling — both spellings are allowlisted on the domain.
public var cidV1: String?
public var name: String?
public var state: String
public var attachedAt: String?
public init(id: String, cid: String? = nil, cidV1: String? = nil, name: String? = nil, state: String, attachedAt: String? = nil) {
self.id = id
self.cid = cid
self.cidV1 = cidV1
self.name = name
self.state = state
self.attachedAt = attachedAt
}
enum CodingKeys: String, CodingKey {
case id
case cid
case cidV1 = "cid_v1"
case name
case state
case attachedAt = "attached_at"
}
/// Explicit so required-but-nullable fields encode as `null` rather than vanishing.
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
try container.encode(cid, forKey: .cid)
try container.encode(cidV1, forKey: .cidV1)
try container.encode(name, forKey: .name)
try container.encode(state, forKey: .state)
try container.encode(attachedAt, forKey: .attachedAt)
}
}
/// Used by GET /ipfs/domains/{id}/pins.
public struct ListDomainPinsResponse: Codable, Sendable, Hashable {
public var pins: [DomainPin]
/// Attachment count across all pages
public var total: Int
public var limit: Int
public var offset: Int
public init(pins: [DomainPin], total: Int, limit: Int, offset: Int) {
self.pins = pins
self.total = total
self.limit = limit
self.offset = offset
}
enum CodingKeys: String, CodingKey {
case pins
case total
case limit
case offset
}
}
/// Used by POST /ipfs/domains/{id}/pins.
public struct UpdateDomainPinsBody: Codable, Sendable, Hashable {
public var add: [String]?
public var remove: [String]?
public init(add: [String]? = nil, remove: [String]? = nil) {
self.add = add
self.remove = remove
}
enum CodingKeys: String, CodingKey {
case add
case remove
}
}
/// Used by GET /ipfs/usage.
public struct IPFSUsage: Codable, Sendable, Hashable {
public var pinnedBytes: Int
/// Gateway egress accumulated in the current billing period.
public var servedBytesPeriod: Int
public var perMbHour: String
public var perMbServed: String
public var hourlyCost: String
public var monthlyEstimate: String
public init(pinnedBytes: Int, servedBytesPeriod: Int, perMbHour: String, perMbServed: String, hourlyCost: String, monthlyEstimate: String) {
self.pinnedBytes = pinnedBytes
self.servedBytesPeriod = servedBytesPeriod
self.perMbHour = perMbHour
self.perMbServed = perMbServed
self.hourlyCost = hourlyCost
self.monthlyEstimate = monthlyEstimate
}
enum CodingKeys: String, CodingKey {
case pinnedBytes = "pinned_bytes"
case servedBytesPeriod = "served_bytes_period"
case perMbHour = "per_mb_hour"
case perMbServed = "per_mb_served"
case hourlyCost = "hourly_cost"
case monthlyEstimate = "monthly_estimate"
}
}
/// Used by GET /ipfs/usage.
public struct IPFSUsageResponse: Codable, Sendable, Hashable {
public var usage: IPFSUsage
public init(usage: IPFSUsage) {
self.usage = usage
}
enum CodingKeys: String, CodingKey {
case usage
}
}
/// Query parameters of `listPins`; unset fields are omitted.
public struct ListPinsQuery: Sendable, Hashable {
/// Comma-separated of awaiting-upload|queued|pinning|pinned|failed|deleting
public var status: String?
/// Name substring (case-insensitive) or CID prefix
public var q: String?
/// 1–100, default 25
public var limit: Int?
/// Rows to skip, default 0
public var offset: Int?
public init(status: String? = nil, q: String? = nil, limit: Int? = nil, offset: Int? = nil) {
self.status = status
self.q = q
self.limit = limit
self.offset = offset
}
/// The items in spec order.
public var queryItems: [QueryItem] {
var items: [QueryItem] = []
if let value = status { items.append(QueryItem("status", value)) }
if let value = q { items.append(QueryItem("q", value)) }
if let value = limit { items.append(QueryItem("limit", String(value))) }
if let value = offset { items.append(QueryItem("offset", String(value))) }
return items
}
}
/// Query parameters of `listDomainPins`; unset fields are omitted.
public struct ListDomainPinsQuery: Sendable, Hashable {
/// 1–100, default 100
public var limit: Int?
/// Rows to skip, default 0
public var offset: Int?
public init(limit: Int? = nil, offset: Int? = nil) {
self.limit = limit
self.offset = offset
}
/// The items in spec order.
public var queryItems: [QueryItem] {
var items: [QueryItem] = []
if let value = limit { items.append(QueryItem("limit", String(value))) }
if let value = offset { items.append(QueryItem("offset", String(value))) }
return items
}
}
// MARK: - Operations
extension IrdOperation {
public static let ipfs_listPins = IrdOperation(method: .get, pathTemplate: "/ipfs/pins", module: "ipfs", name: "listPins", security: .keyOrJwt)
public static let ipfs_pin = IrdOperation(method: .post, pathTemplate: "/ipfs/pins", module: "ipfs", name: "pin", security: .keyOrJwt)
public static let ipfs_getPin = IrdOperation(method: .get, pathTemplate: "/ipfs/pins/{id}", module: "ipfs", name: "getPin", security: .keyOrJwt)
public static let ipfs_unpin = IrdOperation(method: .delete, pathTemplate: "/ipfs/pins/{id}", module: "ipfs", name: "unpin", security: .keyOrJwt)
public static let ipfs_startUpload = IrdOperation(method: .post, pathTemplate: "/ipfs/uploads", module: "ipfs", name: "startUpload", security: .keyOrJwt)
public static let ipfs_getUpload = IrdOperation(method: .get, pathTemplate: "/ipfs/uploads/{id}", module: "ipfs", name: "getUpload", security: .keyOrJwt)
public static let ipfs_listNames = IrdOperation(method: .get, pathTemplate: "/ipfs/names", module: "ipfs", name: "listNames", security: .keyOrJwt)
public static let ipfs_createName = IrdOperation(method: .post, pathTemplate: "/ipfs/names", module: "ipfs", name: "createName", security: .keyOrJwt)
public static let ipfs_getName = IrdOperation(method: .get, pathTemplate: "/ipfs/names/{id}", module: "ipfs", name: "getName", security: .keyOrJwt)
public static let ipfs_deleteName = IrdOperation(method: .delete, pathTemplate: "/ipfs/names/{id}", module: "ipfs", name: "deleteName", security: .keyOrJwt)
public static let ipfs_publishTarget = IrdOperation(method: .put, pathTemplate: "/ipfs/names/{id}/target", module: "ipfs", name: "publishTarget", security: .keyOrJwt)
public static let ipfs_listDomains = IrdOperation(method: .get, pathTemplate: "/ipfs/domains", module: "ipfs", name: "listDomains", security: .keyOrJwt)
public static let ipfs_attachDomain = IrdOperation(method: .post, pathTemplate: "/ipfs/domains", module: "ipfs", name: "attachDomain", security: .keyOrJwt)
public static let ipfs_getDomain = IrdOperation(method: .get, pathTemplate: "/ipfs/domains/{id}", module: "ipfs", name: "getDomain", security: .keyOrJwt)
public static let ipfs_listDomainPins = IrdOperation(method: .get, pathTemplate: "/ipfs/domains/{id}/pins", module: "ipfs", name: "listDomainPins", security: .keyOrJwt)
public static let ipfs_updateDomainPins = IrdOperation(method: .post, pathTemplate: "/ipfs/domains/{id}/pins", module: "ipfs", name: "updateDomainPins", security: .keyOrJwt)
public static let ipfs_detachDomain = IrdOperation(method: .delete, pathTemplate: "/ipfs/domains/{id}", module: "ipfs", name: "detachDomain", security: .keyOrJwt)
public static let ipfs_usage = IrdOperation(method: .get, pathTemplate: "/ipfs/usage", module: "ipfs", name: "usage", security: .keyOrJwt)
static let ipfsOperations: [IrdOperation] = [.ipfs_listPins, .ipfs_pin, .ipfs_getPin, .ipfs_unpin, .ipfs_startUpload, .ipfs_getUpload, .ipfs_listNames, .ipfs_createName, .ipfs_getName, .ipfs_deleteName, .ipfs_publishTarget, .ipfs_listDomains, .ipfs_attachDomain, .ipfs_getDomain, .ipfs_listDomainPins, .ipfs_updateDomainPins, .ipfs_detachDomain, .ipfs_usage]
}
/// The `ipfs` operations (18).
public struct IPFSAPI: Sendable {
let client: IrdClient
/// List your pins
/// Non-deleted pins on the account, newest first, paged — `total` is the full match count so clients can render page controls.
/// `GET /ipfs/pins` — 200
public func listPins(query: ListPinsQuery = ListPinsQuery()) async throws -> ListPinsResponse {
try await client.request(.ipfs_listPins, query: query.queryItems)
}
/// Pin by CID
/// Asks the service to fetch and pin existing IPFS content by CID (CIDv0 `Qm…` or CIDv1 base32/base36/base58).
/// `POST /ipfs/pins` — 202
public func pin(body: PinSpec) async throws -> PinResponse {
try await client.request(.ipfs_pin, body: body)
}
/// Pin detail
/// One pin with its live state and gateway URL. Charged `ipfs.reads` per request.
/// `GET /ipfs/pins/{id}` — 200
public func getPin(id: String) async throws -> PinResponse {
try await client.request(.ipfs_getPin, params: ["id": id])
}
/// Unpin
/// Stops billing immediately and unpins on the node's next poll. Free — a negative balance never blocks removing what bills you. Idempotent while deletion is in progress.
/// `DELETE /ipfs/pins/{id}` — 202
public func unpin(id: String) async throws -> DeletedResponse {
try await client.request(.ipfs_unpin, params: ["id": id])
}
/// Start a direct upload
/// Issues a short-lived single-use grant to upload file bytes straight to a storage node (large content never streams through this API).
/// `POST /ipfs/uploads` — 201
public func startUpload(body: StartUploadBody? = nil) async throws -> UploadResponse {
try await client.request(.ipfs_startUpload, body: body)
}
/// Upload status
/// The grant's status (`issued`/`completed`/`failed`/`expired`) and, once completed, the resulting CID and size. Charged `ipfs.reads` per request.
/// `GET /ipfs/uploads/{id}` — 200
public func getUpload(id: String) async throws -> UploadResponse {
try await client.request(.ipfs_getUpload, params: ["id": id])
}
/// List your IPNS names
/// Every non-deleted IPNS name on the account. Charged `ipfs.reads` per request.
/// `GET /ipfs/names` — 200
public func listNames() async throws -> ListNamesResponse {
try await client.request(.ipfs_listNames)
}
/// Create an IPNS name
/// Creates a customer-owned IPNS name (a stable address whose target CID you can re-publish).
/// `POST /ipfs/names` — 201
public func createName(body: CreateNameBody) async throws -> CreateNameResponse {
try await client.request(.ipfs_createName, body: body)
}
/// IPNS name detail
/// One IPNS name with its publish state. Charged `ipfs.reads` per request.
/// `GET /ipfs/names/{id}` — 200
public func getName(id: String) async throws -> NameResponse {
try await client.request(.ipfs_getName, params: ["id": id])
}
/// Delete an IPNS name
/// Removes the name and its key from the node (the escrowed key copy is retained).
/// `DELETE /ipfs/names/{id}` — 202
public func deleteName(id: String) async throws -> DeletedResponse {
try await client.request(.ipfs_deleteName, params: ["id": id])
}
/// Publish a new target
/// Points the name at a CID; the node re-publishes on its next poll (and kubo auto-republishes to keep the record alive). The content should be pinned on the account or the gateway will serve nothing for it.
/// `PUT /ipfs/names/{id}/target` — 200
public func publishTarget(id: String, body: PublishTargetBody) async throws -> NameResponse {
try await client.request(.ipfs_publishTarget, params: ["id": id], body: body)
}
/// List your gateway domains
/// Customer-owned domains serving your pinned content through the gateway, unbranded. Charged `ipfs.reads` per request.
/// `GET /ipfs/domains` — 200
public func listDomains() async throws -> ListDomainsResponse {
try await client.request(.ipfs_listDomains)
}
/// Attach your own domain
/// Serves your content from a domain you own, with no ird branding.
/// `POST /ipfs/domains` — 201
public func attachDomain(body: IPFSAttachDomainBody) async throws -> GatewayDomainResponse {
try await client.request(.ipfs_attachDomain, body: body)
}
/// Gateway domain detail
/// One gateway domain with its verification/cert state. Charged `ipfs.reads` per request.
/// `GET /ipfs/domains/{id}` — 200
public func getDomain(id: String) async throws -> GatewayDomainResponse {
try await client.request(.ipfs_getDomain, params: ["id": id])
}
/// List a domain's served pins
/// The pins the gateway domain serves at `/ipfs/<cid>`, oldest attachment first, server-side paged (`total` is the full count — attachments are unbounded). Charged `ipfs.reads` per request.
/// `GET /ipfs/domains/{id}/pins` — 200
public func listDomainPins(id: String, query: ListDomainPinsQuery = ListDomainPinsQuery()) async throws -> ListDomainPinsResponse {
try await client.request(.ipfs_listDomainPins, params: ["id": id], query: query.queryItems)
}
/// Attach or detach served pins
/// Idempotent attach/detach delta over the domain's served pins — both lists are unbounded, re-adding attached pins and removing absent ones are no-ops, so any number of pins is manageable without ever sending the full set.
/// `POST /ipfs/domains/{id}/pins` — 200
public func updateDomainPins(id: String, body: UpdateDomainPinsBody? = nil) async throws -> GatewayDomainResponse {
try await client.request(.ipfs_updateDomainPins, params: ["id": id], body: body)
}
/// Detach a gateway domain
/// Drops the domain's gateway vhost on the node's next poll. A linked domain (`ipns_name_id`) also best-effort removes the DNS records that were created for it (hand-made records are left alone). Free; idempotent while deleting.
/// `DELETE /ipfs/domains/{id}` — 202
public func detachDomain(id: String) async throws -> DeletedResponse {
try await client.request(.ipfs_detachDomain, params: ["id": id])
}
/// Storage usage and cost
/// Pinned bytes (distinct CIDs — duplicates of one CID never double-bill), gateway egress accumulated this billing period, the active `recurring.ipfs-pin-hourly` rates, and the cost projection (hourly, and a ×730 monthly estimate).
/// `GET /ipfs/usage` — 200
public func usage() async throws -> IPFSUsageResponse {
try await client.request(.ipfs_usage)
}
}
extension IrdClient {
public var ipfs: IPFSAPI { IPFSAPI(client: self) }
}
|