CheckStringRegex() public static method

Method checks a string against a regular expression to match it conforms to API Standards
public static CheckStringRegex ( string inputName, string regularExpression, string actualValue ) : bool
inputName string name of the input to be identified when throwing errors
regularExpression string regular expression to match string against
actualValue string string to test - must match the regularExpression specified
return bool
コード例 #1
0
ファイル: User.cs プロジェクト: jmlewis1/RightScaleNetAPI
        /// <summary>
        /// Create a user. If a user already exists with the same email, that user will be returned.
        /// Creating a user alone will not enable the user to access this account. You have to create 'permissions' for that user before it can be used. Performing a 'show' on a new user will fail unless you immediately create an 'observer' permission on the current account.
        /// Note that information about users and their permissions must be propagated globally across all RightScale clusters, and this can take some time (less than 60 seconds under normal cirucmstances) so the users you create may not be able to login for a minute or two after you create them. However, you may create or destroy permissions for newly-created users with no delay.
        /// To create a user that will login using password authentication, include the 'password' parameter with your request.
        /// To create an SSO-enabled user, you must specify the identity_provider that will be vouching for this user's identity, as well as the principal_uid (SAML NameID or OpenID identity URL) that the identity provider will assert for this user. Identity providers should be specified by their API href; you can obtain a list of the identity providers available to your account by invoking the 'index' action of the identity_providers API resource.
        /// </summary>
        /// <param name="email">Email of user</param>
        /// <param name="firstName">First name of user</param>
        /// <param name="lastName">Last name of user</param>
        /// <param name="phone">Phone number for user</param>
        /// <param name="identityProviderID">The RightScale API href ID of the Identity Provider through which this user will login to RightScale. Required to create an SSO-authenticated user.</param>
        /// <param name="password">The password of this user. Required to create a password-authenticated user</param>
        /// <param name="principalUid">The principal identifier (SAML NameID or OpenID identity URL) of this user. Required to create an SSO-authenticated user</param>
        /// <returns></returns>
        public static string create(string email, string firstName, string lastName, string company, string phone, string password, string identityProviderID, string principalUid)
        {
            Utility.CheckStringHasValue(email);
            Utility.CheckStringHasValue(firstName);
            Utility.CheckStringHasValue(lastName);
            Utility.CheckStringHasValue(phone);
            Utility.CheckStringHasValue(company);
            List <KeyValuePair <string, string> > paramSet = new List <KeyValuePair <string, string> >();

            if (!string.IsNullOrWhiteSpace(phone))
            {
                string phoneValidationRegex = @"^\d+$";
                Utility.CheckStringRegex("phone", phoneValidationRegex, phone);
            }
            Utility.addParameter(email, "user[email]", paramSet);
            Utility.addParameter(firstName, "user[first_name]", paramSet);
            Utility.addParameter(company, "user[company]", paramSet);
            Utility.addParameter(lastName, "user[last_name]", paramSet);
            Utility.addParameter(phone, "user[phone]", paramSet);
            Utility.addParameter(string.Format(APIHrefs.IdentityProviderByID, identityProviderID), "user[identity_provider_href]", paramSet);
            Utility.addParameter(password, "user[password]", paramSet);
            Utility.addParameter(principalUid, "user[principal_uid]", paramSet);

            return(Core.APIClient.Instance.Post(APIHrefs.User, paramSet, "location").Last <string>().Split('/').Last <string>());
        }
コード例 #2
0
        /// <summary>
        /// Gives the raw monitoring data for a particular metric. The response will include different variables associated with that metric and the data points for each of those variables.
        /// To get the data for a certain duration, for e.g. for the last 10 minutes(600 secs), provide the variables start="-600" and end="0".
        /// </summary>
        /// <param name="cloudID">ID of the Cloud where the Instance can be found to gather MonitoringMetric data from</param>
        /// <param name="instanceID">ID of the Instance from which to gather MonitoringMetric data</param>
        /// <param name="metricID">Name/ID of the MonitoringMetric whose data is to be retrieved</param>
        /// <param name="endRefSecs">An integer number of seconds from current time e.g. -150 or 0</param>
        /// <param name="startRefSecs">An integer number of seconds from current time e.g. -300</param>
        /// <returns>Data for specific monitoring metric for the given instance between the reference times</returns>
        public static MonitoringMetricData data(string cloudID, string instanceID, string metricID, string endRefSecs, string startRefSecs)
        {
            string getHref = string.Format(APIHrefs.MonitoringMetricData, cloudID, instanceID, metricID);

            Utility.CheckStringHasValue(startRefSecs);
            Utility.CheckStringRegex("startRefSecs", monitoringMetricTimeRegex, startRefSecs);
            Utility.CheckStringHasValue(endRefSecs);
            Utility.CheckStringRegex("endRefSecs", monitoringMetricTimeRegex, endRefSecs);
            string queryString = string.Empty;

            queryString += string.Format("end={0}&", endRefSecs);
            queryString += string.Format("start={0}", startRefSecs);

            string jsonString = Core.APIClient.Instance.Get(getHref, queryString);

            return(MonitoringMetricData.deserialize(jsonString));
        }