// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import * as BusinessPartnersAPI from './business-partners'; import { APIPromise } from '../core/api-promise'; import { PageCursorURL, PagePromise } from '../core/pagination'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; /** * Custom sites hosted on Rippling */ export class Sites extends APIResource { /** * Retrieves sites that the user has view or edit access on. Optional query param * name filters by case-insensitive substring on display name. Use GET * /sites/{api_name}/ for an exact api_name lookup. * * @example SDK usage * ```ts * // Automatically fetches more pages as needed. * for await (const siteListResponse of client.sites.list()) { * // ... * } * ``` * * @example HTTP * Representative request and response shapes. * ``` * GET /sites/?limit=50&cursor=cursor HTTP/1.1 * Host: rest.ripplingapis.com * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "__meta": { * "redacted_fields": [ * { * "name": "date_of_birth", * "reason": "Insufficient entitlements" * } * ] * }, * "results": [ * { * "id": "string", * "name": "string", * "description": "string", * "api_name": "string", * "logo": "string", * "current_bundle_id": "string", * "admin_group_id": "string", * "viewer_group_id": "string", * "created_by": "string", * "created_at": "string" * } * ], * "next_link": "string" * } * ``` */ list( query: SiteListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/sites/', PageCursorURL, { query, ...options }); } /** * Create a new site from a staged upload. * * @example SDK usage * ```ts * const site = await client.sites.create({ * api_name: 'my_portal', * file_id: 'file_id_1', * name: 'My Portal', * entry_path: 'index.html', * }); * ``` * * @example HTTP * Representative request and response shapes. * ``` * POST /sites/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "api_name": "my_portal", * "file_id": "file_id_1", * "name": "My Portal", * "entry_path": "index.html" * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "string", * "name": "string", * "description": "string", * "api_name": "string", * "logo": "string", * "current_bundle_id": "string", * "admin_group_id": "string", * "viewer_group_id": "string", * "created_by": "string", * "created_at": "string" * } * ``` */ create(body: SiteCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/sites/', { body, ...options }); } /** * Retrieve a specific site. * * @example SDK usage * ```ts * const site = await client.sites.retrieve('employee_portal'); * ``` * * @example HTTP * Representative request and response shapes. * ``` * GET /sites/{api_name}/ HTTP/1.1 * Host: rest.ripplingapis.com * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "__meta": { * "redacted_fields": [ * {} * ] * } * } * ``` */ retrieve(apiName: string, options?: RequestOptions): APIPromise { return this._client.get(path`/sites/${apiName}/`, options); } /** * Update a site. To replace the bundle, pass a file_id from * upload-batches/presign. * * @example SDK usage * ```ts * const site = await client.sites.update('employee_portal', { * entry_path: 'index.html', * file_id: 'file_id_1', * name: 'My Portal', * }); * ``` * * @example HTTP * Representative request and response shapes. * ``` * PATCH /sites/{api_name}/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "entry_path": "index.html", * "file_id": "file_id_1", * "name": "My Portal" * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "string", * "name": "string", * "description": "string", * "api_name": "string", * "logo": "string", * "current_bundle_id": "string", * "admin_group_id": "string", * "viewer_group_id": "string", * "created_by": "string", * "created_at": "string" * } * ``` */ update( apiName: string, body: SiteUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/sites/${apiName}/`, { body, ...options }); } /** * Delete a site. * * @example SDK usage * ```ts * await client.sites.delete('employee_portal'); * ``` * * @example HTTP * Representative request and response shapes. * ``` * DELETE /sites/{api_name}/ HTTP/1.1 * Host: rest.ripplingapis.com * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 204 No Content * ``` */ delete(apiName: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/sites/${apiName}/`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Create staged upload records and return presigned S3 POST credentials. * * @example SDK usage * ```ts * const response = await client.sites.uploadBatchesPresign({ * file_intents: [ * { client_ref: 'index', file_name: 'index.html' }, * ], * }); * ``` * * @example HTTP * Representative request and response shapes. * ``` * POST /sites/upload-batches/presign/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "file_intents": [ * { * "client_ref": "index", * "file_name": "index.html" * } * ] * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "upload_batch_id": "batch_id", * "files": [ * { * "client_ref": "index", * "file_id": "file_id_1", * "file_name": "index.html", * "status": "awaiting_upload", * "upload_url": "https://s3.example.com/bucket", * "upload_fields": { * "key": "staged/...", * "policy": "...", * "x-amz-signature": "..." * } * } * ] * } * ``` */ uploadBatchesPresign( body: SiteUploadBatchesPresignParams, options?: RequestOptions, ): APIPromise { return this._client.post('/sites/upload-batches/presign/', { body, ...options }); } /** * List files and persisted directories from the active bundle manifest. * * @example SDK usage * ```ts * const response = await client.sites.files( * 'employee_portal', * ); * ``` * * @example HTTP * Representative request and response shapes. * ``` * GET /sites/{api_name}/files/?parent_path=parent_path&recursive=true HTTP/1.1 * Host: rest.ripplingapis.com * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "bundle_id": "bundle_id", * "entry_path": "index.html", * "parent_path": "assets", * "recursive": false, * "files": [ * { * "path": "assets/logo.png", * "name": "logo.png", * "parent_path": "assets", * "content_type": "image/png", * "size_bytes": 12034, * "sha256": "abc123" * } * ], * "directories": [ * { * "path": "assets/images", * "name": "images", * "parent_path": "assets" * } * ] * } * ``` */ files( apiName: string, query: SiteFilesParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/sites/${apiName}/files/`, { query, ...options }); } /** * Apply file and directory operations atomically against the active bundle. * * @example SDK usage * ```ts * const response = await client.sites.fileOperations('employee_portal', { * base_bundle_id: 'bundle_id', * operations: [ * { * op: 'put', * kind: 'file', * path: 'assets/logo.png', * file_id: 'file_id_1', * }, * { * op: 'put', * kind: 'directory', * path: 'assets/images', * }, * { * op: 'rename', * kind: 'file', * from_path: 'home.html', * to_path: 'index.html', * }, * { * op: 'delete', * kind: 'file', * path: 'old.js', * }, * ], * entry_path: 'index.html', * }); * ``` * * @example HTTP * Representative request and response shapes. * ``` * POST /sites/{api_name}/file-operations/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "base_bundle_id": "bundle_id", * "operations": [ * { * "op": "put", * "kind": "file", * "path": "assets/logo.png", * "file_id": "file_id_1" * }, * { * "op": "put", * "kind": "directory", * "path": "assets/images" * }, * { * "op": "rename", * "kind": "file", * "from_path": "home.html", * "to_path": "index.html" * }, * { * "op": "delete", * "kind": "file", * "path": "old.js" * } * ], * "entry_path": "index.html" * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "surface_id", * "name": "Employee Portal", * "api_name": "employee_portal", * "logo": "https://example.com/logo.png", * "current_bundle_id": "new_bundle_id", * "admin_group_id": "group_id", * "viewer_group_id": "group_id", * "created_by": "role_id", * "created_at": "2024-08-01T12:00:00+00:00" * } * ``` */ fileOperations( apiName: string, body: SiteFileOperationsParams, options?: RequestOptions, ): APIPromise { return this._client.post(path`/sites/${apiName}/file-operations/`, { body, ...options }); } } export type SiteListResponsesPageCursorURL = PageCursorURL; /** * Response/resource shape for a custom site. */ export interface SiteListResponse { /** * Identifier field */ id?: string; /** * The admin group id for the custom site */ admin_group_id?: string; /** * The unique api name of the custom site */ api_name?: string; /** * Record creation date */ created_at?: string; /** * The ID of the role that created the custom site */ created_by?: string; /** * The active bundle id for the custom site */ current_bundle_id?: string; /** * The optional description of the custom site */ description?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; /** * The viewer group id for the custom site */ viewer_group_id?: string; } /** * Response/resource shape for a custom site. */ export interface SiteCreateResponse { /** * Identifier field */ id?: string; /** * The admin group id for the custom site */ admin_group_id?: string; /** * The unique api name of the custom site */ api_name?: string; /** * Record creation date */ created_at?: string; /** * The ID of the role that created the custom site */ created_by?: string; /** * The active bundle id for the custom site */ current_bundle_id?: string; /** * The optional description of the custom site */ description?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; /** * The viewer group id for the custom site */ viewer_group_id?: string; } /** * Meta information for the response. */ export interface SiteRetrieveResponse extends BusinessPartnersAPI.Meta { /** * Identifier field */ id?: string; /** * The admin group id for the custom site */ admin_group_id?: string; /** * The unique api name of the custom site */ api_name?: string; /** * Record creation date */ created_at?: string; /** * The ID of the role that created the custom site */ created_by?: string; /** * The active bundle id for the custom site */ current_bundle_id?: string; /** * The optional description of the custom site */ description?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; /** * The viewer group id for the custom site */ viewer_group_id?: string; } /** * Response/resource shape for a custom site. */ export interface SiteUpdateResponse { /** * Identifier field */ id?: string; /** * The admin group id for the custom site */ admin_group_id?: string; /** * The unique api name of the custom site */ api_name?: string; /** * Record creation date */ created_at?: string; /** * The ID of the role that created the custom site */ created_by?: string; /** * The active bundle id for the custom site */ current_bundle_id?: string; /** * The optional description of the custom site */ description?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; /** * The viewer group id for the custom site */ viewer_group_id?: string; } export interface SiteUploadBatchesPresignResponse { /** * Staged files created by the upload batch. */ files?: Array; /** * Identifier for the staged upload batch. */ upload_batch_id?: string; } export namespace SiteUploadBatchesPresignResponse { export interface File { /** * Any unique client-chosen id echoed with the staged file_id for correlation. Not * used server-side beyond the response. */ client_ref?: string; /** * Staged upload identifier for use in create, update, or file operations after * uploading bytes to S3. The id can be reused for 1 hour from presign, each attach * copies the bytes into that site's bundle, a repeat attach before expiry creates * another bundle, and the staged object is removed after expiry. */ file_id?: string; /** * Staged file name from the presign file_name intent. */ file_name?: string; /** * Upload status. Returns awaiting_upload after presign until the file is uploaded * to S3. After the object exists in S3, status becomes active on first use. Attach * does not consume the staged upload; it is removed after expiry. */ status?: string; /** * Form fields required for the S3 POST (send these before the file part). */ upload_fields?: unknown; /** * Presigned S3 POST URL for uploading the file bytes. */ upload_url?: string; } } export interface SiteFilesResponse { /** * Active bundle identifier. */ bundle_id?: string; /** * Directories in the listing scope. */ directories?: Array; /** * Entry path for the active bundle. */ entry_path?: string; /** * Files in the listing scope. */ files?: Array; /** * Directory path used for the listing. */ parent_path?: string; /** * Whether the listing was recursive. */ recursive?: boolean; } export namespace SiteFilesResponse { export interface Directory { /** * Directory name. */ name?: string; /** * Parent directory path. */ parent_path?: string; /** * Normalized directory path inside the active bundle. */ path?: string; } export interface File { /** * MIME content type. */ content_type?: string; /** * File name. */ name?: string; /** * Parent directory path. */ parent_path?: string; /** * Normalized file path inside the active bundle. */ path?: string; /** * SHA-256 hash of the file contents. */ sha256?: string; /** * File size in bytes. */ size_bytes?: number; } } /** * Response/resource shape for a custom site. */ export interface SiteFileOperationsResponse { /** * Identifier field */ id?: string; /** * The admin group id for the custom site */ admin_group_id?: string; /** * The unique api name of the custom site */ api_name?: string; /** * Record creation date */ created_at?: string; /** * The ID of the role that created the custom site */ created_by?: string; /** * The active bundle id for the custom site */ current_bundle_id?: string; /** * The optional description of the custom site */ description?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; /** * The viewer group id for the custom site */ viewer_group_id?: string; } export interface SiteListParams { cursor?: string; /** * The maximum number of results to return. Defaults to 50. Maximum is 100. */ limit?: number; } export interface SiteCreateParams { /** * The unique api name of the custom site */ api_name: string; /** * Staged upload id from POST /sites/upload-batches/presign/ after uploading bytes * to S3. Required to create a site or replace the bundle. The id can be reused for * 1 hour from presign, each attach copies the bytes into that site's bundle, a * repeat attach before expiry creates another bundle, and the staged object is * removed after expiry. */ file_id: string; /** * The display name of the custom site */ name: string; /** * The optional description of the custom site */ description?: string; /** * Entry path inside the uploaded asset (for example index.html). Required with * file_id when the zip has no index.html. */ entry_path?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; } export interface SiteUpdateParams { /** * The unique api name of the custom site */ api_name?: string; /** * The optional description of the custom site */ description?: string; /** * Entry path inside the uploaded asset (for example index.html). Required with * file_id when the zip has no index.html. */ entry_path?: string; /** * Staged upload id from POST /sites/upload-batches/presign/ after uploading bytes * to S3. Required to create a site or replace the bundle. The id can be reused for * 1 hour from presign, each attach copies the bytes into that site's bundle, a * repeat attach before expiry creates another bundle, and the staged object is * removed after expiry. */ file_id?: string; /** * A Rippling-owned logo URL for the custom site */ logo?: string; /** * The display name of the custom site */ name?: string; } export interface SiteUploadBatchesPresignParams { /** * Non-empty array of file upload intents to stage with presigned S3 upload URLs. */ file_intents: Array; } export namespace SiteUploadBatchesPresignParams { export interface FileIntent { /** * Any unique client-chosen id echoed with the staged file_id for correlation. Not * used server-side beyond the response. */ client_ref: string; /** * File name with extension (e.g. site.zip). Used to derive Content-Type and * create/PATCH asset type. */ file_name: string; } } export interface SiteFilesParams { /** * Directory path to list. Defaults to the bundle root. */ parent_path?: string; /** * Whether to list files recursively. Defaults to false. */ recursive?: boolean; } export interface SiteFileOperationsParams { /** * Must match the site's current active bundle. Returns 409 when stale. */ base_bundle_id: string; /** * Non-empty array of file or directory operations. */ operations: Array; /** * Optional bundle entry path. When omitted, the current entry path is kept. */ entry_path?: string; } export namespace SiteFileOperationsParams { export interface Operation { /** * Target kind. Supported values are file and directory. */ kind: string; /** * Operation type. Supported values are put, rename, move, and delete. move is * valid for files only; directories support put, rename, and delete. */ op: string; /** * Staged upload id from POST /sites/upload-batches/presign/ after uploading bytes * to S3. Required for put operations on files. The id can be reused for 1 hour * from presign, each attach copies the bytes into that site's bundle, a repeat * attach before expiry creates another bundle, and the staged object is removed * after expiry. */ file_id?: string; /** * Source path for rename and move operations. */ from_path?: string; /** * Target path for put and delete operations. */ path?: string; /** * When true, delete directory removes nested files. Used by delete directory * operations. */ recursive?: boolean; /** * Destination path for rename and move operations. */ to_path?: string; } } export declare namespace Sites { export { type SiteListResponse as SiteListResponse, type SiteCreateResponse as SiteCreateResponse, type SiteRetrieveResponse as SiteRetrieveResponse, type SiteUpdateResponse as SiteUpdateResponse, type SiteUploadBatchesPresignResponse as SiteUploadBatchesPresignResponse, type SiteFilesResponse as SiteFilesResponse, type SiteFileOperationsResponse as SiteFileOperationsResponse, type SiteListResponsesPageCursorURL as SiteListResponsesPageCursorURL, type SiteListParams as SiteListParams, type SiteCreateParams as SiteCreateParams, type SiteUpdateParams as SiteUpdateParams, type SiteUploadBatchesPresignParams as SiteUploadBatchesPresignParams, type SiteFilesParams as SiteFilesParams, type SiteFileOperationsParams as SiteFileOperationsParams, }; }