Beispiel #1
0
 private void ValidateRequest(Ec2Request parms)
 {
     if (!IsNullRequest(parms))
     {
         if (!AwsServices.IsValidRegion(parms.Region))
         {
             throw new Exception("AWS region is not valid.");
         }
         if (!IsValidCloudEnvironment(parms.CloudEnvironment))
         {
             throw new Exception("Cloud environment can not be found.");
         }
         if (!IsValidAction(parms.Action))
         {
             throw new Exception("Request action is not valid.");
         }
         if (!SetReturnFormat(parms.ReturnFormat))
         {
             throw new Exception("Valid return formats are json, xml or yaml.");
         }
         if (!Utilities.IsValidXml(parms.Xslt))
         {
             throw new Exception("XSLT is not well-formed.");
         }
     }
     else
     {
         throw new Exception("No parameter is found in the request.");
     }
 }
    private bool ValidateRequest(ResizeDetail parms)
    {
        bool areValid = true;

        if (!IsNullRequest(parms))
        {
            if (!IsValidEnvironment(parms.Environment))
            {
                UpdateProgress("Environment can not be found.");
                areValid = false;
            }
            if (!AwsServices.IsValidRegion(parms.Region))
            {
                UpdateProgress("AWS region is not valid.");
                areValid = false;
            }
            if (!AwsServices.IsValidInstanceType(parms.NewInstanceType))
            {
                UpdateProgress("EC2 instance type is not valid.");
                areValid = false;
            }
            if (!SetReturnFormat(parms.ReturnFormat))
            {
                UpdateProgress("Valid return formats are json, xml or yaml.");
                areValid = false;
            }
        }
        else
        {
            UpdateProgress("No parameter is found in the request.");
            areValid = false;
        }

        return(areValid);
    }