@pantechdynamic/sdk 0.4.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/dist/index.js CHANGED
@@ -325,7 +325,7 @@ async function* paginate(fetchPage, startCursor) {
325
325
  }
326
326
 
327
327
  // src/resource.ts
328
- var SECRET_FIELDS = ["secret", "private_key_pem"];
328
+ var SECRET_FIELDS = ["secret", "private_key_pem", "secret_access_key"];
329
329
  function hideSecrets(value) {
330
330
  if (value && typeof value === "object") {
331
331
  for (const field of SECRET_FIELDS) {
@@ -901,13 +901,18 @@ var Domains = class extends APIResource {
901
901
  }
902
902
  /**
903
903
  * Buys the domain for `years` (1 to 10), paid from your credit first; a
904
- * failed order is refunded. `accept_terms` must be true. Follow the order
905
- * with `orders.wait(result)`.
904
+ * failed order is refunded. `accept_terms` must be true: the registrant has
905
+ * accepted the Domain Registration Agreement
906
+ * (https://pantechdynamics.com/legal/domain-registration). Follow the order with
907
+ * `orders.wait(result)`.
906
908
  */
907
909
  register(body, options) {
908
910
  return this._post("/domains", body, options);
909
911
  }
910
- /** Moves a domain to Pantech with its auth code, adding `years` to its term. Follow it with `orders.wait`. */
912
+ /**
913
+ * Moves a domain to Pantech with its auth code, adding `years` to its term.
914
+ * `accept_terms` must be true, as for `register`. Follow it with `orders.wait`.
915
+ */
911
916
  transfer(body, options) {
912
917
  return this._post("/domains/transfers", body, options);
913
918
  }
@@ -1142,6 +1147,8 @@ var Instances = class extends APIResource {
1142
1147
  snapshots = new InstanceSnapshots(this._client);
1143
1148
  /** Short-lived SSH access grants through the browser terminal relay. */
1144
1149
  sshAccess = new InstanceSshAccess(this._client);
1150
+ /** Dynamic IP: a public outbound address that rotates on a schedule or on demand. */
1151
+ dynamicIp = new InstanceDynamicIp(this._client);
1145
1152
  /** One page of your instances. */
1146
1153
  list(params = {}, options) {
1147
1154
  return this._get("/instances", params, options);
@@ -1249,6 +1256,24 @@ var InstanceSshAccess = class extends APIResource {
1249
1256
  return this._delete(path`/instances/${instanceId}/ssh-access/${grantId}`, options);
1250
1257
  }
1251
1258
  };
1259
+ var InstanceDynamicIp = class extends APIResource {
1260
+ /** Whether the instance has a dynamic IP, its schedule, current address and recent changes. */
1261
+ get(instanceId, options) {
1262
+ return this._get(path`/instances/${instanceId}/address-rotation`, void 0, options);
1263
+ }
1264
+ /** Turns on or changes dynamic IP settings for the instance. */
1265
+ set(instanceId, body, options) {
1266
+ return this._put(path`/instances/${instanceId}/address-rotation`, body, options);
1267
+ }
1268
+ /** Turns off dynamic IP for the instance and stops its surcharge. */
1269
+ disable(instanceId, options) {
1270
+ return this._delete(path`/instances/${instanceId}/address-rotation`, options);
1271
+ }
1272
+ /** Gives the instance a new dynamic IP now, outside its schedule. Sent once: the API does not replay it. */
1273
+ rotate(instanceId, options) {
1274
+ return this._post(path`/instances/${instanceId}/address-rotation/rotate`, void 0, options, { noRetry: true });
1275
+ }
1276
+ };
1252
1277
  var InstanceOrders = class extends APIResource {
1253
1278
  list(params = {}, options) {
1254
1279
  return this._get("/instance-orders", params, options);
@@ -1602,6 +1627,192 @@ var FirewallRules = class extends APIResource {
1602
1627
  }
1603
1628
  };
1604
1629
 
1630
+ // src/resources/object-storage.ts
1631
+ var ObjectStorage = class extends APIResource {
1632
+ /** S3 access keys for your organization. */
1633
+ keys = new ObjectStorageKeys(this._client);
1634
+ /** Whether object storage is available, with endpoints and regional pricing. */
1635
+ getStatus(options) {
1636
+ return this._get("/object-storage", void 0, options);
1637
+ }
1638
+ /** Hourly object storage traffic and operations for your organization. */
1639
+ getUsage(params = {}, options) {
1640
+ return this._get("/object-storage/usage", params, options);
1641
+ }
1642
+ };
1643
+ var ObjectStorageKeys = class extends APIResource {
1644
+ /** Lists your S3 access keys without their secrets. */
1645
+ list(params = {}, options) {
1646
+ return this._get("/object-storage/keys", params, options);
1647
+ }
1648
+ /**
1649
+ * Creates an S3 access key. Its `secret_access_key` is returned once and
1650
+ * never replayed; it is non-enumerable so `console.log` and `JSON.stringify`
1651
+ * leave it out while `key.secret_access_key` reads it.
1652
+ */
1653
+ async create(body, options) {
1654
+ return hideSecrets(
1655
+ await this._post("/object-storage/keys", body, options, { noRetry: true })
1656
+ );
1657
+ }
1658
+ /** Revokes an S3 access key at once. */
1659
+ revoke(storageKeyId, options) {
1660
+ return this._delete(path`/object-storage/keys/${storageKeyId}`, options);
1661
+ }
1662
+ };
1663
+ var Buckets = class extends APIResource {
1664
+ /** Objects and folders inside a bucket. */
1665
+ objects = new BucketObjects(this._client);
1666
+ /** Multipart uploads for large objects. */
1667
+ multipart = new BucketMultipart(this._client);
1668
+ /** Lists every bucket in your organization. */
1669
+ list(options) {
1670
+ return this._get("/buckets", void 0, options);
1671
+ }
1672
+ /** Creates a new bucket. */
1673
+ create(body, options) {
1674
+ return this._post("/buckets", body, options);
1675
+ }
1676
+ /** Gets one bucket's settings and endpoints. */
1677
+ get(bucketId, options) {
1678
+ return this._get(path`/buckets/${bucketId}`, void 0, options);
1679
+ }
1680
+ /** Updates a bucket's versioning, access policy, or public prefixes. */
1681
+ update(bucketId, body, options) {
1682
+ return this._patch(path`/buckets/${bucketId}`, body, options);
1683
+ }
1684
+ /** Deletes a bucket. Pass `{ force: true }` to empty it before removal. */
1685
+ delete(bucketId, params = {}, options) {
1686
+ return this._request("DELETE", path`/buckets/${bucketId}`, { query: params }, options);
1687
+ }
1688
+ /** Live total size and object count of a bucket. */
1689
+ stats(bucketId, options) {
1690
+ return this._get(path`/buckets/${bucketId}/stats`, void 0, options);
1691
+ }
1692
+ /** Deletes all objects, versions, and active multipart uploads in a bucket. Sent once: not retried on error. */
1693
+ empty(bucketId, options) {
1694
+ return this._post(path`/buckets/${bucketId}/empty`, void 0, options, { noRetry: true });
1695
+ }
1696
+ /** Reads the bucket's CORS rules. */
1697
+ getCors(bucketId, options) {
1698
+ return this._get(path`/buckets/${bucketId}/cors`, void 0, options);
1699
+ }
1700
+ /** Replaces the bucket's CORS rules (an empty list clears them). */
1701
+ setCors(bucketId, body, options) {
1702
+ return this._put(path`/buckets/${bucketId}/cors`, body, options);
1703
+ }
1704
+ /** Reads the bucket's lifecycle rules. */
1705
+ getLifecycle(bucketId, options) {
1706
+ return this._get(path`/buckets/${bucketId}/lifecycle`, void 0, options);
1707
+ }
1708
+ /** Replaces the bucket's lifecycle rules (an empty list clears them). */
1709
+ setLifecycle(bucketId, body, options) {
1710
+ return this._put(path`/buckets/${bucketId}/lifecycle`, body, options);
1711
+ }
1712
+ /** Reads the bucket's tags. */
1713
+ getTags(bucketId, options) {
1714
+ return this._get(path`/buckets/${bucketId}/tags`, void 0, options);
1715
+ }
1716
+ /** Replaces the bucket's tags (an empty list clears them). */
1717
+ setTags(bucketId, body, options) {
1718
+ return this._put(path`/buckets/${bucketId}/tags`, body, options);
1719
+ }
1720
+ /** Reads the bucket's default object lock configuration. */
1721
+ getObjectLock(bucketId, options) {
1722
+ return this._get(path`/buckets/${bucketId}/object-lock`, void 0, options);
1723
+ }
1724
+ /** Updates the bucket's default object lock configuration. */
1725
+ setObjectLock(bucketId, body, options) {
1726
+ return this._put(path`/buckets/${bucketId}/object-lock`, body, options);
1727
+ }
1728
+ };
1729
+ var BucketObjects = class extends APIResource {
1730
+ /** Lists folders and objects under a prefix, searches across the bucket, or lists object versions. */
1731
+ list(bucketId, params = {}, options) {
1732
+ return this._get(path`/buckets/${bucketId}/objects`, params, options);
1733
+ }
1734
+ /** Reads metadata, headers, tags, lock status, and public visibility of one object. */
1735
+ getMeta(bucketId, params, options) {
1736
+ return this._get(path`/buckets/${bucketId}/objects/meta`, params, options);
1737
+ }
1738
+ /** Downloads an object's raw bytes as an `ArrayBuffer`. */
1739
+ download(bucketId, params, options) {
1740
+ return this._request(
1741
+ "GET",
1742
+ path`/buckets/${bucketId}/objects/download`,
1743
+ { query: params, responseType: "arrayBuffer" },
1744
+ options
1745
+ );
1746
+ }
1747
+ /** Mints a short-lived signed download URL when direct transfers are enabled. */
1748
+ presignDownload(bucketId, body, options) {
1749
+ return this._post(path`/buckets/${bucketId}/objects/download-url`, body, options);
1750
+ }
1751
+ /**
1752
+ * Streams an object upload into the bucket as raw bytes. Sets
1753
+ * `Content-Type: application/octet-stream` unless `options.headers` sets a
1754
+ * custom `Content-Type`.
1755
+ */
1756
+ upload(bucketId, params, body, options) {
1757
+ return this._request("PUT", path`/buckets/${bucketId}/objects/upload`, { query: params, rawBody: body }, options);
1758
+ }
1759
+ /** Mints a short-lived signed upload URL when direct transfers are enabled. */
1760
+ presignUpload(bucketId, body, options) {
1761
+ return this._post(path`/buckets/${bucketId}/objects/upload-url`, body, options);
1762
+ }
1763
+ /** Creates a folder marker object ending with `/`. */
1764
+ createFolder(bucketId, body, options) {
1765
+ return this._post(path`/buckets/${bucketId}/objects/folder`, body, options);
1766
+ }
1767
+ /** Copies, renames, or updates metadata of an object inside the bucket. */
1768
+ copy(bucketId, body, options) {
1769
+ return this._post(path`/buckets/${bucketId}/objects/copy`, body, options);
1770
+ }
1771
+ /** Deletes one or more objects or versions, or deletes a folder prefix recursively. */
1772
+ delete(bucketId, body, options) {
1773
+ return this._post(path`/buckets/${bucketId}/objects/delete`, body, options);
1774
+ }
1775
+ /** Replaces tags on an object or object version. */
1776
+ setTags(bucketId, body, options) {
1777
+ return this._put(path`/buckets/${bucketId}/objects/tags`, body, options);
1778
+ }
1779
+ /** Sets retention or legal hold on an object or object version. */
1780
+ setLock(bucketId, body, options) {
1781
+ return this._put(path`/buckets/${bucketId}/objects/lock`, body, options);
1782
+ }
1783
+ /** Sets whether a specific object is publicly readable and returns its `public_url`. */
1784
+ setVisibility(bucketId, body, options) {
1785
+ return this._put(path`/buckets/${bucketId}/objects/visibility`, body, options);
1786
+ }
1787
+ };
1788
+ var BucketMultipart = class extends APIResource {
1789
+ /** Starts a multipart upload session for a large object. Sent once: not retried on error. */
1790
+ start(bucketId, body, options) {
1791
+ return this._post(path`/buckets/${bucketId}/objects/multipart/start`, body, options, { noRetry: true });
1792
+ }
1793
+ /** Mints a short-lived signed upload URL for one part of an active multipart upload. */
1794
+ signPart(bucketId, body, options) {
1795
+ return this._post(path`/buckets/${bucketId}/objects/multipart/sign-part`, body, options);
1796
+ }
1797
+ /** Uploads one part of an active multipart upload as raw bytes. */
1798
+ uploadPart(bucketId, params, body, options) {
1799
+ return this._request(
1800
+ "PUT",
1801
+ path`/buckets/${bucketId}/objects/multipart/part`,
1802
+ { query: params, rawBody: body },
1803
+ options
1804
+ );
1805
+ }
1806
+ /** Completes a multipart upload from its uploaded part ETags. Sent once: not retried on error. */
1807
+ complete(bucketId, body, options) {
1808
+ return this._post(path`/buckets/${bucketId}/objects/multipart/complete`, body, options, { noRetry: true });
1809
+ }
1810
+ /** Aborts an active multipart upload and discards uploaded parts. */
1811
+ abort(bucketId, body, options) {
1812
+ return this._post(path`/buckets/${bucketId}/objects/multipart/abort`, body, options);
1813
+ }
1814
+ };
1815
+
1605
1816
  // src/resources/operations.ts
1606
1817
  function operationId(ref) {
1607
1818
  const id = typeof ref === "string" ? ref : ref.operation_id;
@@ -2032,7 +2243,7 @@ var WebhookDeliveries = class extends APIResource {
2032
2243
  };
2033
2244
 
2034
2245
  // src/version.ts
2035
- var VERSION = "0.4.0";
2246
+ var VERSION = "0.5.0";
2036
2247
 
2037
2248
  // src/client.ts
2038
2249
  var DEFAULT_BASE_URL = "https://api.pantechdynamics.com/public/v1";
@@ -2042,7 +2253,7 @@ var MAX_RETRY_AFTER_MS = 6e4;
2042
2253
  var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2043
2254
  var ACCEPT = {
2044
2255
  json: "application/json",
2045
- arrayBuffer: "*/*",
2256
+ arrayBuffer: "application/octet-stream",
2046
2257
  text: "text/dns, text/plain;q=0.9",
2047
2258
  response: "application/json"
2048
2259
  };
@@ -2095,6 +2306,10 @@ var Pantech = class {
2095
2306
  iam;
2096
2307
  /** TLS certificates Pantech issues and renews, or ones you import. */
2097
2308
  certificates;
2309
+ /** S3-compatible object storage: status, usage and access keys. */
2310
+ objectStorage;
2311
+ /** Object storage buckets, objects, multipart uploads and bucket rules. */
2312
+ buckets;
2098
2313
  operations;
2099
2314
  constructor(options = {}) {
2100
2315
  const apiKey = options.apiKey ?? readEnv("PANTECH_API_KEY");
@@ -2142,6 +2357,8 @@ var Pantech = class {
2142
2357
  this.registry = new Registry(this);
2143
2358
  this.iam = new IAM(this);
2144
2359
  this.certificates = new Certificates(this);
2360
+ this.objectStorage = new ObjectStorage(this);
2361
+ this.buckets = new Buckets(this);
2145
2362
  }
2146
2363
  /**
2147
2364
  * Sends one request and returns its decoded body (undefined for an empty
@@ -2158,7 +2375,12 @@ var Pantech = class {
2158
2375
  Authorization: `Bearer ${this.#apiKey}`
2159
2376
  };
2160
2377
  let payload;
2161
- if (req.body !== void 0) {
2378
+ if (req.rawBody !== void 0) {
2379
+ payload = req.rawBody;
2380
+ if (!hasHeader(headers, "content-type")) {
2381
+ headers["Content-Type"] = "application/octet-stream";
2382
+ }
2383
+ } else if (req.body !== void 0) {
2162
2384
  payload = JSON.stringify(req.body);
2163
2385
  headers["Content-Type"] = "application/json";
2164
2386
  }
@@ -2216,6 +2438,9 @@ var Pantech = class {
2216
2438
  }
2217
2439
  }
2218
2440
  };
2441
+ function hasHeader(headers, name) {
2442
+ return Object.keys(headers).some((key) => key.toLowerCase() === name);
2443
+ }
2219
2444
  function queryString(query) {
2220
2445
  if (!query) return "";
2221
2446
  const params = new URLSearchParams();