hcloud-sdk 22.48.0 → 22.49.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 CHANGED
@@ -1,5 +1,11 @@
1
- ## [22.48.0](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/compare/v22.47.0...v22.48.0) (2026-10-05)
1
+ ## [22.49.0](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/compare/v22.48.0...v22.49.0) (2026-10-07)
2
2
 
3
3
  ### Features
4
4
 
5
- * reflect changes made in high5 ([af4a2a1](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/af4a2a1a89937f24f72b5e163d099b1fc0c6a1de))
5
+ * add a capacityInGB quota for default storage as well ([3b4ae0c](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/3b4ae0cf85bb1a85e5ba8d070c805ff216196169))
6
+ * add capacityInGB which reflects license quota as max usable capacity ([75a1dea](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/75a1dea437d657eacd967abaad9ae3e5688bd468))
7
+ * reflect new introduced byos license endpoint and interfaces ([efcb701](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/efcb701645e1e0f06800ba8e7c13c117d547c444))
8
+
9
+ ### Bug Fixes
10
+
11
+ * default license quota determination and application ([e228077](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/e2280774fec9b1a4969743b8c70ded3e307625fd))
@@ -17,7 +17,13 @@ export type Storage = {
17
17
  spaces: (ReducedSpace & {
18
18
  storageUsed: number;
19
19
  })[];
20
+ /** Total bytes used across all spaces assigned to this storage. For the default storage only the spaces of the requesting organization. */
20
21
  storageUsed: number;
22
+ /**
23
+ * Licensed maximum capacity in GB (1 GB = 1024³ bytes). For the default storage the default storage quota of the organization.
24
+ * For own storages the storages quota of the organization, shared across all of its own storages (0 if own storages are not allowed).
25
+ */
26
+ capacityInGB: number;
21
27
  valid: boolean;
22
28
  errorMessage?: string;
23
29
  };
@@ -32,6 +38,21 @@ export type StorageConfiguration = {
32
38
  isDefault: boolean;
33
39
  valid: boolean;
34
40
  };
41
+ export type StorageCapacity = {
42
+ storageId: string;
43
+ /** Organization the capacity was determined for. For own storages the owner, for the default storage the requested organization. */
44
+ organizationId: string;
45
+ /** Whether the storage is the default storage */
46
+ isDefault: boolean;
47
+ /** Whether the license of the organization allows own storages */
48
+ byos: boolean;
49
+ /** Licensed capacity in bytes. For own storages across all own storages of the organization, for the default storage the default storage quota of the organization. */
50
+ capacityBytes?: number;
51
+ /** Current usage in bytes. For own storages across all own storages of the organization, for the default storage by the spaces of the organization. */
52
+ usedBytes?: number;
53
+ /** Whether an upload of the requested size would exceed the licensed capacity */
54
+ exceeded: boolean;
55
+ };
35
56
  export type StorageDto = Omit<Storage, "accessKeyId" | "secretAccessKey">;
36
57
  export type StorageCreateDto = Pick<Storage, "name" | "endpoint" | "bucket" | "region"> & {
37
58
  accessKeyId: string;
@@ -24,6 +24,17 @@ type LicenseQuotaBase = {
24
24
  domains: {
25
25
  quota: number;
26
26
  };
27
+ /** Bring your own storage quota. Absent on older licenses, in which case own storages are not allowed. */
28
+ storages?: {
29
+ byos: boolean;
30
+ quota: number;
31
+ capacityInGB: number;
32
+ };
33
+ /** Default (hcloud provided) storage quota. Absent on older licenses, in which case a capacity of 1 GB applies. */
34
+ defaultStorage?: {
35
+ /** Maximum usage of the default storage in GB (1 GB = 1024³ bytes). */
36
+ capacityInGB: number;
37
+ };
27
38
  logPeriodInDays: number;
28
39
  };
29
40
  };
@@ -1,6 +1,6 @@
1
1
  import Base, { MaybeRaw } from "../../../../Base";
