diff --git a/packages/clients/src/api/instance/v1/api.utils.ts b/packages/clients/src/api/instance/v1/api.utils.ts index 1c1a81171..ab522b09b 100644 --- a/packages/clients/src/api/instance/v1/api.utils.ts +++ b/packages/clients/src/api/instance/v1/api.utils.ts @@ -39,6 +39,7 @@ import type { CreateServerRequest, DetachVolumeRequest, DetachVolumeResponse, + GetServerUserDataRequest, SetServerUserDataRequest, UpdateImageRequest, UpdateImageResponse, @@ -512,6 +513,24 @@ export class InstanceV1UtilsAPI extends API { ) .then(res => ({ image: res.image })) + /** + * Get the content of a user data on a server for the given key. + * + * @param request - The request {@link GetServerUserDataRequest} + * @returns The content of the key + */ + getServerUserData = (request: Readonly) => + this.client.fetch({ + method: 'GET', + path: `/instance/v1/zones/${validatePathParam( + 'zone', + request.zone ?? this.client.settings.defaultZone, + )}/servers/${validatePathParam( + 'serverId', + request.serverId, + )}/user_data/${validatePathParam('key', request.key)}`, + }) + /** * Sets the content of a user data on a server for the given key. * diff --git a/packages/clients/src/api/instance/v1/types.utils.ts b/packages/clients/src/api/instance/v1/types.utils.ts index 1783efc6b..3d917bf32 100644 --- a/packages/clients/src/api/instance/v1/types.utils.ts +++ b/packages/clients/src/api/instance/v1/types.utils.ts @@ -106,6 +106,14 @@ export interface UpdateImageResponse { image?: Image } +export type GetServerUserDataRequest = { + /** Zone to target. If none is passed will use default zone from the config */ + zone?: Zone + serverId: string + /** The user data key to get */ + key: string +} + export type SetServerUserDataRequest = { /** Zone to target. If none is passed will use default zone from the config */ zone?: Zone