"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigDoc = exports.FileStoreTypeEnum = exports.AwsSecretStore = exports.AwsSecretStoreDef = exports.AzureKeyVault = exports.AzureKeyVaultDef = exports.SecretStore = exports.SecretStoreDef = exports.KvpStoreDef = exports.KvpStoreInfrx = exports.CloudResourceInstance = exports.KvpStoreTypesEnum = void 0;
const contracts_1 = require("@codiac.io/codiac-common/contracts");
const contracts_2 = require("../../apis/codiac-relay/contracts");
// COmmented out bc: use the relay api client contracts instead.
// /** Identifier for a supported cloud service provider, for use in selecting infrastructure clients, provisioners, and credentials. */
// export enum CloudProviderEnum {
//   "azure" = "azure",
//   "aws" = "aws",
//   "dockerHub" = "dockerHub",
//   "other" = "other"
// }
/** List of codenames for supported KeyValue stores.
 * eg: Clients for these types of stores are registered under these values.  */
var KvpStoreTypesEnum;
(function (KvpStoreTypesEnum) {
    KvpStoreTypesEnum["azKeyVault"] = "azKeyVault";
    KvpStoreTypesEnum["awsKeyVault"] = "awsKeyVault";
    KvpStoreTypesEnum["azBlob"] = "azBlob";
    KvpStoreTypesEnum["mongoCollection"] = "mongoCollection";
    KvpStoreTypesEnum["mongoDocument"] = "mongoDocument";
    KvpStoreTypesEnum["etcd"] = "etcd";
})(KvpStoreTypesEnum = exports.KvpStoreTypesEnum || (exports.KvpStoreTypesEnum = {}));
/** Identifying and access information for a living, breathing, concrete instance
 * of a key value store resource in a cloud provider subscription. */
class CloudResourceInstance /* implements ICloudResourceInstance, IDomainEntity, IAuditable */ {
    /**
     * @param name The friendly, human-readable identifier of this resource,
     *  as it is known by the cloud provider.
     *  Its name is unique only within the resource group containing the instance,
     *  and it necessarily matches the name of the definition from which it was spawned.
     * @param provider  The third party cloud service provider that is hosting this resource.
     * @param resourceId The Id given by the csp.
     * @param id The id assigned to this entity by the codiac database.
     */
    constructor(name, provider
    // , public location: string, public providerSubscription: string
    // , public resourceGroupName: string
    , resourceId, id, modified, modifiedBy, created, createdBy) {
        this.name = name;
        this.provider = provider;
        this.resourceId = resourceId;
        this.id = id;
        this.created = created || new Date(Date.now());
        this.createdBy = createdBy || "unknown";
        this.modified = modified || this.created;
        this.modifiedBy = modifiedBy || this.createdBy;
    }
}
exports.CloudResourceInstance = CloudResourceInstance;
// SECRET STORES
class KvpStoreInfrx extends CloudResourceInstance {
    constructor(name, provider, type, resourceId, id, modified, modifiedBy, created, createdBy) {
        super(name, provider, resourceId, id, modified, modifiedBy, created, createdBy);
        this.type = type;
    }
}
exports.KvpStoreInfrx = KvpStoreInfrx;
/** The specs for a key value store to be managed by the codiac system.
 * This class is used to programmatically put up and take down concrete key value stores. */
class KvpStoreDef /* implements IDomainEntity, IAuditable, ICloudResourceDef<KvpStoreInfrx, KvpStoreTypesEnum> */ {
    /**
     * @param name  The friendly identifying name under which the key value store resource is registered within an enterprise.  The concrete instance that gets created will use this name (if the instance exists already, this property must match the name of the concrete instance).
     * @param type  Differentiator for key value store resources (eg: KeyVault, etcd, mongo, etc) and their various implementations.
     * @param instance  Info describing the concrete instance of this kvp store actually living within a cloud provider subscription.
     */
    constructor(name, provider, type, instance, id, modified, modifiedBy, created, createdBy) {
        this.name = name;
        this.provider = provider;
        this.type = type;
        this.instance = instance;
        this.id = id;
        this.created = created || new Date(Date.now());
        this.createdBy = createdBy || "unknown";
        this.modified = modified || this.created;
        this.modifiedBy = modifiedBy || this.createdBy;
    }
}
exports.KvpStoreDef = KvpStoreDef;
/** Representation of a secret store managed service on a cloud provider.
 */
