@finos/legend-graph
Version:
Legend graph and graph manager
59 lines • 2.65 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { usingConstantValueSchema, usingModelSchema, } from '@finos/legend-shared';
import { V1_IngestDefinition } from '../../../model/packageableElements/ingest/V1_IngestDefinition.js';
import { V1_AppDirNodeModelSchema } from './V1_EntitlementSerializationHelper.js';
import { createModelSchema, deserialize, primitive } from 'serializr';
import { V1_AWSSnowflakeIngestEnvironment, V1_IngestEnvironmentType, } from '../../../lakehouse/ingest/V1_LakehouseIngestEnvironment.js';
export const V1_createIngestDef = (name, packagePath, json) => {
const ingestDef = new V1_IngestDefinition();
const jsonType = json;
const appDir = jsonType.appDirDeployment ??
jsonType.owner?.prodParallel ??
jsonType.owner?.production;
ingestDef.name = name;
ingestDef.appDirDeployment = appDir
? deserialize(V1_AppDirNodeModelSchema, appDir)
: undefined;
ingestDef.package = packagePath;
ingestDef.content = json;
return ingestDef;
};
export const V1_AWSSnowflakeIngestEnvironmentModelSchema = createModelSchema(V1_AWSSnowflakeIngestEnvironment, {
_type: usingConstantValueSchema(V1_IngestEnvironmentType.AWSSnowflake),
urn: primitive(),
version: primitive(),
environmentClassification: primitive(),
producers: usingModelSchema(V1_AppDirNodeModelSchema),
awsRegion: primitive(),
awsAccountId: primitive(),
ingestStepFunctionsAvtivityArn: primitive(),
ingestStateMachineArn: primitive(),
ingestSystemAccount: primitive(),
snowflakeAccount: primitive(),
snowflakeHost: primitive(),
s3StagingBucketName: primitive(),
storageIntegrationName: primitive(),
});
export const V1_deserializeIngestEnvironment = (json) => {
switch (json._type) {
case V1_IngestEnvironmentType.AWSSnowflake:
return deserialize(V1_AWSSnowflakeIngestEnvironmentModelSchema, json);
default:
throw new Error(`Unknown V1_IngestEnvironment type: ${json._type}`);
}
};
//# sourceMappingURL=V1_IngestSerializationHelper.js.map