/* tslint:disable */ /* eslint-disable */ /** * attachmentAV * An SDK to integrate virus and malware scan capabilities into JavaScript / TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos. * * 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 { AsyncDownloadScanRequest, AsyncS3ScanRequest, ScanResult, SyncDownloadScanRequest, SyncS3ScanRequest, Usage, Whoami, } from '../models/index'; import { AsyncDownloadScanRequestFromJSON, AsyncDownloadScanRequestToJSON, AsyncS3ScanRequestFromJSON, AsyncS3ScanRequestToJSON, ScanResultFromJSON, ScanResultToJSON, SyncDownloadScanRequestFromJSON, SyncDownloadScanRequestToJSON, SyncS3ScanRequestFromJSON, SyncS3ScanRequestToJSON, UsageFromJSON, UsageToJSON, WhoamiFromJSON, WhoamiToJSON, } from '../models/index'; export interface ScanAsyncDownloadPostRequest { asyncDownloadScanRequest: AsyncDownloadScanRequest; } export interface ScanAsyncResultGetRequest { traceId: string; } export interface ScanAsyncS3PostRequest { asyncS3ScanRequest: AsyncS3ScanRequest; } export interface ScanSyncBinaryPostRequest { body: Blob; } export interface ScanSyncDownloadPostRequest { syncDownloadScanRequest: SyncDownloadScanRequest; } export interface ScanSyncS3PostRequest { syncS3ScanRequest: SyncS3ScanRequest; } /** * */ export class AttachmentAVApi extends runtime.BaseAPI { /** * Download a file from a remote location (HTTP/HTTPS), scan the file, and post the scan result to your callback URL. */ async scanAsyncDownloadPostRaw(requestParameters: ScanAsyncDownloadPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['asyncDownloadScanRequest'] == null) { throw new runtime.RequiredError( 'asyncDownloadScanRequest', 'Required parameter "asyncDownloadScanRequest" was null or undefined when calling scanAsyncDownloadPost().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/async/download`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: AsyncDownloadScanRequestToJSON(requestParameters['asyncDownloadScanRequest']), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Download a file from a remote location (HTTP/HTTPS), scan the file, and post the scan result to your callback URL. */ async scanAsyncDownloadPost(requestParameters: ScanAsyncDownloadPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.scanAsyncDownloadPostRaw(requestParameters, initOverrides); } /** * Retrieve the scan result for scan job. */ async scanAsyncResultGetRaw(requestParameters: ScanAsyncResultGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['traceId'] == null) { throw new runtime.RequiredError( 'traceId', 'Required parameter "traceId" was null or undefined when calling scanAsyncResultGet().' ); } const queryParameters: any = {}; if (requestParameters['traceId'] != null) { queryParameters['trace_id'] = requestParameters['traceId']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/async/result`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue)); } /** * Retrieve the scan result for scan job. */ async scanAsyncResultGet(requestParameters: ScanAsyncResultGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.scanAsyncResultGetRaw(requestParameters, initOverrides); return await response.value(); } /** * Download a file from S3, scan the file, and post the scan result to your callback URL. A bucket policy is required to grant attachmentAV access to the S3 objects. */ async scanAsyncS3PostRaw(requestParameters: ScanAsyncS3PostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['asyncS3ScanRequest'] == null) { throw new runtime.RequiredError( 'asyncS3ScanRequest', 'Required parameter "asyncS3ScanRequest" was null or undefined when calling scanAsyncS3Post().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/async/s3`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: AsyncS3ScanRequestToJSON(requestParameters['asyncS3ScanRequest']), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Download a file from S3, scan the file, and post the scan result to your callback URL. A bucket policy is required to grant attachmentAV access to the S3 objects. */ async scanAsyncS3Post(requestParameters: ScanAsyncS3PostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.scanAsyncS3PostRaw(requestParameters, initOverrides); } /** * Upload a file, scan the file, and return the scan result. */ async scanSyncBinaryPostRaw(requestParameters: ScanSyncBinaryPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['body'] == null) { throw new runtime.RequiredError( 'body', 'Required parameter "body" was null or undefined when calling scanSyncBinaryPost().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/octet-stream'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/sync/binary`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters['body'] as any, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue)); } /** * Upload a file, scan the file, and return the scan result. */ async scanSyncBinaryPost(requestParameters: ScanSyncBinaryPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.scanSyncBinaryPostRaw(requestParameters, initOverrides); return await response.value(); } /** * Download a file from a remote location (HTTP/HTTPS), scan the file, and return the scan result. */ async scanSyncDownloadPostRaw(requestParameters: ScanSyncDownloadPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['syncDownloadScanRequest'] == null) { throw new runtime.RequiredError( 'syncDownloadScanRequest', 'Required parameter "syncDownloadScanRequest" was null or undefined when calling scanSyncDownloadPost().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/sync/download`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: SyncDownloadScanRequestToJSON(requestParameters['syncDownloadScanRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue)); } /** * Download a file from a remote location (HTTP/HTTPS), scan the file, and return the scan result. */ async scanSyncDownloadPost(requestParameters: ScanSyncDownloadPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.scanSyncDownloadPostRaw(requestParameters, initOverrides); return await response.value(); } /** * Download a file from S3, scan the file, and return the scan result. A bucket policy is required to grant attachmentAV access to the S3 objects. */ async scanSyncS3PostRaw(requestParameters: ScanSyncS3PostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['syncS3ScanRequest'] == null) { throw new runtime.RequiredError( 'syncS3ScanRequest', 'Required parameter "syncS3ScanRequest" was null or undefined when calling scanSyncS3Post().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/scan/sync/s3`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: SyncS3ScanRequestToJSON(requestParameters['syncS3ScanRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue)); } /** * Download a file from S3, scan the file, and return the scan result. A bucket policy is required to grant attachmentAV access to the S3 objects. */ async scanSyncS3Post(requestParameters: ScanSyncS3PostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.scanSyncS3PostRaw(requestParameters, initOverrides); return await response.value(); } /** * Get remaining credits and quota. */ async usageGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/usage`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UsageFromJSON(jsonValue)); } /** * Get remaining credits and quota. */ async usageGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.usageGetRaw(initOverrides); return await response.value(); } /** * Get information abour yourself. */ async whoamiGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // apiKeyAuth authentication } if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/whoami`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WhoamiFromJSON(jsonValue)); } /** * Get information abour yourself. */ async whoamiGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.whoamiGetRaw(initOverrides); return await response.value(); } }