diff --git a/packages/service-clients/odsp-client/api-report/odsp-client.alpha.api.md b/packages/service-clients/odsp-client/api-report/odsp-client.alpha.api.md index 8a0462d5c31d..9544d32aa15d 100644 --- a/packages/service-clients/odsp-client/api-report/odsp-client.alpha.api.md +++ b/packages/service-clients/odsp-client/api-report/odsp-client.alpha.api.md @@ -50,8 +50,10 @@ export interface OdspConnectionConfig { // @beta (undocumented) export interface OdspContainerAttachProps { + eTag?: string; fileName: string | undefined; filePath: string | undefined; + itemId?: string; } // @beta diff --git a/packages/service-clients/odsp-client/api-report/odsp-client.beta.api.md b/packages/service-clients/odsp-client/api-report/odsp-client.beta.api.md index fc893e97c251..afdf03485e13 100644 --- a/packages/service-clients/odsp-client/api-report/odsp-client.beta.api.md +++ b/packages/service-clients/odsp-client/api-report/odsp-client.beta.api.md @@ -50,8 +50,10 @@ export interface OdspConnectionConfig { // @beta (undocumented) export interface OdspContainerAttachProps { + eTag?: string; fileName: string | undefined; filePath: string | undefined; + itemId?: string; } // @beta diff --git a/packages/service-clients/odsp-client/src/interfaces.ts b/packages/service-clients/odsp-client/src/interfaces.ts index 2096dd4333d7..20359d685e82 100644 --- a/packages/service-clients/odsp-client/src/interfaces.ts +++ b/packages/service-clients/odsp-client/src/interfaces.ts @@ -77,6 +77,18 @@ export interface OdspContainerAttachProps { * The file name of the Fluid file. If undefined, the file is named with a GUID. */ fileName: string | undefined; + + /** + * The ID of the item (file) to which the container is being attached. + * When combined with eTag, this will trigger a conversion of an existing file to a Fluid file. + */ + itemId?: string; + + /** + * Optional eTag to use when attaching the container. + * If provided, the container will + */ + eTag?: string; } /** diff --git a/packages/service-clients/odsp-client/src/odspClient.ts b/packages/service-clients/odsp-client/src/odspClient.ts index 44459bd74d50..3ddbcee21792 100644 --- a/packages/service-clients/odsp-client/src/odspClient.ts +++ b/packages/service-clients/odsp-client/src/odspClient.ts @@ -202,12 +202,25 @@ export class OdspClient { const attach = async ( odspProps?: ContainerAttachProps, ): Promise => { - const createNewRequest: IRequest = createOdspCreateContainerRequest( - connection.siteUrl, - connection.driveId, - odspProps?.filePath ?? "", - odspProps?.fileName ?? uuid(), - ); + const createNewRequest: IRequest = + odspProps?.eTag !== undefined && odspProps?.itemId !== undefined + ? { + url: createOdspUrl({ + siteUrl: connection.siteUrl, + driveId: connection.driveId, + itemId: odspProps.itemId, + dataStorePath: "", + }), + headers: { + eTag: odspProps.eTag, + }, + } + : createOdspCreateContainerRequest( + connection.siteUrl, + connection.driveId, + odspProps?.filePath ?? "", + odspProps?.fileName ?? uuid(), + ); if (container.attachState !== AttachState.Detached) { throw new Error("Cannot attach container. Container is not in detached state"); }