@kumulo/upcloud 0.0.1 → 0.2.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/LICENSE +20 -0
- package/README.md +39 -0
- package/dist/client/common.d.ts +16 -0
- package/dist/client/network.d.ts +99 -0
- package/dist/client/node-groups.d.ts +76 -0
- package/dist/client/object-storage.d.ts +121 -0
- package/dist/client/storage.d.ts +47 -0
- package/dist/client/uks.d.ts +65 -0
- package/dist/client/zone.d.ts +14 -0
- package/dist/errors.d.ts +16 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +375 -0
- package/dist/transport/http-client.d.ts +15 -0
- package/package.json +58 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Stahl-Gruber
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @kumulo/upcloud
|
|
2
|
+
|
|
3
|
+
Hand-written UpCloud API client: Managed Kubernetes (UKS) clusters and node
|
|
4
|
+
groups, plus the SDN network and router resources a UKS cluster needs.
|
|
5
|
+
|
|
6
|
+
Part of [kumulo](../../../README.md) — a CLI that provisions and manages
|
|
7
|
+
Kubernetes clusters on OVH, Hetzner, OpenStack and UpCloud from a single YAML
|
|
8
|
+
config. This package is published from that workspace and is normally
|
|
9
|
+
consumed through the `kumulo` CLI rather than directly.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
bun add @kumulo/upcloud
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Why hand-written (D1)
|
|
16
|
+
|
|
17
|
+
Every other provider client in this workspace (`@kumulo/hetzner`,
|
|
18
|
+
`@kumulo/dns-hetzner`, `packages/openstack/client`'s generated clients,
|
|
19
|
+
`tools/ovh2openapi`) is generated from a vendor-published OpenAPI spec via
|
|
20
|
+
`@effect/openapi-generator`. UpCloud publishes no such spec — its API
|
|
21
|
+
reference is hand-maintained prose, not a machine-readable document — so
|
|
22
|
+
this package is hand-written against that documentation instead, and is
|
|
23
|
+
**deliberately exempt from `codegen:check`**: it is simply absent from
|
|
24
|
+
`tools/codegen/services.json`, the registry that drives regeneration and
|
|
25
|
+
staleness checking, so there is nothing for that check to compare against.
|
|
26
|
+
|
|
27
|
+
## D15 — a narrow dependency-cruiser exception
|
|
28
|
+
|
|
29
|
+
`@kumulo/distro-upcloud-uks` depends on this package, which is an edge
|
|
30
|
+
`no-sibling-package-imports` forbids as written (non-core siblings may not
|
|
31
|
+
depend on each other). `.dependency-cruiser.cjs` relaxes that rule for
|
|
32
|
+
*incoming* edges into `@kumulo/upcloud` only — this package is treated like
|
|
33
|
+
`@kumulo/core` from the outside. Its own *outgoing* imports stay fully
|
|
34
|
+
governed by the original rule: `@kumulo/upcloud` may still import
|
|
35
|
+
`@kumulo/core` and nothing else, keeping it a dependency leaf. See D15 in
|
|
36
|
+
`.docs/workflows/upcloud-uks/requirements.md`.
|
|
37
|
+
|
|
38
|
+
See the [root README](../../../README.md) for configuration, commands and
|
|
39
|
+
examples, and the [changelog](../../../CHANGELOG.md) for release notes.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaError } from "effect/Schema";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as HttpClientError from "effect/http/HttpClientError";
|
|
4
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
import type { PaginationError } from "@kumulo/core";
|
|
7
|
+
export declare const UpcloudLabel: Schema.Struct<{
|
|
8
|
+
readonly key: Schema.String;
|
|
9
|
+
readonly value: Schema.String;
|
|
10
|
+
}>;
|
|
11
|
+
export type UpcloudLabel = typeof UpcloudLabel.Type;
|
|
12
|
+
export declare const UpcloudBoolean: Schema.decodeTo<Schema.Boolean, Schema.Union<readonly [Schema.Boolean, Schema.Literals<readonly ["yes", "no"]>]>, never, never>;
|
|
13
|
+
export type UpcloudRawError = HttpClientError.HttpClientError | SchemaError | PaginationError;
|
|
14
|
+
export declare const isOk: (response: HttpClientResponse.HttpClientResponse) => boolean;
|
|
15
|
+
export declare const decodeOn2xx: <A, I>(schema: Schema.Codec<A, I>) => (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<A, UpcloudRawError>;
|
|
16
|
+
export declare const decodeVoid: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<void, UpcloudRawError>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import { UpcloudLabel } from "./common";
|
|
5
|
+
import type { UpcloudRawError } from "./common";
|
|
6
|
+
export declare const UpcloudBool: Schema.Literals<readonly ["yes", "no"]>;
|
|
7
|
+
export type UpcloudBool = typeof UpcloudBool.Type;
|
|
8
|
+
export declare const IpNetwork: Schema.Struct<{
|
|
9
|
+
readonly address: Schema.String;
|
|
10
|
+
readonly dhcp: Schema.String;
|
|
11
|
+
readonly dhcp_default_route: Schema.optionalKey<Schema.String>;
|
|
12
|
+
readonly dhcp_dns: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
13
|
+
readonly family: Schema.String;
|
|
14
|
+
readonly gateway: Schema.optionalKey<Schema.String>;
|
|
15
|
+
}>;
|
|
16
|
+
export type IpNetwork = typeof IpNetwork.Type;
|
|
17
|
+
export interface IpNetworkInput {
|
|
18
|
+
readonly address: string;
|
|
19
|
+
readonly dhcp: UpcloudBool;
|
|
20
|
+
readonly dhcp_default_route?: UpcloudBool;
|
|
21
|
+
readonly dhcp_dns?: ReadonlyArray<string>;
|
|
22
|
+
readonly family: "IPv4" | "IPv6";
|
|
23
|
+
readonly gateway?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const Network: Schema.Struct<{
|
|
26
|
+
readonly uuid: Schema.String;
|
|
27
|
+
readonly name: Schema.String;
|
|
28
|
+
readonly zone: Schema.String;
|
|
29
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
30
|
+
readonly router: Schema.optionalKey<Schema.String>;
|
|
31
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
32
|
+
readonly key: Schema.String;
|
|
33
|
+
readonly value: Schema.String;
|
|
34
|
+
}>>>;
|
|
35
|
+
readonly ip_networks: Schema.Struct<{
|
|
36
|
+
readonly ip_network: Schema.$Array<Schema.Struct<{
|
|
37
|
+
readonly address: Schema.String;
|
|
38
|
+
readonly dhcp: Schema.String;
|
|
39
|
+
readonly dhcp_default_route: Schema.optionalKey<Schema.String>;
|
|
40
|
+
readonly dhcp_dns: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
41
|
+
readonly family: Schema.String;
|
|
42
|
+
readonly gateway: Schema.optionalKey<Schema.String>;
|
|
43
|
+
}>>;
|
|
44
|
+
}>;
|
|
45
|
+
}>;
|
|
46
|
+
export type Network = typeof Network.Type;
|
|
47
|
+
export declare const Router: Schema.Struct<{
|
|
48
|
+
readonly uuid: Schema.String;
|
|
49
|
+
readonly name: Schema.String;
|
|
50
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
51
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
52
|
+
readonly key: Schema.String;
|
|
53
|
+
readonly value: Schema.String;
|
|
54
|
+
}>>>;
|
|
55
|
+
readonly attached_networks: Schema.optionalKey<Schema.Struct<{
|
|
56
|
+
readonly network: Schema.$Array<Schema.Unknown>;
|
|
57
|
+
}>>;
|
|
58
|
+
}>;
|
|
59
|
+
export type Router = typeof Router.Type;
|
|
60
|
+
export interface NetworkCreateInput {
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly zone: string;
|
|
63
|
+
readonly ip_networks: {
|
|
64
|
+
readonly ip_network: ReadonlyArray<IpNetworkInput>;
|
|
65
|
+
};
|
|
66
|
+
readonly router?: string;
|
|
67
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
68
|
+
}
|
|
69
|
+
export interface NetworkListFilter {
|
|
70
|
+
readonly zone?: string;
|
|
71
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
72
|
+
}
|
|
73
|
+
export interface RouterListFilter {
|
|
74
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
75
|
+
}
|
|
76
|
+
export interface NetworkClient {
|
|
77
|
+
readonly list: (filter?: NetworkListFilter) => Effect.Effect<ReadonlyArray<Network>, UpcloudRawError>;
|
|
78
|
+
readonly get: (uuid: string) => Effect.Effect<Network, UpcloudRawError>;
|
|
79
|
+
readonly create: (body: NetworkCreateInput) => Effect.Effect<Network, UpcloudRawError>;
|
|
80
|
+
readonly modify: (uuid: string, body: {
|
|
81
|
+
readonly labels: ReadonlyArray<UpcloudLabel>;
|
|
82
|
+
}) => Effect.Effect<Network, UpcloudRawError>;
|
|
83
|
+
readonly delete: (uuid: string) => Effect.Effect<void, UpcloudRawError>;
|
|
84
|
+
}
|
|
85
|
+
export interface RouterClient {
|
|
86
|
+
readonly list: (filter?: RouterListFilter) => Effect.Effect<ReadonlyArray<Router>, UpcloudRawError>;
|
|
87
|
+
readonly get: (uuid: string) => Effect.Effect<Router, UpcloudRawError>;
|
|
88
|
+
readonly create: (body: {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
91
|
+
}) => Effect.Effect<Router, UpcloudRawError>;
|
|
92
|
+
readonly modify: (uuid: string, body: {
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly labels: ReadonlyArray<UpcloudLabel>;
|
|
95
|
+
}) => Effect.Effect<Router, UpcloudRawError>;
|
|
96
|
+
readonly delete: (uuid: string) => Effect.Effect<void, UpcloudRawError>;
|
|
97
|
+
}
|
|
98
|
+
export declare const makeNetworkClient: (httpClient: HttpClient.HttpClient) => NetworkClient;
|
|
99
|
+
export declare const makeRouterClient: (httpClient: HttpClient.HttpClient) => RouterClient;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import { UpcloudLabel } from "./common";
|
|
5
|
+
import type { UpcloudRawError } from "./common";
|
|
6
|
+
export declare const NodeGroupState: Schema.Literals<readonly ["pending", "running", "scaling-up", "scaling-down", "terminating", "failed", "unknown"]>;
|
|
7
|
+
export type NodeGroupState = typeof NodeGroupState.Type;
|
|
8
|
+
export declare const NodeGroupTaint: Schema.Struct<{
|
|
9
|
+
readonly key: Schema.String;
|
|
10
|
+
readonly value: Schema.String;
|
|
11
|
+
readonly effect: Schema.String;
|
|
12
|
+
}>;
|
|
13
|
+
export type NodeGroupTaint = typeof NodeGroupTaint.Type;
|
|
14
|
+
export declare const NodeGroupKubeletArg: Schema.Struct<{
|
|
15
|
+
readonly key: Schema.String;
|
|
16
|
+
readonly value: Schema.String;
|
|
17
|
+
}>;
|
|
18
|
+
export type NodeGroupKubeletArg = typeof NodeGroupKubeletArg.Type;
|
|
19
|
+
export declare const NodeGroupStorage: Schema.Struct<{
|
|
20
|
+
readonly tier: Schema.optionalKey<Schema.String>;
|
|
21
|
+
readonly size: Schema.optionalKey<Schema.Number>;
|
|
22
|
+
}>;
|
|
23
|
+
export type NodeGroupStorage = typeof NodeGroupStorage.Type;
|
|
24
|
+
export declare const NodeGroup: Schema.Struct<{
|
|
25
|
+
readonly name: Schema.String;
|
|
26
|
+
readonly count: Schema.Number;
|
|
27
|
+
readonly plan: Schema.String;
|
|
28
|
+
readonly state: Schema.optionalKey<Schema.String>;
|
|
29
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
30
|
+
readonly key: Schema.String;
|
|
31
|
+
readonly value: Schema.String;
|
|
32
|
+
}>>>;
|
|
33
|
+
readonly taints: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
34
|
+
readonly key: Schema.String;
|
|
35
|
+
readonly value: Schema.String;
|
|
36
|
+
readonly effect: Schema.String;
|
|
37
|
+
}>>>;
|
|
38
|
+
readonly kubelet_args: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
39
|
+
readonly key: Schema.String;
|
|
40
|
+
readonly value: Schema.String;
|
|
41
|
+
}>>>;
|
|
42
|
+
readonly ssh_keys: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
43
|
+
readonly storage: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
44
|
+
readonly tier: Schema.optionalKey<Schema.String>;
|
|
45
|
+
readonly size: Schema.optionalKey<Schema.Number>;
|
|
46
|
+
}>]>>;
|
|
47
|
+
readonly anti_affinity: Schema.optionalKey<Schema.Boolean>;
|
|
48
|
+
readonly utility_network_access: Schema.optionalKey<Schema.Boolean>;
|
|
49
|
+
readonly storage_encryption: Schema.optionalKey<Schema.String>;
|
|
50
|
+
}>;
|
|
51
|
+
export type NodeGroup = typeof NodeGroup.Type;
|
|
52
|
+
export interface NodeGroupCreateInput {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly count: number;
|
|
55
|
+
readonly plan: string;
|
|
56
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
57
|
+
readonly taints?: ReadonlyArray<NodeGroupTaint>;
|
|
58
|
+
readonly kubelet_args?: ReadonlyArray<NodeGroupKubeletArg>;
|
|
59
|
+
readonly ssh_keys?: ReadonlyArray<string>;
|
|
60
|
+
readonly storage?: string;
|
|
61
|
+
readonly anti_affinity?: boolean;
|
|
62
|
+
readonly utility_network_access?: boolean;
|
|
63
|
+
readonly storage_encryption?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface NodeGroupPatchInput {
|
|
66
|
+
readonly count: number;
|
|
67
|
+
}
|
|
68
|
+
export interface NodeGroupsClient {
|
|
69
|
+
readonly list: (clusterUuid: string) => Effect.Effect<ReadonlyArray<NodeGroup>, UpcloudRawError>;
|
|
70
|
+
readonly get: (clusterUuid: string, name: string) => Effect.Effect<NodeGroup, UpcloudRawError>;
|
|
71
|
+
readonly create: (clusterUuid: string, body: NodeGroupCreateInput) => Effect.Effect<NodeGroup, UpcloudRawError>;
|
|
72
|
+
readonly patch: (clusterUuid: string, name: string, body: NodeGroupPatchInput) => Effect.Effect<NodeGroup, UpcloudRawError>;
|
|
73
|
+
readonly delete: (clusterUuid: string, name: string) => Effect.Effect<void, UpcloudRawError>;
|
|
74
|
+
readonly deleteNode: (clusterUuid: string, name: string, nodeName: string) => Effect.Effect<void, UpcloudRawError>;
|
|
75
|
+
}
|
|
76
|
+
export declare const makeNodeGroupsClient: (httpClient: HttpClient.HttpClient) => NodeGroupsClient;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import { UpcloudLabel } from "./common";
|
|
5
|
+
import type { UpcloudRawError } from "./common";
|
|
6
|
+
export declare const ObjectStorageConfiguredStatus: Schema.Literals<readonly ["started", "stopped"]>;
|
|
7
|
+
export type ObjectStorageConfiguredStatus = typeof ObjectStorageConfiguredStatus.Type;
|
|
8
|
+
export declare const ObjectStorageNetwork: Schema.Struct<{
|
|
9
|
+
readonly name: Schema.String;
|
|
10
|
+
readonly type: Schema.Literals<readonly ["public", "private"]>;
|
|
11
|
+
readonly family: Schema.String;
|
|
12
|
+
readonly uuid: Schema.optionalKey<Schema.String>;
|
|
13
|
+
}>;
|
|
14
|
+
export type ObjectStorageNetwork = typeof ObjectStorageNetwork.Type;
|
|
15
|
+
export declare const ObjectStorageEndpoint: Schema.Struct<{
|
|
16
|
+
readonly domain_name: Schema.String;
|
|
17
|
+
readonly type: Schema.String;
|
|
18
|
+
readonly mode: Schema.optionalKey<Schema.String>;
|
|
19
|
+
readonly iam_url: Schema.optionalKey<Schema.String>;
|
|
20
|
+
readonly sts_url: Schema.optionalKey<Schema.String>;
|
|
21
|
+
}>;
|
|
22
|
+
export type ObjectStorageEndpoint = typeof ObjectStorageEndpoint.Type;
|
|
23
|
+
export declare const ObjectStorageService: Schema.Struct<{
|
|
24
|
+
readonly uuid: Schema.String;
|
|
25
|
+
readonly name: Schema.String;
|
|
26
|
+
readonly region: Schema.String;
|
|
27
|
+
readonly configured_status: Schema.Literals<readonly ["started", "stopped"]>;
|
|
28
|
+
readonly operational_state: Schema.String;
|
|
29
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
30
|
+
readonly key: Schema.String;
|
|
31
|
+
readonly value: Schema.String;
|
|
32
|
+
}>>>;
|
|
33
|
+
readonly networks: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
34
|
+
readonly name: Schema.String;
|
|
35
|
+
readonly type: Schema.Literals<readonly ["public", "private"]>;
|
|
36
|
+
readonly family: Schema.String;
|
|
37
|
+
readonly uuid: Schema.optionalKey<Schema.String>;
|
|
38
|
+
}>>>;
|
|
39
|
+
readonly endpoints: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
40
|
+
readonly domain_name: Schema.String;
|
|
41
|
+
readonly type: Schema.String;
|
|
42
|
+
readonly mode: Schema.optionalKey<Schema.String>;
|
|
43
|
+
readonly iam_url: Schema.optionalKey<Schema.String>;
|
|
44
|
+
readonly sts_url: Schema.optionalKey<Schema.String>;
|
|
45
|
+
}>>>;
|
|
46
|
+
}>;
|
|
47
|
+
export type ObjectStorageService = typeof ObjectStorageService.Type;
|
|
48
|
+
export declare const BucketMetrics: Schema.Struct<{
|
|
49
|
+
readonly name: Schema.String;
|
|
50
|
+
readonly total_objects: Schema.Number;
|
|
51
|
+
readonly total_size_bytes: Schema.Number;
|
|
52
|
+
readonly deleted: Schema.optionalKey<Schema.Boolean>;
|
|
53
|
+
}>;
|
|
54
|
+
export type BucketMetrics = typeof BucketMetrics.Type;
|
|
55
|
+
export declare const ObjectStorageUser: Schema.Struct<{
|
|
56
|
+
readonly username: Schema.String;
|
|
57
|
+
}>;
|
|
58
|
+
export type ObjectStorageUser = typeof ObjectStorageUser.Type;
|
|
59
|
+
export declare const AccessKeyStatus: Schema.Literals<readonly ["Active", "Inactive"]>;
|
|
60
|
+
export type AccessKeyStatus = typeof AccessKeyStatus.Type;
|
|
61
|
+
export declare const AccessKey: Schema.Struct<{
|
|
62
|
+
readonly access_key_id: Schema.String;
|
|
63
|
+
readonly status: Schema.Literals<readonly ["Active", "Inactive"]>;
|
|
64
|
+
readonly secret_access_key: Schema.optionalKey<Schema.String>;
|
|
65
|
+
}>;
|
|
66
|
+
export type AccessKey = typeof AccessKey.Type;
|
|
67
|
+
export declare const ObjectStorageRegion: Schema.Struct<{
|
|
68
|
+
readonly name: Schema.String;
|
|
69
|
+
readonly primary_zone: Schema.String;
|
|
70
|
+
readonly zones: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
71
|
+
readonly name: Schema.String;
|
|
72
|
+
}>>>;
|
|
73
|
+
}>;
|
|
74
|
+
export type ObjectStorageRegion = typeof ObjectStorageRegion.Type;
|
|
75
|
+
export declare const ObjectStorageUserPolicy: Schema.Struct<{
|
|
76
|
+
readonly name: Schema.String;
|
|
77
|
+
readonly arn: Schema.optionalKey<Schema.String>;
|
|
78
|
+
}>;
|
|
79
|
+
export type ObjectStorageUserPolicy = typeof ObjectStorageUserPolicy.Type;
|
|
80
|
+
export interface ObjectStorageServiceCreateInput {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly region: string;
|
|
83
|
+
readonly configured_status: ObjectStorageConfiguredStatus;
|
|
84
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
85
|
+
readonly networks?: ReadonlyArray<ObjectStorageNetwork>;
|
|
86
|
+
}
|
|
87
|
+
export interface ObjectStorageServicePatchInput {
|
|
88
|
+
readonly configured_status?: ObjectStorageConfiguredStatus;
|
|
89
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
90
|
+
}
|
|
91
|
+
export interface ObjectStorageClient {
|
|
92
|
+
readonly services: {
|
|
93
|
+
readonly list: () => Effect.Effect<ReadonlyArray<ObjectStorageService>, UpcloudRawError>;
|
|
94
|
+
readonly get: (uuid: string) => Effect.Effect<ObjectStorageService, UpcloudRawError>;
|
|
95
|
+
readonly create: (body: ObjectStorageServiceCreateInput) => Effect.Effect<ObjectStorageService, UpcloudRawError>;
|
|
96
|
+
readonly patch: (uuid: string, body: ObjectStorageServicePatchInput) => Effect.Effect<ObjectStorageService, UpcloudRawError>;
|
|
97
|
+
readonly delete: (uuid: string, force?: boolean) => Effect.Effect<void, UpcloudRawError>;
|
|
98
|
+
};
|
|
99
|
+
readonly buckets: {
|
|
100
|
+
readonly list: (serviceUuid: string) => Effect.Effect<ReadonlyArray<BucketMetrics>, UpcloudRawError>;
|
|
101
|
+
readonly create: (serviceUuid: string, name: string) => Effect.Effect<void, UpcloudRawError>;
|
|
102
|
+
readonly delete: (serviceUuid: string, name: string) => Effect.Effect<void, UpcloudRawError>;
|
|
103
|
+
};
|
|
104
|
+
readonly users: {
|
|
105
|
+
readonly create: (serviceUuid: string, username: string) => Effect.Effect<ObjectStorageUser, UpcloudRawError>;
|
|
106
|
+
readonly get: (serviceUuid: string, username: string) => Effect.Effect<ObjectStorageUser, UpcloudRawError>;
|
|
107
|
+
readonly delete: (serviceUuid: string, username: string) => Effect.Effect<void, UpcloudRawError>;
|
|
108
|
+
readonly policies: {
|
|
109
|
+
readonly list: (serviceUuid: string, username: string) => Effect.Effect<ReadonlyArray<ObjectStorageUserPolicy>, UpcloudRawError>;
|
|
110
|
+
readonly attach: (serviceUuid: string, username: string, name: string) => Effect.Effect<void, UpcloudRawError>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly accessKeys: {
|
|
114
|
+
readonly create: (serviceUuid: string, username: string) => Effect.Effect<AccessKey, UpcloudRawError>;
|
|
115
|
+
readonly list: (serviceUuid: string, username: string) => Effect.Effect<ReadonlyArray<AccessKey>, UpcloudRawError>;
|
|
116
|
+
readonly patch: (serviceUuid: string, username: string, accessKeyId: string, status: AccessKeyStatus) => Effect.Effect<AccessKey, UpcloudRawError>;
|
|
117
|
+
readonly delete: (serviceUuid: string, username: string, accessKeyId: string) => Effect.Effect<void, UpcloudRawError>;
|
|
118
|
+
};
|
|
119
|
+
readonly regions: () => Effect.Effect<ReadonlyArray<ObjectStorageRegion>, UpcloudRawError>;
|
|
120
|
+
}
|
|
121
|
+
export declare const makeObjectStorageClient: (httpClient: HttpClient.HttpClient) => ObjectStorageClient;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import { UpcloudLabel } from "./common";
|
|
5
|
+
import type { UpcloudRawError } from "./common";
|
|
6
|
+
export declare const StorageTier: Schema.Literals<readonly ["maxiops", "standard", "hdd"]>;
|
|
7
|
+
export type StorageTier = typeof StorageTier.Type;
|
|
8
|
+
export declare const StorageState: Schema.Literals<readonly ["online", "maintenance", "cloning", "backuping", "syncing", "error"]>;
|
|
9
|
+
export type StorageState = typeof StorageState.Type;
|
|
10
|
+
export declare const Storage: Schema.Struct<{
|
|
11
|
+
readonly uuid: Schema.String;
|
|
12
|
+
readonly size: Schema.Number;
|
|
13
|
+
readonly tier: Schema.optionalKey<Schema.Literals<readonly ["maxiops", "standard", "hdd"]>>;
|
|
14
|
+
readonly zone: Schema.optionalKey<Schema.String>;
|
|
15
|
+
readonly title: Schema.String;
|
|
16
|
+
readonly encrypted: Schema.optionalKey<Schema.decodeTo<Schema.Boolean, Schema.Union<readonly [Schema.Boolean, Schema.Literals<readonly ["yes", "no"]>]>, never, never>>;
|
|
17
|
+
readonly state: Schema.String;
|
|
18
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
19
|
+
readonly key: Schema.String;
|
|
20
|
+
readonly value: Schema.String;
|
|
21
|
+
}>>>;
|
|
22
|
+
}>;
|
|
23
|
+
export type Storage = typeof Storage.Type;
|
|
24
|
+
export interface StorageCreateInput {
|
|
25
|
+
readonly size: number;
|
|
26
|
+
readonly zone: string;
|
|
27
|
+
readonly title: string;
|
|
28
|
+
readonly tier?: StorageTier;
|
|
29
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
30
|
+
readonly encrypted?: "yes" | "no";
|
|
31
|
+
}
|
|
32
|
+
export interface StorageListFilter {
|
|
33
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
34
|
+
}
|
|
35
|
+
export interface StoragePatchInput {
|
|
36
|
+
readonly title?: string;
|
|
37
|
+
readonly size?: number;
|
|
38
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
39
|
+
}
|
|
40
|
+
export interface StorageClient {
|
|
41
|
+
readonly list: (filter?: StorageListFilter) => Effect.Effect<ReadonlyArray<Storage>, UpcloudRawError>;
|
|
42
|
+
readonly get: (uuid: string) => Effect.Effect<Storage, UpcloudRawError>;
|
|
43
|
+
readonly create: (body: StorageCreateInput) => Effect.Effect<Storage, UpcloudRawError>;
|
|
44
|
+
readonly modify: (uuid: string, body: StoragePatchInput) => Effect.Effect<Storage, UpcloudRawError>;
|
|
45
|
+
readonly delete: (uuid: string) => Effect.Effect<void, UpcloudRawError>;
|
|
46
|
+
}
|
|
47
|
+
export declare const makeStorageClient: (httpClient: HttpClient.HttpClient) => StorageClient;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import { UpcloudLabel } from "./common";
|
|
5
|
+
import type { UpcloudRawError } from "./common";
|
|
6
|
+
export declare const UksState: Schema.Literals<readonly ["pending", "running", "scaling-up", "scaling-down", "terminating", "terminated", "failed", "unknown"]>;
|
|
7
|
+
export type UksState = typeof UksState.Type;
|
|
8
|
+
export declare const UksCluster: Schema.Struct<{
|
|
9
|
+
readonly uuid: Schema.String;
|
|
10
|
+
readonly name: Schema.String;
|
|
11
|
+
readonly zone: Schema.String;
|
|
12
|
+
readonly network: Schema.String;
|
|
13
|
+
readonly network_cidr: Schema.String;
|
|
14
|
+
readonly version: Schema.String;
|
|
15
|
+
readonly plan: Schema.String;
|
|
16
|
+
readonly state: Schema.String;
|
|
17
|
+
readonly control_plane_ip_filter: Schema.optionalKey<Schema.NullOr<Schema.$Array<Schema.String>>>;
|
|
18
|
+
readonly storage_encryption: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
19
|
+
readonly private_node_groups: Schema.optionalKey<Schema.Boolean>;
|
|
20
|
+
readonly labels: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
21
|
+
readonly key: Schema.String;
|
|
22
|
+
readonly value: Schema.String;
|
|
23
|
+
}>>>;
|
|
24
|
+
}>;
|
|
25
|
+
export type UksCluster = typeof UksCluster.Type;
|
|
26
|
+
export declare const UksPlan: Schema.Struct<{
|
|
27
|
+
readonly name: Schema.String;
|
|
28
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
29
|
+
}>;
|
|
30
|
+
export type UksPlan = typeof UksPlan.Type;
|
|
31
|
+
export interface UksClusterCreateInput {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly zone: string;
|
|
34
|
+
readonly version: string;
|
|
35
|
+
readonly network: string;
|
|
36
|
+
readonly network_cidr: string;
|
|
37
|
+
readonly plan?: string;
|
|
38
|
+
readonly node_groups?: ReadonlyArray<unknown>;
|
|
39
|
+
readonly private_node_groups?: boolean;
|
|
40
|
+
readonly control_plane_ip_filter?: ReadonlyArray<string>;
|
|
41
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
42
|
+
readonly storage_encryption?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface UksUpgradeRequest {
|
|
45
|
+
readonly version: string;
|
|
46
|
+
readonly strategy?: {
|
|
47
|
+
readonly type: "manual" | "rolling-update";
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface UksClusterPatchInput {
|
|
51
|
+
readonly control_plane_ip_filter?: ReadonlyArray<string>;
|
|
52
|
+
readonly labels?: ReadonlyArray<UpcloudLabel>;
|
|
53
|
+
}
|
|
54
|
+
export interface UksClient {
|
|
55
|
+
readonly list: () => Effect.Effect<ReadonlyArray<UksCluster>, UpcloudRawError>;
|
|
56
|
+
readonly get: (uuid: string) => Effect.Effect<UksCluster, UpcloudRawError>;
|
|
57
|
+
readonly create: (body: UksClusterCreateInput) => Effect.Effect<UksCluster, UpcloudRawError>;
|
|
58
|
+
readonly patch: (uuid: string, body: UksClusterPatchInput) => Effect.Effect<UksCluster, UpcloudRawError>;
|
|
59
|
+
readonly delete: (uuid: string) => Effect.Effect<void, UpcloudRawError>;
|
|
60
|
+
readonly availableUpgrades: (uuid: string) => Effect.Effect<ReadonlyArray<string>, UpcloudRawError>;
|
|
61
|
+
readonly upgrade: (uuid: string, body: UksUpgradeRequest) => Effect.Effect<void, UpcloudRawError>;
|
|
62
|
+
readonly kubeconfig: (uuid: string) => Effect.Effect<string, UpcloudRawError>;
|
|
63
|
+
readonly plans: () => Effect.Effect<ReadonlyArray<UksPlan>, UpcloudRawError>;
|
|
64
|
+
}
|
|
65
|
+
export declare const makeUksClient: (httpClient: HttpClient.HttpClient) => UksClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
import type { UpcloudRawError } from "./common";
|
|
5
|
+
export declare const Zone: Schema.Struct<{
|
|
6
|
+
readonly id: Schema.String;
|
|
7
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
8
|
+
readonly public: Schema.optionalKey<Schema.String>;
|
|
9
|
+
}>;
|
|
10
|
+
export type Zone = typeof Zone.Type;
|
|
11
|
+
export interface ZoneClient {
|
|
12
|
+
readonly list: () => Effect.Effect<ReadonlyArray<Zone>, UpcloudRawError>;
|
|
13
|
+
}
|
|
14
|
+
export declare const makeZoneClient: (httpClient: HttpClient.HttpClient) => ZoneClient;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { AuthenticationFailed, HttpTransportError, ProviderApiError, QuotaExceeded, RateLimited, ResourceConflict, ResourceNotFound, ResponseDecodeError } from "@kumulo/core";
|
|
3
|
+
import type { HttpErrorContext } from "@kumulo/core";
|
|
4
|
+
import type { UpcloudRawError } from "./client/common";
|
|
5
|
+
export type UpcloudCause = UpcloudRawError;
|
|
6
|
+
export type UpcloudError = AuthenticationFailed | QuotaExceeded | RateLimited | ProviderApiError | ResourceNotFound | ResourceConflict | ResponseDecodeError | HttpTransportError;
|
|
7
|
+
export interface ErrorContext {
|
|
8
|
+
readonly kind: string;
|
|
9
|
+
readonly ref: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const isUpcloudQuota: ({ status, body }: HttpErrorContext) => boolean;
|
|
12
|
+
export declare const mapUpcloudError: <A, R>({ self, ctx }: {
|
|
13
|
+
readonly self: Effect.Effect<A, UpcloudCause, R>;
|
|
14
|
+
readonly ctx: ErrorContext;
|
|
15
|
+
}) => Effect.Effect<A, UpcloudError, R>;
|
|
16
|
+
export declare const ignoreMissing: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<void, E, R>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @kumulo/upcloud — package barrel. */
|
|
2
|
+
export declare const packageName = "@kumulo/upcloud";
|
|
3
|
+
export { UpcloudHttpLive } from "./transport/http-client";
|
|
4
|
+
export { ignoreMissing, mapUpcloudError } from "./errors";
|
|
5
|
+
export type { UpcloudError } from "./errors";
|
|
6
|
+
export { UpcloudLabel } from "./client/common";
|
|
7
|
+
export { makeUksClient, UksCluster } from "./client/uks";
|
|
8
|
+
export type { UksClient } from "./client/uks";
|
|
9
|
+
export { makeNodeGroupsClient, NodeGroup } from "./client/node-groups";
|
|
10
|
+
export type { NodeGroupsClient } from "./client/node-groups";
|
|
11
|
+
export { makeNetworkClient, makeRouterClient } from "./client/network";
|
|
12
|
+
export type { NetworkClient, RouterClient } from "./client/network";
|
|
13
|
+
export { makeZoneClient } from "./client/zone";
|
|
14
|
+
export type { ZoneClient } from "./client/zone";
|
|
15
|
+
export { makeStorageClient, Storage, StorageTier } from "./client/storage";
|
|
16
|
+
export type { StorageClient } from "./client/storage";
|
|
17
|
+
export { AccessKey, makeObjectStorageClient, ObjectStorageService } from "./client/object-storage";
|
|
18
|
+
export type { ObjectStorageClient } from "./client/object-storage";
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { Effect, Layer, Option, Predicate, Schema } from "effect";
|
|
2
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
3
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
4
|
+
import { AuthenticationFailed, HttpTransportError, ProviderApiError, QuotaExceeded, RateLimited, ResourceConflict, ResourceNotFound, ResponseDecodeError, ignoreNotFound, makeProviderHttpClient, mapHttpError, paginateByOffset } from "@kumulo/core";
|
|
5
|
+
import * as Schema$1 from "effect/Schema";
|
|
6
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
7
|
+
import * as HttpClientError from "effect/http/HttpClientError";
|
|
8
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
9
|
+
const makeUpcloudHttpClient = (options) => Effect.map(makeProviderHttpClient({
|
|
10
|
+
base: options.base,
|
|
11
|
+
authorize: (request) => Effect.succeed(HttpClientRequest.bearerToken(request, options.token)),
|
|
12
|
+
timeout: options.requestTimeout
|
|
13
|
+
}), HttpClient.mapRequest(HttpClientRequest.prependUrl(options.baseUrl ?? "https://api.upcloud.com")));
|
|
14
|
+
const UpcloudHttpLive = ({ token, baseUrl }) => Layer.effect(HttpClient.HttpClient, Effect.flatMap(HttpClient.HttpClient, (base) => makeUpcloudHttpClient({
|
|
15
|
+
base,
|
|
16
|
+
token,
|
|
17
|
+
baseUrl
|
|
18
|
+
})));
|
|
19
|
+
// src/errors.ts
|
|
20
|
+
const _isUpcloudError = (error) => error instanceof AuthenticationFailed || error instanceof QuotaExceeded || error instanceof RateLimited || error instanceof ProviderApiError || error instanceof ResourceNotFound || error instanceof ResourceConflict || error instanceof ResponseDecodeError || error instanceof HttpTransportError;
|
|
21
|
+
const _ClassicBody = Schema.fromJsonString(Schema.Struct({ error: Schema.Struct({ error_code: Schema.String }) }));
|
|
22
|
+
const _errorCode = (body) => Option.getOrUndefined(Option.map(Schema.decodeUnknownOption(_ClassicBody)(body), (b) => b.error.error_code));
|
|
23
|
+
const isUpcloudQuota = ({ status, body }) => status === 402 || status === 403 && _errorCode(body)?.endsWith("_LIMIT_REACHED") === true;
|
|
24
|
+
const mapUpcloudError = ({ self, ctx }) => Effect.mapError(self, (cause) => {
|
|
25
|
+
if (Predicate.isTagged(cause, "PaginationLimitExceeded") || Predicate.isTagged(cause, "PaginationStalled")) return new ProviderApiError({
|
|
26
|
+
operation: `${ctx.kind} ${ctx.ref}`,
|
|
27
|
+
status: 0,
|
|
28
|
+
body: `pagination failed: ${cause._tag}`
|
|
29
|
+
});
|
|
30
|
+
const mapped = mapHttpError({
|
|
31
|
+
cause,
|
|
32
|
+
kind: ctx.kind,
|
|
33
|
+
ref: ctx.ref,
|
|
34
|
+
isQuota: isUpcloudQuota
|
|
35
|
+
});
|
|
36
|
+
return _isUpcloudError(mapped) ? mapped : new ProviderApiError({
|
|
37
|
+
operation: `${ctx.kind} ${ctx.ref}`,
|
|
38
|
+
status: 0,
|
|
39
|
+
body: mapped._tag
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
const ignoreMissing = ignoreNotFound;
|
|
43
|
+
// src/client/common.ts
|
|
44
|
+
const UpcloudLabel = Schema$1.Struct({
|
|
45
|
+
key: Schema$1.String,
|
|
46
|
+
value: Schema$1.String
|
|
47
|
+
});
|
|
48
|
+
const UpcloudBoolean = Schema$1.Union([Schema$1.Boolean, Schema$1.Literals(["yes", "no"])]).pipe(Schema$1.decodeTo(Schema$1.Boolean, {
|
|
49
|
+
decode: SchemaGetter.transform((value) => value === true || value === "yes"),
|
|
50
|
+
encode: SchemaGetter.transform((value) => value)
|
|
51
|
+
}));
|
|
52
|
+
const isOk = (response) => response.status >= 200 && response.status < 300;
|
|
53
|
+
const _unexpectedStatus = (response) => Effect.flatMap(Effect.orElseSucceed(response.text, () => "unexpected UpCloud API response status"), (description) => Effect.fail(new HttpClientError.HttpClientError({ reason: new HttpClientError.StatusCodeError({
|
|
54
|
+
request: response.request,
|
|
55
|
+
response,
|
|
56
|
+
description
|
|
57
|
+
}) })));
|
|
58
|
+
const decodeOn2xx = (schema) => (response) => isOk(response) ? HttpClientResponse.schemaBodyJson(schema)(response) : _unexpectedStatus(response);
|
|
59
|
+
const decodeVoid = (response) => isOk(response) ? Effect.void : _unexpectedStatus(response);
|
|
60
|
+
Schema$1.Literals([
|
|
61
|
+
"pending",
|
|
62
|
+
"running",
|
|
63
|
+
"scaling-up",
|
|
64
|
+
"scaling-down",
|
|
65
|
+
"terminating",
|
|
66
|
+
"terminated",
|
|
67
|
+
"failed",
|
|
68
|
+
"unknown"
|
|
69
|
+
]);
|
|
70
|
+
const UksCluster = Schema$1.Struct({
|
|
71
|
+
uuid: Schema$1.String,
|
|
72
|
+
name: Schema$1.String,
|
|
73
|
+
zone: Schema$1.String,
|
|
74
|
+
network: Schema$1.String,
|
|
75
|
+
network_cidr: Schema$1.String,
|
|
76
|
+
version: Schema$1.String,
|
|
77
|
+
plan: Schema$1.String,
|
|
78
|
+
state: Schema$1.String,
|
|
79
|
+
control_plane_ip_filter: Schema$1.optionalKey(Schema$1.NullOr(Schema$1.Array(Schema$1.String))),
|
|
80
|
+
storage_encryption: Schema$1.optionalKey(Schema$1.NullOr(Schema$1.String)),
|
|
81
|
+
private_node_groups: Schema$1.optionalKey(Schema$1.Boolean),
|
|
82
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel))
|
|
83
|
+
});
|
|
84
|
+
const UksPlan = Schema$1.Struct({
|
|
85
|
+
name: Schema$1.String,
|
|
86
|
+
description: Schema$1.optionalKey(Schema$1.String)
|
|
87
|
+
});
|
|
88
|
+
const _ClustersResponse = Schema$1.Array(UksCluster);
|
|
89
|
+
const _PlansResponse = Schema$1.Array(UksPlan);
|
|
90
|
+
const _UpgradesResponse = Schema$1.Struct({ versions: Schema$1.Array(Schema$1.String) });
|
|
91
|
+
const _KubeconfigResponse = Schema$1.Struct({ kubeconfig: Schema$1.String });
|
|
92
|
+
const _decodeCluster = decodeOn2xx(UksCluster);
|
|
93
|
+
const _decodeClusters = decodeOn2xx(_ClustersResponse);
|
|
94
|
+
const _decodePlans = decodeOn2xx(_PlansResponse);
|
|
95
|
+
const _decodeUpgrades = decodeOn2xx(_UpgradesResponse);
|
|
96
|
+
const _decodeKubeconfig = decodeOn2xx(_KubeconfigResponse);
|
|
97
|
+
const _base$3 = "/1.3/kubernetes";
|
|
98
|
+
const makeUksClient = (httpClient) => ({
|
|
99
|
+
list: () => httpClient.execute(HttpClientRequest.get(_base$3)).pipe(Effect.flatMap(_decodeClusters)),
|
|
100
|
+
get: (uuid) => httpClient.execute(HttpClientRequest.get(`${_base$3}/${uuid}`)).pipe(Effect.flatMap(_decodeCluster)),
|
|
101
|
+
create: (body) => httpClient.execute(HttpClientRequest.post(_base$3).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeCluster)),
|
|
102
|
+
patch: (uuid, body) => httpClient.execute(HttpClientRequest.patch(`${_base$3}/${uuid}`).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeCluster)),
|
|
103
|
+
delete: (uuid) => httpClient.execute(HttpClientRequest.delete(`${_base$3}/${uuid}`)).pipe(Effect.flatMap(decodeVoid)),
|
|
104
|
+
availableUpgrades: (uuid) => httpClient.execute(HttpClientRequest.get(`${_base$3}/${uuid}/available-upgrades`)).pipe(Effect.flatMap(_decodeUpgrades), Effect.map((r) => r.versions)),
|
|
105
|
+
upgrade: (uuid, body) => httpClient.execute(HttpClientRequest.post(`${_base$3}/${uuid}/upgrade`).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(decodeVoid)),
|
|
106
|
+
kubeconfig: (uuid) => httpClient.execute(HttpClientRequest.get(`${_base$3}/${uuid}/kubeconfig`)).pipe(Effect.flatMap(_decodeKubeconfig), Effect.map((r) => r.kubeconfig)),
|
|
107
|
+
plans: () => httpClient.execute(HttpClientRequest.get(`${_base$3}/plans`)).pipe(Effect.flatMap(_decodePlans))
|
|
108
|
+
});
|
|
109
|
+
Schema$1.Literals([
|
|
110
|
+
"pending",
|
|
111
|
+
"running",
|
|
112
|
+
"scaling-up",
|
|
113
|
+
"scaling-down",
|
|
114
|
+
"terminating",
|
|
115
|
+
"failed",
|
|
116
|
+
"unknown"
|
|
117
|
+
]);
|
|
118
|
+
const NodeGroupTaint = Schema$1.Struct({
|
|
119
|
+
key: Schema$1.String,
|
|
120
|
+
value: Schema$1.String,
|
|
121
|
+
effect: Schema$1.String
|
|
122
|
+
});
|
|
123
|
+
const NodeGroupKubeletArg = Schema$1.Struct({
|
|
124
|
+
key: Schema$1.String,
|
|
125
|
+
value: Schema$1.String
|
|
126
|
+
});
|
|
127
|
+
const NodeGroupStorage = Schema$1.Struct({
|
|
128
|
+
tier: Schema$1.optionalKey(Schema$1.String),
|
|
129
|
+
size: Schema$1.optionalKey(Schema$1.Number)
|
|
130
|
+
});
|
|
131
|
+
const NodeGroup = Schema$1.Struct({
|
|
132
|
+
name: Schema$1.String,
|
|
133
|
+
count: Schema$1.Number,
|
|
134
|
+
plan: Schema$1.String,
|
|
135
|
+
state: Schema$1.optionalKey(Schema$1.String),
|
|
136
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel)),
|
|
137
|
+
taints: Schema$1.optionalKey(Schema$1.Array(NodeGroupTaint)),
|
|
138
|
+
kubelet_args: Schema$1.optionalKey(Schema$1.Array(NodeGroupKubeletArg)),
|
|
139
|
+
ssh_keys: Schema$1.optionalKey(Schema$1.Array(Schema$1.String)),
|
|
140
|
+
storage: Schema$1.optionalKey(Schema$1.Union([Schema$1.String, NodeGroupStorage])),
|
|
141
|
+
anti_affinity: Schema$1.optionalKey(Schema$1.Boolean),
|
|
142
|
+
utility_network_access: Schema$1.optionalKey(Schema$1.Boolean),
|
|
143
|
+
storage_encryption: Schema$1.optionalKey(Schema$1.String)
|
|
144
|
+
});
|
|
145
|
+
const _NodeGroupsResponse = Schema$1.Array(NodeGroup);
|
|
146
|
+
const _decodeNodeGroup = decodeOn2xx(NodeGroup);
|
|
147
|
+
const _decodeNodeGroups = decodeOn2xx(_NodeGroupsResponse);
|
|
148
|
+
const _base$2 = (clusterUuid) => `/1.3/kubernetes/${clusterUuid}/node-groups`;
|
|
149
|
+
const _one = (clusterUuid, name) => `${_base$2(clusterUuid)}/${name}`;
|
|
150
|
+
const makeNodeGroupsClient = (httpClient) => ({
|
|
151
|
+
list: (clusterUuid) => httpClient.execute(HttpClientRequest.get(_base$2(clusterUuid))).pipe(Effect.flatMap(_decodeNodeGroups)),
|
|
152
|
+
get: (clusterUuid, name) => httpClient.execute(HttpClientRequest.get(_one(clusterUuid, name))).pipe(Effect.flatMap(_decodeNodeGroup)),
|
|
153
|
+
create: (clusterUuid, body) => httpClient.execute(HttpClientRequest.post(_base$2(clusterUuid)).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeNodeGroup)),
|
|
154
|
+
patch: (clusterUuid, name, body) => httpClient.execute(HttpClientRequest.patch(_one(clusterUuid, name)).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeNodeGroup)),
|
|
155
|
+
delete: (clusterUuid, name) => httpClient.execute(HttpClientRequest.delete(_one(clusterUuid, name))).pipe(Effect.flatMap(decodeVoid)),
|
|
156
|
+
deleteNode: (clusterUuid, name, nodeName) => httpClient.execute(HttpClientRequest.delete(`${_one(clusterUuid, name)}/${nodeName}`)).pipe(Effect.flatMap(decodeVoid))
|
|
157
|
+
});
|
|
158
|
+
Schema$1.Literals(["yes", "no"]);
|
|
159
|
+
const IpNetwork = Schema$1.Struct({
|
|
160
|
+
address: Schema$1.String,
|
|
161
|
+
dhcp: Schema$1.String,
|
|
162
|
+
dhcp_default_route: Schema$1.optionalKey(Schema$1.String),
|
|
163
|
+
dhcp_dns: Schema$1.optionalKey(Schema$1.Array(Schema$1.String)),
|
|
164
|
+
family: Schema$1.String,
|
|
165
|
+
gateway: Schema$1.optionalKey(Schema$1.String)
|
|
166
|
+
});
|
|
167
|
+
const Network = Schema$1.Struct({
|
|
168
|
+
uuid: Schema$1.String,
|
|
169
|
+
name: Schema$1.String,
|
|
170
|
+
zone: Schema$1.String,
|
|
171
|
+
type: Schema$1.optionalKey(Schema$1.String),
|
|
172
|
+
router: Schema$1.optionalKey(Schema$1.String),
|
|
173
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel)),
|
|
174
|
+
ip_networks: Schema$1.Struct({ ip_network: Schema$1.Array(IpNetwork) })
|
|
175
|
+
});
|
|
176
|
+
const Router = Schema$1.Struct({
|
|
177
|
+
uuid: Schema$1.String,
|
|
178
|
+
name: Schema$1.String,
|
|
179
|
+
type: Schema$1.optionalKey(Schema$1.String),
|
|
180
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel)),
|
|
181
|
+
attached_networks: Schema$1.optionalKey(Schema$1.Struct({ network: Schema$1.Array(Schema$1.Unknown) }))
|
|
182
|
+
});
|
|
183
|
+
const _NetworkResponse = Schema$1.Struct({ network: Network });
|
|
184
|
+
const _NetworksResponse = Schema$1.Struct({ networks: Schema$1.Struct({ network: Schema$1.Array(Network) }) });
|
|
185
|
+
const _RouterResponse = Schema$1.Struct({ router: Router });
|
|
186
|
+
const _RoutersResponse = Schema$1.Struct({ routers: Schema$1.Struct({ router: Schema$1.Array(Router) }) });
|
|
187
|
+
const _decodeNetwork = decodeOn2xx(_NetworkResponse);
|
|
188
|
+
const _decodeNetworks = decodeOn2xx(_NetworksResponse);
|
|
189
|
+
const _decodeRouter = decodeOn2xx(_RouterResponse);
|
|
190
|
+
const _decodeRouters = decodeOn2xx(_RoutersResponse);
|
|
191
|
+
const _listPath = ({ path, zone, labels }) => {
|
|
192
|
+
const params = new URLSearchParams();
|
|
193
|
+
if (zone !== void 0) params.append("zone", zone);
|
|
194
|
+
for (const label of labels ?? []) params.append("label", `${label.key}=${label.value}`);
|
|
195
|
+
const query = params.toString();
|
|
196
|
+
return query === "" ? path : `${path}?${query}`;
|
|
197
|
+
};
|
|
198
|
+
const makeNetworkClient = (httpClient) => ({
|
|
199
|
+
list: (filter) => httpClient.execute(HttpClientRequest.get(_listPath({
|
|
200
|
+
path: "/1.3/network",
|
|
201
|
+
zone: filter?.zone,
|
|
202
|
+
labels: filter?.labels
|
|
203
|
+
}))).pipe(Effect.flatMap(_decodeNetworks), Effect.map((r) => r.networks.network)),
|
|
204
|
+
get: (uuid) => httpClient.execute(HttpClientRequest.get(`/1.3/network/${uuid}`)).pipe(Effect.flatMap(_decodeNetwork), Effect.map((r) => r.network)),
|
|
205
|
+
create: (body) => httpClient.execute(HttpClientRequest.post("/1.3/network").pipe(HttpClientRequest.bodyJsonUnsafe({ network: body }))).pipe(Effect.flatMap(_decodeNetwork), Effect.map((r) => r.network)),
|
|
206
|
+
modify: (uuid, body) => httpClient.execute(HttpClientRequest.put(`/1.3/network/${uuid}`).pipe(HttpClientRequest.bodyJsonUnsafe({ network: body }))).pipe(Effect.flatMap(_decodeNetwork), Effect.map((r) => r.network)),
|
|
207
|
+
delete: (uuid) => httpClient.execute(HttpClientRequest.delete(`/1.3/network/${uuid}`)).pipe(Effect.flatMap(decodeVoid))
|
|
208
|
+
});
|
|
209
|
+
const makeRouterClient = (httpClient) => ({
|
|
210
|
+
list: (filter) => httpClient.execute(HttpClientRequest.get(_listPath({
|
|
211
|
+
path: "/1.3/router",
|
|
212
|
+
labels: filter?.labels
|
|
213
|
+
}))).pipe(Effect.flatMap(_decodeRouters), Effect.map((r) => r.routers.router)),
|
|
214
|
+
get: (uuid) => httpClient.execute(HttpClientRequest.get(`/1.3/router/${uuid}`)).pipe(Effect.flatMap(_decodeRouter), Effect.map((r) => r.router)),
|
|
215
|
+
create: (body) => httpClient.execute(HttpClientRequest.post("/1.3/router").pipe(HttpClientRequest.bodyJsonUnsafe({ router: body }))).pipe(Effect.flatMap(_decodeRouter), Effect.map((r) => r.router)),
|
|
216
|
+
modify: (uuid, body) => httpClient.execute(HttpClientRequest.patch(`/1.3/router/${uuid}`).pipe(HttpClientRequest.bodyJsonUnsafe({ router: body }))).pipe(Effect.flatMap(_decodeRouter), Effect.map((r) => r.router)),
|
|
217
|
+
delete: (uuid) => httpClient.execute(HttpClientRequest.delete(`/1.3/router/${uuid}`)).pipe(Effect.flatMap(decodeVoid))
|
|
218
|
+
});
|
|
219
|
+
// src/client/zone.ts
|
|
220
|
+
const Zone = Schema$1.Struct({
|
|
221
|
+
id: Schema$1.String,
|
|
222
|
+
description: Schema$1.optionalKey(Schema$1.String),
|
|
223
|
+
public: Schema$1.optionalKey(Schema$1.String)
|
|
224
|
+
});
|
|
225
|
+
const _decodeZones = decodeOn2xx(Schema$1.Struct({ zones: Schema$1.Struct({ zone: Schema$1.Array(Zone) }) }));
|
|
226
|
+
const makeZoneClient = (httpClient) => ({ list: () => httpClient.execute(HttpClientRequest.get("/1.3/zone")).pipe(Effect.flatMap(_decodeZones), Effect.map((response) => response.zones.zone)) });
|
|
227
|
+
// src/client/storage.ts
|
|
228
|
+
const StorageTier = Schema$1.Literals([
|
|
229
|
+
"maxiops",
|
|
230
|
+
"standard",
|
|
231
|
+
"hdd"
|
|
232
|
+
]);
|
|
233
|
+
Schema$1.Literals([
|
|
234
|
+
"online",
|
|
235
|
+
"maintenance",
|
|
236
|
+
"cloning",
|
|
237
|
+
"backuping",
|
|
238
|
+
"syncing",
|
|
239
|
+
"error"
|
|
240
|
+
]);
|
|
241
|
+
const Storage = Schema$1.Struct({
|
|
242
|
+
uuid: Schema$1.String,
|
|
243
|
+
size: Schema$1.Number,
|
|
244
|
+
tier: Schema$1.optionalKey(StorageTier),
|
|
245
|
+
zone: Schema$1.optionalKey(Schema$1.String),
|
|
246
|
+
title: Schema$1.String,
|
|
247
|
+
encrypted: Schema$1.optionalKey(UpcloudBoolean),
|
|
248
|
+
state: Schema$1.String,
|
|
249
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel))
|
|
250
|
+
});
|
|
251
|
+
const _StorageResponse = Schema$1.Struct({ storage: Storage });
|
|
252
|
+
const _StoragesResponse = Schema$1.Struct({ storages: Schema$1.Struct({ storage: Schema$1.Array(Storage) }) });
|
|
253
|
+
const _decodeStorage = decodeOn2xx(_StorageResponse);
|
|
254
|
+
const _decodeStorages = decodeOn2xx(_StoragesResponse);
|
|
255
|
+
const _base$1 = "/1.3/storage";
|
|
256
|
+
const _listUrl = (filter) => {
|
|
257
|
+
const params = new URLSearchParams();
|
|
258
|
+
for (const label of filter?.labels ?? []) params.append("label", `${label.key}=${label.value}`);
|
|
259
|
+
const query = params.toString();
|
|
260
|
+
return query === "" ? `${_base$1}/normal` : `${_base$1}/normal?${query}`;
|
|
261
|
+
};
|
|
262
|
+
const makeStorageClient = (httpClient) => ({
|
|
263
|
+
list: (filter) => httpClient.execute(HttpClientRequest.get(_listUrl(filter))).pipe(Effect.flatMap(_decodeStorages), Effect.map((r) => r.storages.storage)),
|
|
264
|
+
get: (uuid) => httpClient.execute(HttpClientRequest.get(`${_base$1}/${uuid}`)).pipe(Effect.flatMap(_decodeStorage), Effect.map((r) => r.storage)),
|
|
265
|
+
create: (body) => httpClient.execute(HttpClientRequest.post(_base$1).pipe(HttpClientRequest.bodyJsonUnsafe({ storage: {
|
|
266
|
+
...body,
|
|
267
|
+
size: String(body.size)
|
|
268
|
+
} }))).pipe(Effect.flatMap(_decodeStorage), Effect.map((r) => r.storage)),
|
|
269
|
+
modify: (uuid, body) => httpClient.execute(HttpClientRequest.put(`${_base$1}/${uuid}`).pipe(HttpClientRequest.bodyJsonUnsafe({ storage: body }))).pipe(Effect.flatMap(_decodeStorage), Effect.map((r) => r.storage)),
|
|
270
|
+
delete: (uuid) => httpClient.execute(HttpClientRequest.delete(`${_base$1}/${uuid}?backups=delete`)).pipe(Effect.flatMap(decodeVoid))
|
|
271
|
+
});
|
|
272
|
+
// src/client/object-storage.ts
|
|
273
|
+
const ObjectStorageConfiguredStatus = Schema$1.Literals(["started", "stopped"]);
|
|
274
|
+
const ObjectStorageNetwork = Schema$1.Struct({
|
|
275
|
+
name: Schema$1.String,
|
|
276
|
+
type: Schema$1.Literals(["public", "private"]),
|
|
277
|
+
family: Schema$1.String,
|
|
278
|
+
uuid: Schema$1.optionalKey(Schema$1.String)
|
|
279
|
+
});
|
|
280
|
+
const ObjectStorageEndpoint = Schema$1.Struct({
|
|
281
|
+
domain_name: Schema$1.String,
|
|
282
|
+
type: Schema$1.String,
|
|
283
|
+
mode: Schema$1.optionalKey(Schema$1.String),
|
|
284
|
+
iam_url: Schema$1.optionalKey(Schema$1.String),
|
|
285
|
+
sts_url: Schema$1.optionalKey(Schema$1.String)
|
|
286
|
+
});
|
|
287
|
+
const ObjectStorageService = Schema$1.Struct({
|
|
288
|
+
uuid: Schema$1.String,
|
|
289
|
+
name: Schema$1.String,
|
|
290
|
+
region: Schema$1.String,
|
|
291
|
+
configured_status: ObjectStorageConfiguredStatus,
|
|
292
|
+
operational_state: Schema$1.String,
|
|
293
|
+
labels: Schema$1.optionalKey(Schema$1.Array(UpcloudLabel)),
|
|
294
|
+
networks: Schema$1.optionalKey(Schema$1.Array(ObjectStorageNetwork)),
|
|
295
|
+
endpoints: Schema$1.optionalKey(Schema$1.Array(ObjectStorageEndpoint))
|
|
296
|
+
});
|
|
297
|
+
const BucketMetrics = Schema$1.Struct({
|
|
298
|
+
name: Schema$1.String,
|
|
299
|
+
total_objects: Schema$1.Number,
|
|
300
|
+
total_size_bytes: Schema$1.Number,
|
|
301
|
+
deleted: Schema$1.optionalKey(Schema$1.Boolean)
|
|
302
|
+
});
|
|
303
|
+
const ObjectStorageUser = Schema$1.Struct({ username: Schema$1.String });
|
|
304
|
+
const AccessKeyStatus = Schema$1.Literals(["Active", "Inactive"]);
|
|
305
|
+
const AccessKey = Schema$1.Struct({
|
|
306
|
+
access_key_id: Schema$1.String,
|
|
307
|
+
status: AccessKeyStatus,
|
|
308
|
+
secret_access_key: Schema$1.optionalKey(Schema$1.String)
|
|
309
|
+
});
|
|
310
|
+
const ObjectStorageRegion = Schema$1.Struct({
|
|
311
|
+
name: Schema$1.String,
|
|
312
|
+
primary_zone: Schema$1.String,
|
|
313
|
+
zones: Schema$1.optionalKey(Schema$1.Array(Schema$1.Struct({ name: Schema$1.String })))
|
|
314
|
+
});
|
|
315
|
+
const _decodeService = decodeOn2xx(ObjectStorageService);
|
|
316
|
+
const _decodeServices = decodeOn2xx(Schema$1.Array(ObjectStorageService));
|
|
317
|
+
const _decodeBucketList = decodeOn2xx(Schema$1.Array(BucketMetrics));
|
|
318
|
+
const _decodeUser = decodeOn2xx(ObjectStorageUser);
|
|
319
|
+
const _decodeAccessKey = decodeOn2xx(AccessKey);
|
|
320
|
+
const _decodeAccessKeys = decodeOn2xx(Schema$1.Array(AccessKey));
|
|
321
|
+
const _decodeRegions = decodeOn2xx(Schema$1.Array(ObjectStorageRegion));
|
|
322
|
+
const ObjectStorageUserPolicy = Schema$1.Struct({
|
|
323
|
+
name: Schema$1.String,
|
|
324
|
+
arn: Schema$1.optionalKey(Schema$1.String)
|
|
325
|
+
});
|
|
326
|
+
const _decodePolicies = decodeOn2xx(Schema$1.Array(ObjectStorageUserPolicy));
|
|
327
|
+
const _base = "/1.3/object-storage-2";
|
|
328
|
+
const _service = (uuid) => `${_base}/${uuid}`;
|
|
329
|
+
const _buckets = (serviceUuid) => `${_service(serviceUuid)}/buckets`;
|
|
330
|
+
const _users = (serviceUuid) => `${_service(serviceUuid)}/users`;
|
|
331
|
+
const _user = (serviceUuid, username) => `${_users(serviceUuid)}/${username}`;
|
|
332
|
+
const _policies = (serviceUuid, username) => `${_user(serviceUuid, username)}/policies`;
|
|
333
|
+
const _accessKeys = (serviceUuid, username) => `${_user(serviceUuid, username)}/access-keys`;
|
|
334
|
+
const _pageSize = 100;
|
|
335
|
+
const _maxPages = 1e3;
|
|
336
|
+
const _paged = (fetch) => paginateByOffset({
|
|
337
|
+
fetch: (offset) => fetch(`limit=${_pageSize}&offset=${offset}`),
|
|
338
|
+
items: (page) => page,
|
|
339
|
+
limit: _pageSize,
|
|
340
|
+
maxPages: _maxPages
|
|
341
|
+
});
|
|
342
|
+
const makeObjectStorageClient = (httpClient) => ({
|
|
343
|
+
services: {
|
|
344
|
+
list: () => _paged((page) => httpClient.execute(HttpClientRequest.get(`${_base}?${page}`)).pipe(Effect.flatMap(_decodeServices))),
|
|
345
|
+
get: (uuid) => httpClient.execute(HttpClientRequest.get(_service(uuid))).pipe(Effect.flatMap(_decodeService)),
|
|
346
|
+
create: (body) => httpClient.execute(HttpClientRequest.post(_base).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeService)),
|
|
347
|
+
patch: (uuid, body) => httpClient.execute(HttpClientRequest.patch(_service(uuid)).pipe(HttpClientRequest.bodyJsonUnsafe(body))).pipe(Effect.flatMap(_decodeService)),
|
|
348
|
+
delete: (uuid, force) => httpClient.execute(HttpClientRequest.delete(force ? `${_service(uuid)}?force=true` : _service(uuid))).pipe(Effect.flatMap(decodeVoid))
|
|
349
|
+
},
|
|
350
|
+
buckets: {
|
|
351
|
+
list: (serviceUuid) => _paged((page) => httpClient.execute(HttpClientRequest.get(`${_buckets(serviceUuid)}?${page}`)).pipe(Effect.flatMap(_decodeBucketList))),
|
|
352
|
+
create: (serviceUuid, name) => httpClient.execute(HttpClientRequest.post(_buckets(serviceUuid)).pipe(HttpClientRequest.bodyJsonUnsafe({ name }))).pipe(Effect.flatMap(decodeVoid)),
|
|
353
|
+
delete: (serviceUuid, name) => httpClient.execute(HttpClientRequest.delete(`${_buckets(serviceUuid)}/${name}`)).pipe(Effect.flatMap(decodeVoid))
|
|
354
|
+
},
|
|
355
|
+
users: {
|
|
356
|
+
create: (serviceUuid, username) => httpClient.execute(HttpClientRequest.post(_users(serviceUuid)).pipe(HttpClientRequest.bodyJsonUnsafe({ username }))).pipe(Effect.flatMap(_decodeUser)),
|
|
357
|
+
get: (serviceUuid, username) => httpClient.execute(HttpClientRequest.get(_user(serviceUuid, username))).pipe(Effect.flatMap(_decodeUser)),
|
|
358
|
+
delete: (serviceUuid, username) => httpClient.execute(HttpClientRequest.delete(_user(serviceUuid, username))).pipe(Effect.flatMap(decodeVoid)),
|
|
359
|
+
policies: {
|
|
360
|
+
list: (serviceUuid, username) => httpClient.execute(HttpClientRequest.get(_policies(serviceUuid, username))).pipe(Effect.flatMap(_decodePolicies)),
|
|
361
|
+
attach: (serviceUuid, username, name) => httpClient.execute(HttpClientRequest.post(_policies(serviceUuid, username)).pipe(HttpClientRequest.bodyJsonUnsafe({ name }))).pipe(Effect.flatMap(decodeVoid))
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
accessKeys: {
|
|
365
|
+
create: (serviceUuid, username) => httpClient.execute(HttpClientRequest.post(_accessKeys(serviceUuid, username))).pipe(Effect.flatMap(_decodeAccessKey)),
|
|
366
|
+
list: (serviceUuid, username) => httpClient.execute(HttpClientRequest.get(_accessKeys(serviceUuid, username))).pipe(Effect.flatMap(_decodeAccessKeys)),
|
|
367
|
+
patch: (serviceUuid, username, accessKeyId, status) => httpClient.execute(HttpClientRequest.patch(`${_accessKeys(serviceUuid, username)}/${accessKeyId}`).pipe(HttpClientRequest.bodyJsonUnsafe({ status }))).pipe(Effect.flatMap(_decodeAccessKey)),
|
|
368
|
+
delete: (serviceUuid, username, accessKeyId) => httpClient.execute(HttpClientRequest.delete(`${_accessKeys(serviceUuid, username)}/${accessKeyId}`)).pipe(Effect.flatMap(decodeVoid))
|
|
369
|
+
},
|
|
370
|
+
regions: () => httpClient.execute(HttpClientRequest.get(`${_base}/regions`)).pipe(Effect.flatMap(_decodeRegions))
|
|
371
|
+
});
|
|
372
|
+
// src/index.ts
|
|
373
|
+
/** @kumulo/upcloud — package barrel. */
|
|
374
|
+
const packageName = "@kumulo/upcloud";
|
|
375
|
+
export { AccessKey, NodeGroup, ObjectStorageService, Storage, StorageTier, UksCluster, UpcloudHttpLive, UpcloudLabel, ignoreMissing, makeNetworkClient, makeNodeGroupsClient, makeObjectStorageClient, makeRouterClient, makeStorageClient, makeUksClient, makeZoneClient, mapUpcloudError, packageName };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import type { Duration, Redacted } from "effect";
|
|
3
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
4
|
+
export declare const UPCLOUD_API_BASE_URL = "https://api.upcloud.com";
|
|
5
|
+
export interface UpcloudHttpClientOptions {
|
|
6
|
+
readonly base: HttpClient.HttpClient;
|
|
7
|
+
readonly token: Redacted.Redacted<string>;
|
|
8
|
+
readonly baseUrl?: string;
|
|
9
|
+
readonly requestTimeout?: Duration.Input;
|
|
10
|
+
}
|
|
11
|
+
export declare const makeUpcloudHttpClient: (options: UpcloudHttpClientOptions) => Effect.Effect<HttpClient.HttpClient>;
|
|
12
|
+
export declare const UpcloudHttpLive: ({ token, baseUrl }: {
|
|
13
|
+
readonly token: Redacted.Redacted<string>;
|
|
14
|
+
readonly baseUrl?: string;
|
|
15
|
+
}) => Layer.Layer<HttpClient.HttpClient, never, HttpClient.HttpClient>;
|
package/package.json
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@kumulo/upcloud",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Hand-written UpCloud API client (UKS, network, router) for kumulo.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "David Stahl-Gruber",
|
|
7
|
+
"homepage": "https://github.com/DwieDave/kumulo#readme",
|
|
8
|
+
"bugs": "https://github.com/DwieDave/kumulo/issues",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/DwieDave/kumulo.git",
|
|
12
|
+
"directory": "packages/upcloud/client"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"upcloud",
|
|
16
|
+
"uks",
|
|
17
|
+
"kubernetes",
|
|
18
|
+
"effect",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@kumulo/core": "0.2.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"effect": "4.1.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@effect/vitest": "4.1.0",
|
|
49
|
+
"effect": "4.1.0",
|
|
50
|
+
"vitest": "5.0.5"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "bash ../../../scripts/build-package.sh",
|
|
54
|
+
"prepack": "node ../../../scripts/prepack-exports.mjs strip",
|
|
55
|
+
"postpack": "node ../../../scripts/prepack-exports.mjs restore",
|
|
56
|
+
"prepublishOnly": "bun run build"
|
|
57
|
+
}
|
|
58
|
+
}
|