Skip to content

Commit aadb8de

Browse files
wrangler containers apply uses observability configuration
1 parent 6c6afbd commit aadb8de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1447
-271
lines changed

.changeset/bumpy-beers-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
`wrangler containers apply` uses `observability` configuration.

packages/containers-shared/src/client/core/OpenAPI.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* istanbul ignore file */
22
/* tslint:disable */
3-
/* eslint-disable */
43
import { Agent } from "undici";
54
import type { ApiRequestOptions } from "./ApiRequestOptions";
65

packages/containers-shared/src/client/core/request.ts

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ import type { ApiRequestOptions } from "./ApiRequestOptions";
99
import type { ApiResult } from "./ApiResult";
1010
import type { OnCancel } from "./CancelablePromise";
1111

12+
interface FetchError {
13+
code: number;
14+
documentation_url?: string;
15+
message: string;
16+
error_chain?: FetchError[];
17+
}
18+
19+
interface FetchResult<ResponseType = unknown> {
20+
success: boolean;
21+
result: ResponseType;
22+
errors: FetchError[];
23+
messages?: string[];
24+
result_info?: unknown;
25+
}
26+
1227
const isDefined = <T>(
1328
value: T | null | undefined
1429
): value is Exclude<T, null | undefined> => {
@@ -197,6 +212,13 @@ const getRequestBody = (options: ApiRequestOptions): any => {
197212
return undefined;
198213
};
199214

215+
const isResponseSchemaV4 = (
216+
config: OpenAPIConfig,
217+
_options: ApiRequestOptions
218+
): boolean => {
219+
return config.BASE.endsWith("/containers");
220+
};
221+
200222
export const sendRequest = async (
201223
config: OpenAPIConfig,
202224
options: ApiRequestOptions,
@@ -319,16 +341,28 @@ export const request = <T>(
319341
options.responseHeader
320342
);
321343

322-
const result: ApiResult = {
323-
url,
324-
ok: response.ok,
325-
status: response.status,
326-
statusText: response.statusText,
327-
body: responseHeader ?? responseBody,
344+
const parseResponseSchemaV4 = (body: any): ApiResult => {
345+
const fetchResult = body as FetchResult<T>;
346+
return {
347+
url,
348+
ok: response.ok && fetchResult.success,
349+
status: response.status,
350+
statusText: response.statusText,
351+
body: responseHeader ?? fetchResult.result,
352+
};
328353
};
329354

330-
catchErrorCodes(options, result);
355+
const result: ApiResult = isResponseSchemaV4(config, options)
356+
? parseResponseSchemaV4(responseBody)
357+
: {
358+
url,
359+
ok: response.ok,
360+
status: response.status,
361+
statusText: response.statusText,
362+
body: responseHeader ?? responseBody,
363+
};
331364

365+
catchErrorCodes(options, result);
332366
resolve(result.body);
333367
}
334368
} catch (error) {

packages/containers-shared/src/client/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export { ApiError } from "./core/ApiError";
55
export { CancelablePromise, CancelError } from "./core/CancelablePromise";
66
export { OpenAPI } from "./core/OpenAPI";
77
export type { OpenAPIConfig } from "./core/OpenAPI";
8-
export { request } from "./core/request";
98

109
export type { AccountDefaults } from "./models/AccountDefaults";
1110
export type { AccountID } from "./models/AccountID";
@@ -14,9 +13,11 @@ export type { AccountLocation } from "./models/AccountLocation";
1413
export type { AccountLocationLimits } from "./models/AccountLocationLimits";
1514
export type { AccountLocationLimitsAsProperty } from "./models/AccountLocationLimitsAsProperty";
1615
export type { AccountRegistryToken } from "./models/AccountRegistryToken";
16+
export type { AddressAssignment } from "./models/AddressAssignment";
1717
export type { Application } from "./models/Application";
1818
export type { ApplicationAffinities } from "./models/ApplicationAffinities";
1919
export { ApplicationAffinityColocation } from "./models/ApplicationAffinityColocation";
20+
export type { ApplicationConstraintPop } from "./models/ApplicationConstraintPop";
2021
export type { ApplicationConstraints } from "./models/ApplicationConstraints";
2122
export type { ApplicationHealth } from "./models/ApplicationHealth";
2223
export type { ApplicationHealthInstances } from "./models/ApplicationHealthInstances";
@@ -113,11 +114,11 @@ export { ImageRegistryProtocolIsReferencedError } from "./models/ImageRegistryPr
113114
export { ImageRegistryProtocolNotFound } from "./models/ImageRegistryProtocolNotFound";
114115
export type { ImageRegistryProtocols } from "./models/ImageRegistryProtocols";
115116
export type { ImageRegistryProtoDomain } from "./models/ImageRegistryProtoDomain";
117+
export { InstanceType } from "./models/InstanceType";
116118
export type { InternalError } from "./models/InternalError";
117119
export type { IP } from "./models/IP";
118120
export type { IPAllocation } from "./models/IPAllocation";
119121
export type { IPAllocationConfiguration } from "./models/IPAllocationConfiguration";
120-
export type { IPAllocationPlacement } from "./models/IPAllocationPlacement";
121122
export type { IPAllocationsWithFilter } from "./models/IPAllocationsWithFilter";
122123
export { IPType } from "./models/IPType";
123124
export type { IPV4 } from "./models/IPV4";
@@ -158,6 +159,7 @@ export type { NetworkParameters } from "./models/NetworkParameters";
158159
export { NodeGroup } from "./models/NodeGroup";
159160
export type { Observability } from "./models/Observability";
160161
export type { ObservabilityLogging } from "./models/ObservabilityLogging";
162+
export type { ObservabilityLogs } from "./models/ObservabilityLogs";
161163
export type { Placement } from "./models/Placement";
162164
export type { PlacementEvent } from "./models/PlacementEvent";
163165
export type { PlacementEvents } from "./models/PlacementEvents";
@@ -168,6 +170,8 @@ export { PlacementStatusHealth } from "./models/PlacementStatusHealth";
168170
export type { PlacementWithEvents } from "./models/PlacementWithEvents";
169171
export type { PlainTextSecretValue } from "./models/PlainTextSecretValue";
170172
export type { Port } from "./models/Port";
173+
export type { PortRange } from "./models/PortRange";
174+
export type { PortRangeAllocation } from "./models/PortRangeAllocation";
171175
export { ProvisionerConfiguration } from "./models/ProvisionerConfiguration";
172176
export type { Ref } from "./models/Ref";
173177
export type { Region } from "./models/Region";

packages/containers-shared/src/client/models/AccountDefaults.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ import type { MemorySizeWithUnit } from "./MemorySizeWithUnit";
99
*/
1010
export type AccountDefaults = {
1111
vcpus: number;
12-
memory_mib?: number;
12+
memory_mib: number;
1313
/**
14-
* DEPRECATED in favor of memory_mib
14+
* Default disk size in MB
15+
*/
16+
disk_mb?: number;
17+
/**
18+
* Deprecated in favor of memory_mib
1519
* @deprecated
1620
*/
17-
memory: MemorySizeWithUnit;
21+
memory?: MemorySizeWithUnit;
1822
};

packages/containers-shared/src/client/models/AccountLimit.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,24 @@ export type AccountLimit = {
1919
* @deprecated
2020
*/
2121
memory_per_deployment: MemorySizeWithUnit;
22-
memory_mib_per_deployment?: number;
22+
memory_mib_per_deployment: number;
2323
/**
2424
* Deprecated in favor of disk_mb_per_deployment
2525
* @deprecated
2626
*/
2727
disk_per_deployment: DiskSizeWithUnit;
28-
disk_mb_per_deployment?: number;
28+
disk_mb_per_deployment: number;
2929
total_vcpu: number;
3030
/**
31-
* DEPRECATED in favor of total_memory_mib
31+
* Deprecated in favor of total_memory_mib
3232
* @deprecated
3333
*/
3434
total_memory: MemorySizeWithUnit;
35-
total_memory_mib?: number;
35+
total_memory_mib: number;
36+
/**
37+
* Total amount of disk usage allowed for the account
38+
*/
39+
total_disk_mb: number;
3640
node_group: NodeGroup;
3741
/**
3842
* Network modes that will be included in this customer's vm

packages/containers-shared/src/client/models/IPAllocationPlacement.ts renamed to packages/containers-shared/src/client/models/AddressAssignment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import type { PlacementID } from "./PlacementID";
77
import type { UnixTimestamp } from "./UnixTimestamp";
88

99
/**
10-
* The allocation that exists when an IP has been assigned to a metal
10+
* The allocation that exists when an IP or a port range has been assigned to a metal
1111
*/
12-
export type IPAllocationPlacement = {
12+
export type AddressAssignment = {
1313
placementID?: PlacementID;
14-
expiration: UnixTimestamp;
14+
expiration?: UnixTimestamp;
1515
deploymentID?: DeploymentID;
1616
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
/**
6+
* The name of a pop to be specified in an application pop. Requires specific entitlements to use this.
7+
*/
8+
export type ApplicationConstraintPop = string;

packages/containers-shared/src/client/models/ApplicationConstraints.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* tslint:disable */
33
/* eslint-disable */
44

5+
import type { ApplicationConstraintPop } from "./ApplicationConstraintPop";
56
import type { City } from "./City";
67
import type { Region } from "./Region";
78

@@ -10,4 +11,5 @@ export type ApplicationConstraints = {
1011
tier?: number;
1112
regions?: Array<Region>;
1213
cities?: Array<City>;
14+
pops?: Array<ApplicationConstraintPop>;
1315
};

packages/containers-shared/src/client/models/ApplicationHealthInstances.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@
33
/* eslint-disable */
44

55
export type ApplicationHealthInstances = {
6+
/**
7+
* Number of active durable object containers in this application.
8+
*
9+
*/
10+
durable_objects_active?: number;
11+
/**
12+
* Number of healthy instances. If the application is attached to a DO namespace,
13+
* this represents the number of prepared container instances.
14+
*
15+
*/
616
healthy: number;
17+
/**
18+
* Number of failing container instances.
19+
*
20+
*/
721
failed: number;
22+
/**
23+
* Number of container instances that are being prepared.
24+
*
25+
*/
826
starting: number;
27+
/**
28+
* Number of container instances pending to be scheduled.
29+
*
30+
*/
931
scheduling: number;
1032
};

0 commit comments

Comments
 (0)