// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as FilesAPI from './files'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class Share extends APIResource { /** * Replace who a file the caller owns is shared with: any active Team of the * caller's Organization and/or the whole Organization (`organization`). Recipients * can view and use the file but cannot delete it. An empty `targets` list stops * sharing. A file saved from a knowledge base that was `confidential` or * `restricted` when saved, is now, or can no longer be found can't be shared, but * sharing can still be stopped. Requires X-Tenant-ID header. */ create( fileID: string, params: ShareCreateParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.put(path`/library/files/${fileID}/share`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Revoke every share of a file the caller owns. Idempotent: revoking an unshared * file succeeds. Conversations where recipients already attached the file are * unaffected. Requires X-Tenant-ID header. */ deleteAll( fileID: string, params: ShareDeleteAllParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.delete(path`/library/files/${fileID}/share`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * The share targets of a Library file after a share or revoke. */ export interface LibraryShareResponse { /** * Library file ID. */ id: string; /** * Teams and/or the Organization the file is now shared with. */ shared_with?: Array; } export interface ShareCreateParams { /** * Body param: The complete set of targets the file should be shared with. */ targets: Array; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export namespace ShareCreateParams { /** * A requested share target. */ export interface Target { /** * `team` or `organization`. */ type: FilesAPI.ShareTargetType; /** * Team ID. Required for `team`. Optional for `organization`: if given, it must be * the caller's own Organization ID. */ id?: string | null; } } export interface ShareDeleteAllParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Share { export { type LibraryShareResponse as LibraryShareResponse, type ShareCreateParams as ShareCreateParams, type ShareDeleteAllParams as ShareDeleteAllParams, }; }