2
2
  import { PaginatedResponse, SearchFilter, Sorting } from "../../../../interfaces/global";
3
- import { StorageDto as Storage, StorageConfiguration, StorageCreateDto, StoragePatchDto } from "../../../../interfaces/global/Storage";
3
+ import { StorageDto as Storage, StorageCapacity, StorageConfiguration, StorageCreateDto, StoragePatchDto } from "../../../../interfaces/global/Storage";
4
4
  export declare class IdpOrganizationStorages extends Base {
5
5
  /**
6
6
  * Creates a new Storage in the specified Organization.
@@ -82,5 +82,20 @@ export declare class IdpOrganizationStorages extends Base {
82
82
  getStorageConfig<R extends boolean = false>(pat: string, storageId?: string, decrypt?: boolean, raw?: {
83
83
  raw: R;
84
84
  }): Promise<MaybeRaw<R, StorageConfiguration>>;
85
+ /**
86
+ * Checks whether the specified Storage can take an upload of the given size according to the license of an Organization.
87
+ * Own Storages are limited by the storages quota of the owning Organization, the default Storage by the default storage quota
88
+ * of the given Organization (counting only its Spaces). Requires a Personal Access Token (PAT) with appropriate permissions.
89
+ *
90
+ * @param pat Personal Access Token
91
+ * @param storageId (optional) ID of storage. If not provided or "default", the default storage is checked.
92
+ * @param uploadSize (optional) Size of the upload that is about to start in bytes. If omitted, it is checked whether the capacity is already reached.
93
+ * @param orgName (optional) Name of the Organization the upload belongs to. Required for the default storage, must be the owner for own storages.
94
+ * @param raw (optional) If true, returns the raw Axios response instead of the data
95
+ * @returns The Storage capacity
96
+ */
97
+ getStorageCapacity<R extends boolean = false>(pat: string, storageId?: string, uploadSize?: number, orgName?: string, raw?: {
98
+ raw: R;
99
+ }): Promise<MaybeRaw<R, StorageCapacity>>;
85
100
  protected getEndpoint(endpoint: string): string;
86
101
  }
@@ -129,6 +129,30 @@ class IdpOrganizationStorages extends Base_1.default {
129
129
  return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
130
130
  });
131
131
  }
132
+ /**
133
+ * Checks whether the specified Storage can take an upload of the given size according to the license of an Organization.
134
+ * Own Storages are limited by the storages quota of the owning Organization, the default Storage by the default storage quota
135
+ * of the given Organization (counting only its Spaces). Requires a Personal Access Token (PAT) with appropriate permissions.
136
+ *
137
+ * @param pat Personal Access Token
138
+ * @param storageId (optional) ID of storage. If not provided or "default", the default storage is checked.
139
+ * @param uploadSize (optional) Size of the upload that is about to start in bytes. If omitted, it is checked whether the capacity is already reached.
140
+ * @param orgName (optional) Name of the Organization the upload belongs to. Required for the default storage, must be the owner for own storages.
141
+ * @param raw (optional) If true, returns the raw Axios response instead of the data
142
+ * @returns The Storage capacity
143
+ */
144
+ getStorageCapacity(pat_1) {
145
+ return __awaiter(this, arguments, void 0, function* (pat, storageId = "default", uploadSize, orgName, raw) {
146
+ const resp = yield this.axios.get(`${this.options.server}/api/account/v1/storage/${storageId}/capacity`, {
147
+ params: Object.assign(Object.assign({}, (uploadSize !== undefined ? { uploadSize } : {})), (orgName !== undefined ? { orgName } : {})),
148
+ headers: {
149
+ Authorization: `Bearer ${pat}`,
150
+ "x-hcloud-login-enforce": "true",
151
+ },
152
+ });
153
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
154
+ });
155
+ }
132
156
  getEndpoint(endpoint) {
133
157
  return `${this.options.server}/api/account/v1/org${endpoint}`;
134
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hcloud-sdk",
3
- "version": "22.48.0",
3
+ "version": "22.49.0",
4
4
  "description": "hcloud platform sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",