class SecretStoreDef extends KvpStoreDef /* implements IDomainEntity, IAuditable */ {
    constructor(name, provider, type, instance, id, modified, modifiedBy, created, createdBy) {
        super(name, provider, type, instance, id, modified, modifiedBy, created, createdBy);
    }
}
exports.SecretStoreDef = SecretStoreDef;
class SecretStore extends KvpStoreInfrx {
    constructor(name, resourceId, provider, type, id, modified, modifiedBy, created, createdBy) {
        super(name, provider, type, resourceId, id, modified, modifiedBy, created, createdBy);
    }
}
exports.SecretStore = SecretStore;
class AzureKeyVaultDef extends SecretStoreDef {
    constructor(name, resourceGroup, tenantId, subscriptionId, location, azVaultSku = "standard", instance) {
        super(name, contracts_2.CloudProviderEnum.azure, KvpStoreTypesEnum.azKeyVault, instance);
        this.resourceGroup = resourceGroup;
        this.tenantId = tenantId;
        this.subscriptionId = subscriptionId;
        this.location = location;
        this.azVaultSku = azVaultSku;
        this.instance = instance;
    }
}
exports.AzureKeyVaultDef = AzureKeyVaultDef;
class AzureKeyVault extends SecretStore {
    constructor(name, resourceId, resourceGroup, tenantId, subscriptionId, location, vaultUri) {
        super(name, resourceId, contracts_2.CloudProviderEnum.azure, KvpStoreTypesEnum.azKeyVault);
        this.resourceGroup = resourceGroup;
        this.tenantId = tenantId;
        this.subscriptionId = subscriptionId;
        this.location = location;
        this.vaultUri = vaultUri;
    }
}
exports.AzureKeyVault = AzureKeyVault;
class AwsSecretStoreDef extends SecretStoreDef {
    constructor(name, accountId, region, instance) {
        super(name, contracts_2.CloudProviderEnum.aws, KvpStoreTypesEnum.awsKeyVault, instance);
        this.accountId = accountId;
        this.region = region;
        this.instance = instance;
    }
}
exports.AwsSecretStoreDef = AwsSecretStoreDef;
class AwsSecretStore extends SecretStore {
    constructor(name, resourceId, accountId, region) {
        super(name, resourceId, contracts_2.CloudProviderEnum.aws, KvpStoreTypesEnum.awsKeyVault);
        this.accountId = accountId;
        this.region = region;
    }
}
exports.AwsSecretStore = AwsSecretStore;
// export class StorageAccount /* implements IStorageAccount, IDomainEntity */ {
//   constructor(public name: string, public location: string, public primaryEndpoints: IStorageAccountEndpointUrls, id?: string) {
//     this.id = id;
//   }
//   public id: string | undefined;
// }
// export class StorageAccountKey {
//   constructor(public keyName: string, public permissions: "Full" | "Read", public value: string) {
//   }
// }
/** Supported file store adapters that can be mapped to a reserved folder on an asset. */
var FileStoreTypeEnum;
(function (FileStoreTypeEnum) {
    FileStoreTypeEnum["azureFileStorage"] = "AzureFileStorage";
    FileStoreTypeEnum["azureBlobStorage"] = "AzureBlobStorage";
    FileStoreTypeEnum["azureDisk"] = "AzureDisk";
    FileStoreTypeEnum["hostMachineFolder"] = "HostMachineFolder";
})(FileStoreTypeEnum = exports.FileStoreTypeEnum || (exports.FileStoreTypeEnum = {}));
// /** Abstraction and specification for a share on a file store, 
//  *  to be mapped to a reserved folder on an asset.
//  * 
//  *  This class can be used as the specification 
//  *  to programmatically put up and take down concrete file stores.  
//  *  As such, it outlives the actual entity described by its "instance" property.  
//  *     
//  * @param name  The name by which to identify this fileshare definition within the enterprise (Optional: defaults to the shareName).
//  * @param type  Indicator of which type of fileshare resource is being used.
//  * @param storageAccount  The name within the cloud provider of the file storage account within which the share resides.
//  * @param shareName  The name of the fileshare to connect to within the file storage account.
//  * @param providerSubscriptionId The Id of the physical Cloud Provider Subscription in which this filestore exists (Azure-specific). 
//  * @param resourceGroup  The name of the Azure resource group under which the instance is to be created  (Azure-specific).
//  * @param instance  Info describing the concrete instance of this file store actually living within a cloud provider subscription.
//  */
// export class FileStoreDef /* implements IDomainEntity, IAuditable */ {
//   constructor(public name: string
//     , public type: FileStoreTypeEnum
//     , public storageAccount: string
//     , public shareName: string
//     , public providerSubscriptionId: string
//     , public resourceGroup: string
//     , public instance?: FileStoreInfrx
//     , id?: string
//     , modified?: Date, modifiedBy?: string, created?: Date, createdBy?: string) {
//     this.id = id;
//     this.created = created || new Date(Date.now());
//     this.createdBy = createdBy || "unknown";
//     this.modified = modified || this.created;
//     this.modifiedBy = modifiedBy || this.createdBy;
//   }
//   public id: string | undefined;
//   // IAuditable properties
//   public createdBy: string;
//   public modifiedBy: string;
//   public created: Date;
//   public modified: Date;
// }
// /** Metadata describing an existing concrete instance
// *  of a FileStoreDef resource within a cloud provider.  */
// export class FileStoreInfrx {
//   /**
//    * @param providerSubscriptionId The Id of the physical Cloud Provider Subscription in which this filestore exists (Azure-specific).
//    * @param resourceGroup Name of the Azure resource group containing the filestore itself (Azure-specific).
//    * @param resourceId The unique identifier given by the cloud provider to the file storage account.
//    * @param accessKey The key generated upon creation of the FileStore, to enable the consumer to attach to it.
//    */
//   constructor(public providerSubscriptionId: string, public resourceGroup: string, public resourceId: string, public accessKey: string) {
//   }
// }
// export class FileStoreDefCriteria extends CriteriaBase<FileStoreDef> {
//   constructor(
//     public name?: StringFilter,
//     public type?: FileStoreTypeEnum,
//     public shareName?: StringFilter,
//     public providerSubscriptionId?: StringFilter
//   ) {
//     super()
//   }
// }
// CONFIGS
/** An object representation of a config file, assembled from ScopedSettings.
 * This document can take any form, and is constructed solely from settings and values,
 * with all meta information omitted to preserve the integrity of the ultimate config file.
 * NOTE: To view the list of un-smashed settings with metadata from which this document is assembled,
 * fire the same request object against the ScopedSetting endpoint.  */
class ConfigDoc /* implements IConfigDoc, IDomainEntity */ {
    constructor(id) {
        this.id = id;
    }
}
exports.ConfigDoc = ConfigDoc;
//# sourceMappingURL=contracts.js.map