Skip to content

Commit ff030cf

Browse files
authored
feat(instance): add getServerUserData method (#405)
1 parent 01b33a7 commit ff030cf

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/clients/src/api/instance/v1/api.utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import type {
3939
CreateServerRequest,
4040
DetachVolumeRequest,
4141
DetachVolumeResponse,
42+
GetServerUserDataRequest,
4243
SetServerUserDataRequest,
4344
UpdateImageRequest,
4445
UpdateImageResponse,
@@ -512,6 +513,24 @@ export class InstanceV1UtilsAPI extends API {
512513
)
513514
.then(res => ({ image: res.image }))
514515

516+
/**
517+
* Get the content of a user data on a server for the given key.
518+
*
519+
* @param request - The request {@link GetServerUserDataRequest}
520+
* @returns The content of the key
521+
*/
522+
getServerUserData = (request: Readonly<GetServerUserDataRequest>) =>
523+
this.client.fetch<string>({
524+
method: 'GET',
525+
path: `/instance/v1/zones/${validatePathParam(
526+
'zone',
527+
request.zone ?? this.client.settings.defaultZone,
528+
)}/servers/${validatePathParam(
529+
'serverId',
530+
request.serverId,
531+
)}/user_data/${validatePathParam('key', request.key)}`,
532+
})
533+
515534
/**
516535
* Sets the content of a user data on a server for the given key.
517536
*

packages/clients/src/api/instance/v1/types.utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ export interface UpdateImageResponse {
106106
image?: Image
107107
}
108108

109+
export type GetServerUserDataRequest = {
110+
/** Zone to target. If none is passed will use default zone from the config */
111+
zone?: Zone
112+
serverId: string
113+
/** The user data key to get */
114+
key: string
115+
}
116+
109117
export type SetServerUserDataRequest = {
110118
/** Zone to target. If none is passed will use default zone from the config */
111119
zone?: Zone

0 commit comments

Comments
 (0)