/* tslint:disable */ /* eslint-disable */ /** * Fabric API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { CreateNotepadRequest, CreateNotepadSnapshot201Response, CreateNotepadSnapshotRequest, ListNotepadSnapshots200Response, PutNotepadContentRequest, ResourceDetailNotepad, } from '../models/index'; import { CreateNotepadRequestFromJSON, CreateNotepadRequestToJSON, CreateNotepadSnapshot201ResponseFromJSON, CreateNotepadSnapshot201ResponseToJSON, CreateNotepadSnapshotRequestFromJSON, CreateNotepadSnapshotRequestToJSON, ListNotepadSnapshots200ResponseFromJSON, ListNotepadSnapshots200ResponseToJSON, PutNotepadContentRequestFromJSON, PutNotepadContentRequestToJSON, ResourceDetailNotepadFromJSON, ResourceDetailNotepadToJSON, } from '../models/index'; export type CreateNotepadOperationRequest = Omit; export type CreateNotepadSnapshotOperationRequest = Omit; export type GetNotepadContentRequest = Omit<{ resourceId: string; baseId?: string; }, 'baseId'>; export type GetNotepadSnapshotContentRequest = Omit<{ resourceId: string; snapshotId: string; baseId?: string; }, 'baseId'>; export type ListNotepadSnapshotsRequest = Omit<{ resourceId: string; baseId?: string; limit?: number; offset?: number | null; }, 'baseId'>; export type PutNotepadContentOperationRequest = Omit; export type RevertNotepadToSnapshotRequest = Omit<{ resourceId: string; snapshotId: string; baseId?: string; }, 'baseId'>; /** * */ export class NotepadsApi extends runtime.BaseAPI { /** * Create a new notepad resource in the specified location. * Create notepad */ async createRaw(requestParameters: CreateNotepadOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateNotepadRequestToJSON(requestParameters), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ResourceDetailNotepadFromJSON(jsonValue)); } /** * Create a new notepad resource in the specified location. * Create notepad */ async create(requestParameters: CreateNotepadOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { const response = await this.createRaw(requestParameters, initOverrides); return await response.value(); } /** * Create a point-in-time snapshot of the current notepad content. Use an optional label to describe the snapshot (e.g. \"before restructure\"). Snapshots can later be used to view or revert to a previous version of the notepad. * Create notepad snapshot */ async createSnapshotRaw(requestParameters: CreateNotepadSnapshotOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/snapshots`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateNotepadSnapshotRequestToJSON(requestParameters), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateNotepadSnapshot201ResponseFromJSON(jsonValue)); } /** * Create a point-in-time snapshot of the current notepad content. Use an optional label to describe the snapshot (e.g. \"before restructure\"). Snapshots can later be used to view or revert to a previous version of the notepad. * Create notepad snapshot */ async createSnapshot(requestParameters: CreateNotepadSnapshotOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { const response = await this.createSnapshotRaw(requestParameters, initOverrides); return await response.value(); } /** * Retrieve the plain text content of a notepad. * Get notepad content */ async getContentRaw(requestParameters: GetNotepadContentRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/content`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Retrieve the plain text content of a notepad. * Get notepad content */ async getContent(requestParameters: GetNotepadContentRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { const response = await this.getContentRaw(requestParameters, initOverrides); return await response.value(); } /** * Retrieve the markdown content of a notepad at a specific snapshot. Use this to inspect what the notepad looked like at a previous point in time. * Get notepad snapshot content */ async getSnapshotContentRaw(requestParameters: GetNotepadSnapshotContentRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } if (requestParameters['snapshotId'] == null) { throw new runtime.RequiredError( 'snapshotId', 'Required parameter "snapshotId" was null or undefined when calling ().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/snapshots/{snapshotId}/content`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); urlPath = urlPath.replace(`{${"snapshotId"}}`, encodeURIComponent(String(requestParameters['snapshotId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Retrieve the markdown content of a notepad at a specific snapshot. Use this to inspect what the notepad looked like at a previous point in time. * Get notepad snapshot content */ async getSnapshotContent(requestParameters: GetNotepadSnapshotContentRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { const response = await this.getSnapshotContentRaw(requestParameters, initOverrides); return await response.value(); } /** * Retrieve a paginated list of version snapshots for a notepad, ordered by most recent first. Each snapshot represents a saved point-in-time state of the notepad content. * List notepad snapshots */ async listSnapshotsRaw(requestParameters: ListNotepadSnapshotsRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } const queryParameters: any = {}; if (requestParameters['limit'] != null) { queryParameters['limit'] = requestParameters['limit']; } if (requestParameters['offset'] != null) { queryParameters['offset'] = requestParameters['offset']; } const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/snapshots`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ListNotepadSnapshots200ResponseFromJSON(jsonValue)); } /** * Retrieve a paginated list of version snapshots for a notepad, ordered by most recent first. Each snapshot represents a saved point-in-time state of the notepad content. * List notepad snapshots */ async listSnapshots(requestParameters: ListNotepadSnapshotsRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { const response = await this.listSnapshotsRaw(requestParameters, initOverrides); return await response.value(); } /** * Replace the entire content of a notepad with the provided markdown. * Update notepad content */ async putContentRaw(requestParameters: PutNotepadContentOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/content`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); const response = await this.request({ path: urlPath, method: 'PUT', headers: headerParameters, query: queryParameters, body: PutNotepadContentRequestToJSON(requestParameters), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Replace the entire content of a notepad with the provided markdown. * Update notepad content */ async putContent(requestParameters: PutNotepadContentOperationRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { await this.putContentRaw(requestParameters, initOverrides); } /** * Revert a notepad to the state captured in a specific snapshot. This replaces the current content with the snapshot content and discards all snapshots newer than the target. This action cannot be undone. * Revert notepad to snapshot */ async revertToSnapshotRaw(requestParameters: RevertNotepadToSnapshotRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise> { if (requestParameters['resourceId'] == null) { throw new runtime.RequiredError( 'resourceId', 'Required parameter "resourceId" was null or undefined when calling ().' ); } if (requestParameters['snapshotId'] == null) { throw new runtime.RequiredError( 'snapshotId', 'Required parameter "snapshotId" was null or undefined when calling ().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (requestParameters['baseId'] != null) { headerParameters['X-Fabric-Base-Id'] = String(requestParameters['baseId']); } if (this.configuration && this.configuration.accessToken) { // oauth required headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2", []); } if (this.configuration && this.configuration.apiKey) { headerParameters["X-Api-Key"] = await this.configuration.apiKey("X-Api-Key"); // ApiKey authentication } let urlPath = `/v2/notepads/{resourceId}/snapshots/{snapshotId}/revert`; urlPath = urlPath.replace(`{${"resourceId"}}`, encodeURIComponent(String(requestParameters['resourceId']))); urlPath = urlPath.replace(`{${"snapshotId"}}`, encodeURIComponent(String(requestParameters['snapshotId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Revert a notepad to the state captured in a specific snapshot. This replaces the current content with the snapshot content and discards all snapshots newer than the target. This action cannot be undone. * Revert notepad to snapshot */ async revertToSnapshot(requestParameters: RevertNotepadToSnapshotRequest, initOverrides?: runtime.InitOverrides | runtime.InitOverrideFunction): Promise { await this.revertToSnapshotRaw(requestParameters, initOverrides); } }