@@ -21,6 +21,7 @@ import {
2121 GetSceneMetadataParams ,
2222 isSceneMetadataResponse ,
2323 SceneMetadataResponse ,
24+ PutSceneParams ,
2425} from "../models/index.js" ;
2526import { iteratePagedEndpoint } from "../utilities.js" ;
2627import { callApi , AuthArgs } from "./apiFetch.js" ;
@@ -238,6 +239,50 @@ export async function postScene({
238239 } ) ;
239240}
240241
242+ /**
243+ * Create or replace an existing scene.
244+ * @param params - {@link PutSceneParams}
245+ * @returns Created/updated scene details.
246+ * @throws {ScenesApiError } If the API call fails or the response format is invalid.
247+ */
248+ export async function putScene ( {
249+ iTwinId,
250+ sceneId,
251+ scene,
252+ getAccessToken,
253+ baseUrl,
254+ } : PutSceneParams & AuthArgs ) : Promise < SceneResponse > {
255+ return callApi < SceneResponse > ( {
256+ endpoint : `/${ sceneId } ?iTwinId=${ iTwinId } ` ,
257+ getAccessToken,
258+ baseUrl,
259+ postProcess : async ( response ) => {
260+ if ( ! response . ok ) {
261+ await handleErrorResponse ( response ) ;
262+ }
263+ const responseJson = await response . json ( ) ;
264+ if ( ! isSceneResponse ( responseJson ) ) {
265+ throw new ScenesApiError (
266+ {
267+ code : "InvalidResponse" ,
268+ message : "Error creating or replacing scene: unexpected response format" ,
269+ } ,
270+ response . status ,
271+ ) ;
272+ }
273+ return responseJson ;
274+ } ,
275+ fetchOptions : {
276+ method : "PUT" ,
277+ body : JSON . stringify ( scene ) ,
278+ } ,
279+ additionalHeaders : {
280+ Accept : "application/vnd.bentley.itwin-platform.v1+json" ,
281+ "Content-Type" : "application/json" ,
282+ } ,
283+ } ) ;
284+ }
285+
241286/**
242287 * Updates an existing scene's metadata.
243288 * @param params - {@link PatchSceneParams}
0 commit comments