public static AwsIamCertificateInstaller GetNewInstaller(IReadOnlyDictionary<string, object> initParams)
{
var inst = new AwsIamCertificateInstaller();
if (initParams == null)
initParams = new Dictionary<string, object>();
// Required params
if (!initParams.ContainsKey(SERVER_CERTIFICATE_NAME.Name))
throw new KeyNotFoundException($"missing required parameter [{SERVER_CERTIFICATE_NAME.Name}]");
inst.ServerCertificateName = (string)initParams[SERVER_CERTIFICATE_NAME.Name];
// Optional params
if (initParams.ContainsKey(PATH.Name))
inst.Path = (string)initParams[PATH.Name];
if (initParams.ContainsKey(USE_WITH_CLOUDFRONT.Name))
inst.UseWithCloudFront = (bool)initParams[USE_WITH_CLOUDFRONT.Name];
// Process the common params
inst.CommonParams.InitParams(initParams);
// Some validation
if (!string.IsNullOrEmpty(inst.Path))
{
if (!inst.Path.StartsWith(AwsIamCertificateInstaller.PATH_REQUIRED_PREFIX))
throw new ArgumentException($"optional Path argument must start with leading"
+ $" '{AwsIamCertificateInstaller.PATH_REQUIRED_PREFIX}'");
if (!inst.Path.EndsWith(AwsIamCertificateInstaller.PATH_REQUIRED_SUFFIX))
throw new ArgumentException($"optional Path argument must end with trailing"
+ $" '{AwsIamCertificateInstaller.PATH_REQUIRED_SUFFIX}'");
}
if (inst.UseWithCloudFront)
{
if (!string.IsNullOrEmpty(inst.Path))
{
if (!inst.Path.StartsWith(AwsIamCertificateInstaller.PATH_REQUIRED_CLOUDFRONT_PREFIX,
StringComparison.InvariantCultureIgnoreCase))
throw new ArgumentException($"optional Path argument must start with leading"
+ $" '{AwsIamCertificateInstaller.PATH_REQUIRED_CLOUDFRONT_PREFIX}'");
}
else
{
inst.Path = AwsIamCertificateInstaller.PATH_REQUIRED_CLOUDFRONT_PREFIX;
}
}
return inst;
}