@pantechdynamic/sdk 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +229 -10
- package/dist/index.cjs +1022 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21842 -8459
- package/dist/index.d.ts +21842 -8459
- package/dist/index.js +1014 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,82 @@ A new version heading here (`## X.Y.Z (YYYY-MM-DD)`) pushed to main is
|
|
|
4
4
|
tagged `vX.Y.Z` and published to npm. Add changes under `## Unreleased`
|
|
5
5
|
until then.
|
|
6
6
|
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
## 0.5.0 (2026-11-24)
|
|
10
|
+
|
|
11
|
+
- Dynamic IP for instances: `instances.dynamicIp` (`get`, `set`, `disable`, and non-retrying
|
|
12
|
+
`rotate`), optional `address_rotation` on `instances.create`, and `DynamicIp`, `DynamicIpEvent`,
|
|
13
|
+
and `PutDynamicIpRequest` type aliases.
|
|
14
|
+
- S3-compatible Object Storage: `client.objectStorage` (`getStatus`, `getUsage`, and
|
|
15
|
+
`objectStorage.keys.{list, create, revoke}` with non-enumerable `secret_access_key`) and
|
|
16
|
+
`client.buckets` (`list`, `create`, `get`, `update`, `delete`, `stats`, `empty`, CORS, lifecycle,
|
|
17
|
+
tags, object lock, `buckets.objects.*` with binary upload/download and per-object visibility, and
|
|
18
|
+
`buckets.multipart.*`).
|
|
19
|
+
- Raw binary request body support (`BinaryBody`: `Uint8Array | ArrayBuffer | Blob | string`,
|
|
20
|
+
defaulting to `Content-Type: application/octet-stream` unless overridden) and `Accept:
|
|
21
|
+
application/octet-stream` for `arrayBuffer` binary downloads across Node.js, Bun, Deno, and edge
|
|
22
|
+
runtimes.
|
|
23
|
+
|
|
24
|
+
## 0.4.0 (2026-11-10)
|
|
25
|
+
|
|
26
|
+
- `client.dns`, Pantech DNS on Pantech's own name servers (two per zone): `dns.zones` (`list`, `listAll`,
|
|
27
|
+
`create`, `get`, `update`, `delete`, `verify`, `exportZoneFile` returning the BIND zone file as
|
|
28
|
+
a string, `importZoneFile`) and `dns.records` (`list`, `listAll`, `create`, `get`, `update` and
|
|
29
|
+
`delete` with `{ ifMatch: version }`, `batch` for up to 1000 changes at once).
|
|
30
|
+
- `client.domains`: `listTlds`, `search`, `checkTransfer`, `list`, `listAll`, `get`, `register`,
|
|
31
|
+
`transfer`, `update` (auto-renew, transfer lock, privacy), `setNameServers`, `getContact`,
|
|
32
|
+
`updateContact`, `renew`, `requestAuthCode`, `getAuthCode`, and `domains.orders` (`list`, `get`).
|
|
33
|
+
- `dns.zones.wait()` (until the zone has its name servers) and `dns.records.wait()` (until the
|
|
34
|
+
record set answers), which reject with the new `DNSFailedError`, and `domains.orders.wait()`,
|
|
35
|
+
which rejects with `OrderFailedError` carrying the order's `failure_code`.
|
|
36
|
+
- `PreconditionFailedError` for `412` (`VERSION_CONFLICT`); `DNSErrorCode`, `DomainErrorCode`,
|
|
37
|
+
`DNS_ERROR_CODES` and `DOMAIN_ERROR_CODES` for every DNS and domain problem code.
|
|
38
|
+
- `examples/dns-and-domains.ts`.
|
|
39
|
+
- `client.registry`, the private container registry: `registry.namespace` (`get`, `set`),
|
|
40
|
+
`registry.repositories` (`list`, `listAll`, `create`, `get`, `update` for visibility, tag
|
|
41
|
+
immutability and retention, `delete`), `registry.tags` (`list`, `listAll`, `get`, `delete`) and
|
|
42
|
+
`registry.tokens` (`list`, `listAll`, `create`, `delete`). A new token's `secret` is
|
|
43
|
+
non-enumerable, so `console.log` and `JSON.stringify` leave it out; read `token.secret`.
|
|
44
|
+
- `RegistryErrorCode` and `REGISTRY_ERROR_CODES` for every registry problem code.
|
|
45
|
+
- `examples/container-registry.ts`.
|
|
46
|
+
- `client.iam`, teams and access policies: `iam.actions.list`, `iam.settings` (`get`, `update`),
|
|
47
|
+
`iam.teams` (`list`, `listAll`, `create`, `get`, `update`, `delete`) with `iam.teams.members`
|
|
48
|
+
(`list`, `listAll`, `add`, `remove`), `iam.policies` (`list`, `listAll`, `create`, `get`,
|
|
49
|
+
`update` with `{ ifMatch }`, `delete`) with `iam.policies.attachments` (`list`, `attach`,
|
|
50
|
+
`detach`), `iam.effectiveAccess(userId)` and `iam.simulate(...)`.
|
|
51
|
+
- The `iam` helper: `iam.allow(...)`, `iam.deny(...)` and `iam.statement(...)` build typed policy
|
|
52
|
+
statements and check the API's limits first; `iam.MANAGED_POLICY_IDS` lists Pantech's policies.
|
|
53
|
+
- `IamErrorCode` and `IAM_ERROR_CODES` for every access policy problem code; `IfMatchOptions` for
|
|
54
|
+
any change conditional on a version (`RecordWriteOptions` is now an alias of it).
|
|
55
|
+
- `examples/access-policies.ts`.
|
|
56
|
+
- `iam.members.list` / `listAll`: the organization's members with their teams and policy counts;
|
|
57
|
+
`iam.settings.update` takes `{ ifMatch }`.
|
|
58
|
+
- `client.certificates`, Certificate Manager: `list`, `listAll`, `request`, `import`, `get`,
|
|
59
|
+
`update`, `verify`, `reimport`, `export`, `revoke`, `delete`, and `wait(id)` until it is issued,
|
|
60
|
+
which rejects with the new `CertificateFailedError`. An exported `private_key_pem` is
|
|
61
|
+
non-enumerable, like a new registry token's `secret`.
|
|
62
|
+
- `CertificateErrorCode` and `CERTIFICATE_ERROR_CODES` for every certificate problem code.
|
|
63
|
+
- `examples/certificates.ts`.
|
|
64
|
+
- `dns.zones.quote()`: the free zone allowance and the monthly price of each further zone.
|
|
65
|
+
- `domains.orders.wait()` rejects with `PaymentRequiredError` (code `AWAITING_PAYMENT`, with
|
|
66
|
+
`paymentUrl`, `paymentExpiresAt` and `order`) when an order is `awaiting_payment` because your
|
|
67
|
+
credit does not cover it, instead of waiting silently; `{ waitForPayment: true }` keeps waiting
|
|
68
|
+
while the user pays. Domain orders carry `payment_url` and `payment_expires_at`; TLD offers and
|
|
69
|
+
search results carry `privacy_always_on`.
|
|
70
|
+
- `domains.orders.retryPayment(orderId)` (`POST /domain-orders/{order_id}/retry-payment`): an
|
|
71
|
+
order waiting in `awaiting_payment` tries its payment again at once and waits another hour; it
|
|
72
|
+
never charges twice. A `409` `DOMAIN_ORDER_NOT_AWAITING_PAYMENT` (in `DOMAIN_ERROR_CODES`) when
|
|
73
|
+
the order is not waiting for a payment. `payment_url` is now set only when the bank asks the
|
|
74
|
+
customer to confirm a saved-card payment in US dollars, so `PaymentRequiredError.paymentUrl`
|
|
75
|
+
can be undefined.
|
|
76
|
+
- HTTPS load balancers: `loadBalancers.create` and `update` take `protocol: "https"`,
|
|
77
|
+
`certificate_id`, `tls_policy` and `redirect_http`, and a load balancer reports
|
|
78
|
+
`certificate_fingerprint_sha256`.
|
|
79
|
+
- The vendored spec is the current public API, with DNS, domains, the container registry, IAM,
|
|
80
|
+
certificates and HTTPS load balancers, so `spec/pending/` is empty again. `npm run generate` and
|
|
81
|
+
the coverage test accept a missing `spec/pending/`.
|
|
82
|
+
|
|
7
83
|
## 0.3.0 (2026-11-06)
|
|
8
84
|
|
|
9
85
|
- `KubernetesFixedNodeSize` and `fixed_node_sizes` on the Kubernetes versions list: the zones
|
package/README.md
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
7
|
The official client for the [Pantech Dynamics public API](https://docs.pantechdynamics.com/api):
|
|
8
|
-
instances, VPC networks, firewalls, public IPs, load balancers, volumes, snapshots,
|
|
9
|
-
databases, managed Kubernetes, SSH keys, webhooks, billing, usage, and moving from another
|
|
8
|
+
instances, VPC networks, firewalls, public IPs, load balancers, volumes, snapshots, object storage,
|
|
9
|
+
managed databases, managed Kubernetes, SSH keys, webhooks, billing, usage, and moving from another
|
|
10
|
+
cloud.
|
|
10
11
|
|
|
11
12
|
- Zero runtime dependencies. Uses the global `fetch` and Web Crypto, so it runs on Node.js 18+,
|
|
12
13
|
Bun, Deno and edge runtimes.
|
|
@@ -65,17 +66,23 @@ Every method takes per-call options last: `{ signal, timeout, maxRetries, idempo
|
|
|
65
66
|
|---|---|
|
|
66
67
|
| Account | `me.get()`, `me.revoke()` |
|
|
67
68
|
| Catalogue | `regions.list()`, `plans.list({ placement })`, `images.list()`, `diskOfferings.quote(slug, { size_gb })`, `databaseEngines.list()`, `kubernetesVersions.list()`, `pricing.estimate({...})` |
|
|
68
|
-
| Instances | `instances.list/listAll/create/get/delete/start/stop/reboot/rebuild/rename/resize/restore/…`, `instances.snapshots.*`, `instances.sshAccess.*`, `instanceOrders.wait(order)` |
|
|
69
|
+
| Instances | `instances.list/listAll/create/get/delete/start/stop/reboot/rebuild/rename/resize/restore/…`, `instances.snapshots.*`, `instances.sshAccess.*`, `instances.dynamicIp.*`, `instanceOrders.wait(order)` |
|
|
69
70
|
| Networks | `networks.*`, `networks.subnets.list(networkId)`, `networks.firewallRules.create(subnetId, {...})` |
|
|
70
71
|
| Public IPs | `publicIps.*`, `publicIps.portForwardingRules.*` |
|
|
71
72
|
| Load balancers | `loadBalancers.*` |
|
|
72
73
|
| Kubernetes | `kubernetes.*`, `kubernetes.nodePools.*`, `kubernetes.addons.toggle(...)` |
|
|
73
74
|
| Security groups | `securityGroups.*`, `securityGroups.replaceRules(id, {...})` |
|
|
74
75
|
| Volumes and snapshots | `volumes.*`, `volumes.snapshots.*`, `snapshots.*` |
|
|
76
|
+
| Object storage | `objectStorage.getStatus/getUsage`, `objectStorage.keys.*`, `buckets.*`, `buckets.objects.*`, `buckets.multipart.*` |
|
|
75
77
|
| Databases | `databases.*`, `databases.snapshots.*`, `databaseOrders.wait(order)` |
|
|
76
78
|
| SSH keys, webhooks | `sshKeys.*`, `webhooks.*`, `webhooks.deliveries.*` |
|
|
77
79
|
| Billing and usage | `billing.credit.get()`, `billing.credit.purchases.create(...)`, `billing.receipts.getPdf(id)`, `usage.get()` |
|
|
78
80
|
| Move from another cloud | `migrate.connections.*`, `migrate.scans.*`, `migrate.migrations.*` |
|
|
81
|
+
| DNS | `dns.zones.*` (`exportZoneFile`, `importZoneFile`, `verify`, `wait`), `dns.records.*` (`batch`, `wait`) |
|
|
82
|
+
| Certificates | `certificates.request/import/get/list/update/verify/reimport/export/revoke/delete`, `certificates.wait(id)` |
|
|
83
|
+
| Teams and access policies | `iam.members.list()`, `iam.actions.list()`, `iam.settings.*`, `iam.teams.*`, `iam.teams.members.*`, `iam.policies.*`, `iam.policies.attachments.*`, `iam.effectiveAccess(userId)`, `iam.simulate({...})` |
|
|
84
|
+
| Container registry | `registry.namespace.get/set`, `registry.repositories.*`, `registry.tags.*`, `registry.tokens.*` |
|
|
85
|
+
| Domains | `domains.search({ query })`, `domains.register({...})`, `domains.transfer({...})`, `domains.renew(id)`, `domains.orders.wait(result)` |
|
|
79
86
|
| Operations | `operations.get(id)`, `operations.wait(id)`, `operations.stream(id)` |
|
|
80
87
|
|
|
81
88
|
Every operation in the public spec has a method, except agent sessions, which answer only AI apps
|
|
@@ -104,7 +111,74 @@ for await (const o of client.operations.stream("op_…")) console.log(o.status);
|
|
|
104
111
|
|
|
105
112
|
A failed operation rejects with `OperationFailedError` (`code`, `detail` from its `failure`), a
|
|
106
113
|
failed or unpaid order with `OrderFailedError`, a failed cloud connection or scan with
|
|
107
|
-
`CloudFailedError`,
|
|
114
|
+
`CloudFailedError`, a failed DNS zone or record change with `DNSFailedError`, a certificate that
|
|
115
|
+
cannot be issued with `CertificateFailedError`, and a wait that runs out with `WaitTimeoutError`.
|
|
116
|
+
|
|
117
|
+
## Dynamic IP
|
|
118
|
+
|
|
119
|
+
`client.instances.dynamicIp` manages a rotating public outbound address on a standard instance:
|
|
120
|
+
outbound traffic leaves from a dynamic IP that changes on your schedule (`every_12_hours`, `daily`,
|
|
121
|
+
`weekly`, or `monthly`), while inbound traffic continues to reach the instance's static address.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
// Enable Dynamic IP at creation time:
|
|
125
|
+
const order = await client.instances.create({
|
|
126
|
+
name: "worker-1",
|
|
127
|
+
plan_slug: "starter",
|
|
128
|
+
image_slug: "ubuntu-24-04",
|
|
129
|
+
ssh_key_id: "sshk_…",
|
|
130
|
+
security_group_id: "sg_…",
|
|
131
|
+
address_rotation: { schedule: "weekly", connections: "keep" },
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Or manage Dynamic IP on an existing instance:
|
|
135
|
+
await client.instances.dynamicIp.set("vm_…", { schedule: "daily", connections: "move", on_demand: true });
|
|
136
|
+
const ip = await client.instances.dynamicIp.get("vm_…");
|
|
137
|
+
console.log(ip.state, ip.current_address, ip.next_rotation_at);
|
|
138
|
+
|
|
139
|
+
// Rotate immediately (requires on_demand: true; sent once and never retried after an error):
|
|
140
|
+
await client.instances.dynamicIp.rotate("vm_…");
|
|
141
|
+
|
|
142
|
+
// Turn off Dynamic IP and end its surcharge:
|
|
143
|
+
await client.instances.dynamicIp.disable("vm_…");
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Object storage
|
|
147
|
+
|
|
148
|
+
`client.objectStorage` and `client.buckets` manage S3-compatible buckets, access keys, binary
|
|
149
|
+
uploads and downloads, per-object visibility, multipart uploads, and bucket rules (CORS, lifecycle,
|
|
150
|
+
tags, and object lock).
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const status = await client.objectStorage.getStatus();
|
|
154
|
+
const key = await client.objectStorage.keys.create({ name: "app", region: "af-abj" });
|
|
155
|
+
// key.secret_access_key is shown once and is non-enumerable (console.log / JSON.stringify omit it).
|
|
156
|
+
|
|
157
|
+
const bucket = await client.buckets.create({ name: "media-assets", region: "af-abj" });
|
|
158
|
+
|
|
159
|
+
// Upload raw bytes (Uint8Array, ArrayBuffer, Blob, or string) and download as ArrayBuffer:
|
|
160
|
+
await client.buckets.objects.upload(bucket.id, { key: "images/hero.png" }, pngBytes, {
|
|
161
|
+
headers: { "Content-Type": "image/png" },
|
|
162
|
+
});
|
|
163
|
+
const data = await client.buckets.objects.download(bucket.id, { key: "images/hero.png" });
|
|
164
|
+
|
|
165
|
+
// Publish one object and read its public URL:
|
|
166
|
+
const vis = await client.buckets.objects.setVisibility(bucket.id, { key: "images/hero.png", public: true });
|
|
167
|
+
console.log(vis.public_url);
|
|
168
|
+
|
|
169
|
+
// Multipart upload for large objects:
|
|
170
|
+
const session = await client.buckets.multipart.start(bucket.id, { key: "backups/db.tar.gz" });
|
|
171
|
+
const part1 = await client.buckets.multipart.uploadPart(
|
|
172
|
+
bucket.id,
|
|
173
|
+
{ key: "backups/db.tar.gz", upload_id: session.upload_id, part_number: 1 },
|
|
174
|
+
chunk1,
|
|
175
|
+
);
|
|
176
|
+
await client.buckets.multipart.complete(bucket.id, {
|
|
177
|
+
key: "backups/db.tar.gz",
|
|
178
|
+
upload_id: session.upload_id,
|
|
179
|
+
parts: [{ part_number: 1, etag: part1.etag }],
|
|
180
|
+
});
|
|
181
|
+
```
|
|
108
182
|
|
|
109
183
|
## Move from another cloud
|
|
110
184
|
|
|
@@ -127,6 +201,141 @@ const { files } = await client.migrate.migrations.exportTerraform(plan.id); // m
|
|
|
127
201
|
`migrate.migrations.updateItem(id, { key, excluded: true })` leaves an item out, or changes its
|
|
128
202
|
plan, size, address range or role, before you export. See `examples/migrate-from-aws.ts`.
|
|
129
203
|
|
|
204
|
+
## Certificates
|
|
205
|
+
|
|
206
|
+
`client.certificates` issues TLS certificates through a publicly trusted CA and renews them by
|
|
207
|
+
itself, or holds certificates you import, for Pantech load balancers and your own servers.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
let cert = await client.certificates.request({ names: ["example.com", "*.example.com"], exportable: true });
|
|
211
|
+
for (const v of cert.validations) {
|
|
212
|
+
// Names outside your Pantech DNS zones: add this CNAME once.
|
|
213
|
+
if (v.method === "cname") console.log(v.cname_name, "CNAME", v.cname_target);
|
|
214
|
+
}
|
|
215
|
+
cert = await client.certificates.wait(cert.id); // CertificateFailedError if it cannot be issued
|
|
216
|
+
|
|
217
|
+
const exported = await client.certificates.export(cert.id); // needs the delete scope; owners are emailed
|
|
218
|
+
await writeKeyFile(exported.private_key_pem); // non-enumerable: console.log and JSON.stringify leave it out
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
`certificates.import({ certificate_pem, private_key_pem })` imports one, `reimport` replaces it
|
|
222
|
+
before it expires, `verify` re-checks CNAMEs now, and `revoke` and `delete` retire it. The SDK never
|
|
223
|
+
logs request or response bodies, so an imported key is not logged either. See
|
|
224
|
+
`examples/certificates.ts`.
|
|
225
|
+
|
|
226
|
+
An appliance load balancer can end TLS with one: `client.loadBalancers.create({ …, protocol:
|
|
227
|
+
"https", certificate_id: cert.id, tls_policy: "modern", redirect_http: true })`; renewals reach it
|
|
228
|
+
by themselves. VPC native load balancers pass TLS through as `tcp`, and a certificate in use cannot
|
|
229
|
+
be revoked or deleted (`CERTIFICATE_IN_USE`).
|
|
230
|
+
|
|
231
|
+
## Teams and access policies
|
|
232
|
+
|
|
233
|
+
`client.iam` controls who in your organization may do what. Policies are statements that allow or
|
|
234
|
+
deny actions (`instances:Stop`, `dns:*`, `*:Read`) on resources (`*`, an id, or `name:staging-*`),
|
|
235
|
+
optionally only from some addresses or with MFA; attach them to members or teams. The `iam` helper
|
|
236
|
+
builds statements and checks the API's limits before the call.
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { iam } from "@pantechdynamic/sdk";
|
|
240
|
+
|
|
241
|
+
const team = await client.iam.teams.create({ name: "Platform" });
|
|
242
|
+
const policy = await client.iam.policies.create({
|
|
243
|
+
name: "staging-operators",
|
|
244
|
+
statements: [
|
|
245
|
+
iam.allow(["instances:Read", "instances:Start", "instances:Stop"], ["name:staging-*"], { sourceIp: ["102.89.0.0/16"] }),
|
|
246
|
+
iam.deny(["*:Delete"]),
|
|
247
|
+
],
|
|
248
|
+
});
|
|
249
|
+
await client.iam.policies.attachments.attach(policy.id, { principal_type: "team", principal_id: team.id });
|
|
250
|
+
await client.iam.teams.members.add(team.id, "usr_…");
|
|
251
|
+
|
|
252
|
+
const sim = await client.iam.simulate({ user_id: "usr_…", action: "instances:Delete", resource: "vm_…" });
|
|
253
|
+
console.log(sim.allowed, sim.decision); // false "explicit_deny"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
`iam.policies.update(id, body, { ifMatch: policy.version })` refuses a lost update.
|
|
257
|
+
`iam.actions.list()` is the action catalogue, `iam.effectiveAccess(userId)` what applies to a
|
|
258
|
+
member, `iam.settings` the organization's `member_baseline`, and `iam.MANAGED_POLICY_IDS`
|
|
259
|
+
Pantech's ready-made policies. See `examples/access-policies.ts`.
|
|
260
|
+
|
|
261
|
+
## Container registry
|
|
262
|
+
|
|
263
|
+
`client.registry` manages your private registry at `registry.pantechdynamics.com`: one namespace per
|
|
264
|
+
organization, repositories (private by default), their tags, and registry-only tokens for CI and
|
|
265
|
+
clusters. Push and pull with `docker`, logged in with an API key or a registry token.
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
await client.registry.namespace.set({ name: "acme" }); // once; images are registry.pantechdynamics.com/acme/…
|
|
269
|
+
const repo = await client.registry.repositories.create({
|
|
270
|
+
name: "api/server",
|
|
271
|
+
immutable_tags: true,
|
|
272
|
+
retention: { keep_last: 50, keep_pattern: "v*" },
|
|
273
|
+
});
|
|
274
|
+
for await (const tag of client.registry.tags.listAll(repo.id)) console.log(tag.name, tag.digest);
|
|
275
|
+
|
|
276
|
+
const token = await client.registry.tokens.create({ name: "github-actions", permission: "push", repositories: ["api/server"] });
|
|
277
|
+
await saveToCiSecrets(token.secret); // shown only now (null on a replayed create)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The token's `secret` is non-enumerable: `token.secret` reads it, but `console.log(token)` and
|
|
281
|
+
`JSON.stringify(token)` leave it out. `docker login registry.pantechdynamics.com -u pantech -p
|
|
282
|
+
<secret>` then works for that repository; `registry.tokens.delete(id)` revokes it. See
|
|
283
|
+
`examples/container-registry.ts`.
|
|
284
|
+
|
|
285
|
+
## DNS and domains
|
|
286
|
+
|
|
287
|
+
`client.dns` hosts zones on Pantech DNS, Pantech's own name servers; `client.domains` buys,
|
|
288
|
+
transfers in and renews domains, paid from your credit. Each zone gets its own two name servers to
|
|
289
|
+
set at your registrar. Changes go live in the background: a record set is `pending` until it
|
|
290
|
+
answers, usually within a minute, and records added before the zone is `active` (delegated) stay
|
|
291
|
+
`pending` until it is. The first 5 zones are free; `client.dns.zones.quote()` gives the price of the
|
|
292
|
+
rest in your currency.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
let zone = await client.dns.zones.create({ name: "example.com" });
|
|
296
|
+
zone = await client.dns.zones.wait(zone.id); // until it has its name servers
|
|
297
|
+
console.log(zone.name_servers); // set these at your registrar
|
|
298
|
+
|
|
299
|
+
const rec = await client.dns.records.create(zone.id, { name: "www", type: "A", values: ["203.0.113.10"] });
|
|
300
|
+
await client.dns.records.wait(zone.id, rec.id); // DNSFailedError if the change fails
|
|
301
|
+
|
|
302
|
+
// Change it only if nobody else did since you read it (412 PreconditionFailedError otherwise).
|
|
303
|
+
await client.dns.records.update(zone.id, rec.id, { values: ["203.0.113.11"] }, { ifMatch: rec.version });
|
|
304
|
+
|
|
305
|
+
await client.dns.records.batch(zone.id, {
|
|
306
|
+
changes: [
|
|
307
|
+
{ action: "create", record: { name: "@", type: "MX", values: ["10 mail.example.com"] } },
|
|
308
|
+
{ action: "delete", record_id: "dnsr_…" },
|
|
309
|
+
],
|
|
310
|
+
});
|
|
311
|
+
const zoneFile = await client.dns.zones.exportZoneFile(zone.id); // BIND zone file, as a string
|
|
312
|
+
|
|
313
|
+
const { data } = await client.domains.search({ query: "example" });
|
|
314
|
+
const result = await client.domains.register({ name: "example.com", contact, accept_terms: true });
|
|
315
|
+
try {
|
|
316
|
+
await client.domains.orders.wait(result); // OrderFailedError (amount refunded) if it fails
|
|
317
|
+
} catch (err) {
|
|
318
|
+
if (!(err instanceof PaymentRequiredError)) throw err;
|
|
319
|
+
// Your credit does not cover it: the order waits for a payment until err.paymentExpiresAt.
|
|
320
|
+
// In US dollars your saved card is charged the difference; in naira, add credit.
|
|
321
|
+
if (err.paymentUrl) sendUserTo(err.paymentUrl); // only when the bank asks to confirm the payment
|
|
322
|
+
await client.domains.orders.wait(result, { waitForPayment: true });
|
|
323
|
+
// Or, after saving a new card or adding credit: await client.domains.orders.retryPayment(result.order.id);
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Prices are before VAT. A TLD whose offer has `privacy_always_on: true` (the `.ng` family) has
|
|
328
|
+
privacy protection that cannot be turned off: asking for `privacy: false` is a `422` naming field
|
|
329
|
+
`privacy` with code `PRIVACY_ALWAYS_ON`. `.ng` contacts need `state` and `postal_code`, and
|
|
330
|
+
`name.ng` registrants must be people (`type: "person"`). Send `accept_terms: true` only once the
|
|
331
|
+
registrant has read and accepted the
|
|
332
|
+
[Domain Registration Agreement](https://pantechdynamics.com/legal/domain-registration).
|
|
333
|
+
|
|
334
|
+
`domains` also has `listTlds`, `checkTransfer`, `update` (auto-renew, transfer lock, privacy),
|
|
335
|
+
`setNameServers`, `getContact`/`updateContact`, `requestAuthCode`/`getAuthCode`,
|
|
336
|
+
`orders.list(domainId)`, `orders.get(orderId)` and `orders.retryPayment(orderId)`. The registrant
|
|
337
|
+
contact is personal data: the SDK never logs requests or responses. See `examples/dns-and-domains.ts`.
|
|
338
|
+
|
|
130
339
|
## Errors
|
|
131
340
|
|
|
132
341
|
Every error is a `PantechError` carrying `status`, `code`, `title`, `detail`, `requestId` and
|
|
@@ -145,9 +354,16 @@ try {
|
|
|
145
354
|
```
|
|
146
355
|
|
|
147
356
|
Subclasses: `BadRequestError` (400), `AuthenticationError` (401), `PaymentRequiredError` (402),
|
|
148
|
-
`PermissionDeniedError` (403), `NotFoundError` (404), `ConflictError` (409),
|
|
149
|
-
(
|
|
150
|
-
`APITimeoutError` (no answer).
|
|
357
|
+
`PermissionDeniedError` (403), `NotFoundError` (404), `ConflictError` (409),
|
|
358
|
+
`PreconditionFailedError` (412), `ValidationError` (422), `RateLimitError` (429),
|
|
359
|
+
`InternalServerError` (5xx), `APIConnectionError` and `APITimeoutError` (no answer).
|
|
360
|
+
|
|
361
|
+
DNS and domain codes are typed: `DNSErrorCode` and `DomainErrorCode` are unions of every code those
|
|
362
|
+
endpoints answer with (`DNS_RECORD_EXISTS`, `VERSION_CONFLICT`, `DOMAIN_NOT_AVAILABLE`…), listed at
|
|
363
|
+
runtime in `DNS_ERROR_CODES` and `DOMAIN_ERROR_CODES` (and `RegistryErrorCode`,
|
|
364
|
+
`REGISTRY_ERROR_CODES` for the container registry, `IamErrorCode`, `IAM_ERROR_CODES` for access
|
|
365
|
+
policies, `CertificateErrorCode`, `CERTIFICATE_ERROR_CODES` for certificates), and `isPantechError(err, code)` completes
|
|
366
|
+
them.
|
|
151
367
|
|
|
152
368
|
## Retries and idempotency
|
|
153
369
|
|
|
@@ -158,8 +374,10 @@ to `maxRetries` times with jittered backoff.
|
|
|
158
374
|
|
|
159
375
|
The API does not replay some writes by key, so the SDK sends them once (except after a `429`,
|
|
160
376
|
which is refused before anything runs): creating and deleting SSH keys, opening an instance
|
|
161
|
-
console, issuing a volume key credential,
|
|
162
|
-
|
|
377
|
+
console, issuing a volume key credential, rotating an instance's dynamic IP now
|
|
378
|
+
(`instances.dynamicIp.rotate`), creating object storage access keys, emptying a bucket, starting
|
|
379
|
+
and completing multipart uploads, testing, deleting, rotating the secret of and redelivering
|
|
380
|
+
webhooks, and `DELETE /me`.
|
|
163
381
|
|
|
164
382
|
## Webhooks
|
|
165
383
|
|
|
@@ -180,7 +398,8 @@ the timestamp is too old. On Node.js 18, start node with `--experimental-global-
|
|
|
180
398
|
|
|
181
399
|
## Examples
|
|
182
400
|
|
|
183
|
-
`examples/` has `create-instance.ts`, `list.ts`, `webhook-receiver.ts
|
|
401
|
+
`examples/` has `create-instance.ts`, `list.ts`, `webhook-receiver.ts`, `migrate-from-aws.ts`,
|
|
402
|
+
`dns-and-domains.ts`, `container-registry.ts`, `access-policies.ts` and `certificates.ts`. With Node.js 23.6+:
|
|
184
403
|
`npm run build && PANTECH_API_KEY=PAN_… node examples/list.ts`.
|
|
185
404
|
|
|
186
405
|
## Development
|