public static CheckStringInput ( string inputName, List |
||
inputName | string | name of the input to be identified when throwing errors |
validViews | List |
list of strings representing valid values |
actualValue | string | string to test - must be one of those specified in |
return | bool |
public static List <ServerTemplate> index(List <Filter> filter, string view) { string getUrl = APIHrefs.ServerTemplate; string queryString = string.Empty; if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "description", "multi_cloud_image_href", "name", "revision" }; Utility.CheckFilterInput("filter", validFilters, filter); string jsonString = Core.APIClient.Instance.Get(getUrl, queryString); return(deserializeList(jsonString)); }
public static List <InstanceCustomLodgement> index(List <Filter> filter, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "timeframe" }; Utility.CheckFilterInput("filter", validFilters, filter); //TODO: implement InstanceCustomLodgement.index throw new NotImplementedException(); }
/// <summary> /// Lists instance types. /// </summary> /// <param name="cloudID">ID of the cloud to enumerate instance types for</param> /// <param name="filter">Collection of filters for limiting the return set</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>Collection of InstanceTypes</returns> public static List <InstanceType> index(string cloudID, List <Filter> filter, string view) { string getHref = string.Format(APIHrefs.InstanceType, cloudID); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "cpu_architecture", "description", "name", "resource_uid" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = string.Empty; if (filter != null && filter.Count > 0) { queryString += Utility.BuildFilterString(filter); } queryString += string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserializeList(jsonString)); }
public static RightScripts show_rightscripts(string rightscriptId, string view) { string getURL = string.Format(APIHrefs.RightScriptByID, rightscriptId); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getURL, queryString); //return deserializeList(jsonString); RightScripts rsScrpts = Newtonsoft.Json.JsonConvert.DeserializeObject <RightScripts>(jsonString); return(rsScrpts); //RightScripts tess = JsonConvert.DeserializeObject<RightScripts>(jsonString); }
/// <summary> /// Private static method responsible for calling http client and performing get for all index calls /// </summary> /// <param name="filter">list of keyvaluepairs for filtering get request</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <param name="getHref">API href for GET to be performed on</param> /// <returns>Collection of Server objects</returns> private static List <Server> indexGet(List <Filter> filter, string view, string getHref) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "instance_detail" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "cloud_href", "deployment_href", "name" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = string.Empty; if (filter != null) { foreach (Filter f in filter) { queryString += f.ToString() + "&"; } } queryString += string.Format("view={0}", view); return(GetObjectListByHref(getHref, queryString)); }
//public static List<Input> index() //{ // return index(null,null); //} public static List <RunnableBindings> index_servertemplate(string serverTemplatetId, string view) { string getURL = string.Format(APIHrefs.ServerTemplateRunnableBindings, serverTemplatetId); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getURL, queryString); return(deserializeList(jsonString)); }
/// <summary> /// Internal implementation of show for both deployment and non-deployment calls. /// </summary> /// <param name="getHref"></param> /// <param name="view"></param> /// <returns>ServerTemplate object with data</returns> private static ServerTemplate showGet(string getHref, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } List <string> validViews = new List <string>() { "default", "inputs", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Private implementation to centrally manage all calls to index AlertSpecs /// </summary> /// <param name="getHref">RightScale API Href fragment for indexing AlertSpecs</param> /// <param name="filter">Filters for querying AlertSpecs</param> /// <param name="view">View name for querying AlertSpecs</param> /// <returns>collection of AlertSpecs</returns> private static List <AlertSpec> indexGet(string getHref, List <Filter> filter, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "description", "escalation_name", "name", "subject_href" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = Utility.BuildFilterString(filter); if (!string.IsNullOrEmpty(view)) { queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserializeList(jsonString)); }
public bool Refresh(string view) { bool retVal = false; if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "extended" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(getLinkValue("self"), queryString); Newtonsoft.Json.JsonConvert.PopulateObject(jsonString, this); retVal = true; return(retVal); }
public static List <VolumeSnapshot> index(string cloudID, List <Filter> filter, string view) { //GET /api/clouds/:cloud_id/volumes/:volume_id/volume_snapshots //GET /api/clouds/:cloud_id/volume_snapshots string getHref = string.Format(APIHrefs.VolumeSnapshots, cloudID); string queryString = string.Empty; if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "description", "name", "parent_volume_href", "resource_uid" }; Utility.CheckFilterInput("filter", validFilters, filter); string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserializeList(jsonString)); }
/// <summary> /// Lists deployments of the account. /// Using the available filters, one can select or group which deployments to retrieve. The 'inputs20' view is for retrieving inputs in 2.0 serialization /// </summary> /// <param name="filter">list of KeyValuePair(string,string) to use as filters to query for deployments</param> /// <param name="view">name of the view to be returned</param> /// <returns>collection of Deployment objects</returns> public static List <Deployment> index(List <Filter> filter, string view) { string getHref = APIHrefs.Deployment; if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "description", "name", "server_tag_scope" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryStringValue = string.Empty; queryStringValue += string.Format("view={0}&", view); queryStringValue += Utility.BuildFilterString(filter); string jsonString = Core.APIClient.Instance.Get(getHref, queryStringValue); return(deserializeList(jsonString)); }
public static List <Input> index_instance(string cloudid, string instanceid, string view) { string getURL = string.Format(APIHrefs.InstanceInput, cloudid, instanceid); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getURL, queryString); return(deserializeList(jsonString)); }
public static List <RecurringVolumeAttachment> index(List <Filter> filter, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "runnable_href", "storage_href" }; Utility.CheckFilterInput("filter", validFilters, filter); //TODO: implement RecurringVolumeAttachment.index throw new NotImplementedException(); }
/// <summary> /// Updates attributes of a given deployment. /// </summary> /// <param name="deploymentID">ID of the deployment to update</param> /// <param name="name">The updated name for the deployment</param> /// <param name="description">The updated description for the deployment</param> /// <param name="server_tag_scope">The routing scope for tags for servers in the deployment</param> /// <returns>True if update successful, false if not</returns> public static bool update(string deploymentID, string name, string description, string server_tag_scope) { Utility.CheckStringHasValue(deploymentID); string putHref = string.Format(APIHrefs.DeploymentByID, deploymentID); List <KeyValuePair <string, string> > updateParams = new List <KeyValuePair <string, string> >(); if (!string.IsNullOrWhiteSpace(name)) { updateParams.Add(new KeyValuePair <string, string>("deployment[name]", name)); } if (!string.IsNullOrWhiteSpace(description)) { updateParams.Add(new KeyValuePair <string, string>("deployment[description]", description)); } if (!string.IsNullOrWhiteSpace(server_tag_scope)) { List <string> validValues = new List <string>() { "deployment", "account" }; Utility.CheckStringInput("server_tag_scope", validValues, server_tag_scope); updateParams.Add(new KeyValuePair <string, string>("deployment[server_tag_scope]", server_tag_scope)); } if (updateParams.Count > 0) { return(Core.APIClient.Instance.Put(putHref, updateParams)); } else { return(false); } }
/// <summary> /// Helper method to return a valid view value for SecurityGroupRule api calls /// </summary> /// <param name="view">view value to be tested</param> /// <returns>value of input view or default view if input is null or empty</returns> private static string getValidView(string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } return(view); }
/// <summary> /// Internal implementation of show for both deployment and non-deployment calls. /// </summary> /// <param name="getHref"></param> /// <param name="view"></param> /// <returns>Server object with data</returns> private static Server showGet(string getHref, string view) { List <string> validViews = new List <string>() { "default", "instance_detail" }; Utility.CheckStringInput("view", validViews, view); string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("view={0}", view); } return(GetObjectByHref(getHref, queryString)); }
/// <summary> /// Lists the attributes of a given deployment /// </summary> /// <param name="deploymentID">ID of the deployment to show</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>Deployment specified by ID</returns> public static Deployment show(string deploymentID, string view) { string getHref = string.Format(APIHrefs.DeploymentByID, deploymentID); string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { List <string> validViews = new List <string>() { "default", "inputs", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Displays information about a single Instance type. /// </summary> /// <param name="cloudID">ID of the cloud where the InstanceType can be found</param> /// <param name="instanceTypeID">ID of the specific InstanceType to be returned</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>Specific instance of InstanceType</returns> public static InstanceType show(string cloudID, string instanceTypeID, string view) { string getHref = string.Format(APIHrefs.InstanceTypeByID, cloudID, instanceTypeID); string queryString = string.Empty; if (!string.IsNullOrWhiteSpace(view)) { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); queryString += string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Shows the information of a single image. /// </summary> /// <param name="serverid">ID of the image to be retrieved</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include.</param> /// <returns>Populated Image object</returns> public static Image show(string cloudID, string imageID, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } string getHref = string.Format(APIHrefs.ImageByID, cloudID, imageID); return(showGet(getHref, view)); }
/// <summary> /// Shows the information of a single image. /// </summary> /// <param name="servertemplateid">ID of the image to be retrieved</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include.</param> /// <returns>Populated Image object</returns> public static ServerTemplate show(string servertemplateid, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "inputs", "inputs_2_0" }; Utility.CheckStringInput("view", validViews, view); } string getHref = string.Format(APIHrefs.ServerTemplateByID, servertemplateid); return(showGet(getHref, view)); }
/// <summary> /// Displays information about a single volume /// </summary> /// <param name="cloudID">Cloud ID where the volume can be found</param> /// <param name="volumeID">ID of the volume to show</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>populated instance of Volume object</returns> public static Volume show(string cloudID, string volumeID, string view) { string getHref = string.Format(APIHrefs.VolumeByID, cloudID, volumeID); string queryString = string.Empty; if (view != null) { List <string> validViews = new List <string>() { "default", "extended" }; Utility.CheckStringInput("view", validViews, view); queryString = string.Format("view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Medhod builds a task object based on the task href specified /// </summary> /// <param name="taskHref">Task Href to populate instance of task</param> /// <param name="view"></param> /// <returns>Populated Task object</returns> public static Task show(string taskHref, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default", "extended" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(taskHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Private method for centralizing logic for getting a VolumeAttachment object /// </summary> /// <param name="getHref">href fragment for making calls to the RSAPI</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>Instance of VolumeAttachment</returns> private static VolumeAttachment showGet(string getHref, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } string queryStringValue = string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(getHref, queryStringValue); return(deserialize(jsonString)); }
/// <summary> /// Private method validates formatting if values exist for inputs /// </summary> /// <param name="condition">The condition (operator) in the condition sentence.</param> /// <param name="vote_type">Vote to grow or shrink a ServerArray when the alert is triggered. Must either escalate or vote</param> private static void checkInputFormatting(string condition, string vote_type) { List <string> validVote_types = new List <string>() { "grow", "shrink" }; List <string> validConditions = new List <string>() { ">", ">=", "<", "<=", "==", "!=" }; if (!string.IsNullOrWhiteSpace(condition)) { Utility.CheckStringInput("condition", validConditions, condition); } if (!string.IsNullOrWhiteSpace(vote_type)) { Utility.CheckStringInput("vote_type", validVote_types, vote_type); } }
/// <summary> /// Displays information about a single Volume /// </summary> /// <param name="cloudID">ID of the cloud</param> /// <param name="volumeTypeID">ID of the VolumeType</param> /// <param name="view">Specifies how many attributes or relationships to include</param> /// <returns>Populated instance of VolumeType</returns> public static VolumeType show(string cloudID, string volumeTypeID, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Format("view={0}", view); string getString = string.Format(APIHrefs.VolumeTypeByID, cloudID, volumeTypeID); string jsonString = Core.APIClient.Instance.Get(getString, queryString); return(deserialize(jsonString)); }
/// <summary> /// Lists all Datacenters for a particular cloud. /// </summary> /// <param name="cloudID">ID of cloud to enumerate DataCenters for</param> /// <param name="filter">Filter set to limit return data</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include.</param> /// <returns>Collection of DataCenter objects</returns> public static List <DataCenter> index(string cloudID, List <Filter> filter, string view) { string getHref = string.Format(APIHrefs.DataCenter, cloudID); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "name", "resource_uid" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = string.Empty; queryString += Utility.BuildFilterString(filter); if (!string.IsNullOrWhiteSpace(view)) { queryString += string.Format("&view={0}", view); } string jsonString = Core.APIClient.Instance.Get(getHref, queryString); if (jsonString.ToLower().Contains("unsupported resource")) { throw new RightScaleAPIException("RightScale API Unsupported Exception", getHref + queryString, jsonString); } return(deserializeList(jsonString)); }
/// <summary> /// Show information about a single publication lineage. Only non-HEAD revisions are possible. /// </summary> /// <param name="publicationLineageID">ID of Publication Lineage to retrieve</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>Instance of a PublicationLineage object for the ID passed in</returns> public PublicationLineage show(string publicationLineageID, string view) { string getHref = string.Format(APIHrefs.PublicationLineageByID, publicationLineageID); if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } string queryString = string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserialize(jsonString)); }
/// <summary> /// Lists Volume Types /// </summary> /// <param name="cloudID">ID of cloud where volume types are to be listed</param> /// <param name="filter">limites return set based on provided filter parameters</param> /// <param name="view">Specifies how many attributes and/or expanded nested relationships to include</param> /// <returns>List of VolumeTypes</returns> public static List <VolumeType> index(string cloudID, List <Filter> filter, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "name", "resource_uid" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = string.Format("view={0}&", view); if (filter != null) { foreach (Filter f in filter) { queryString += f.ToString() + "&"; } } queryString = queryString.TrimEnd('&'); string getHref = string.Format(APIHrefs.VolumeType, cloudID); string jsonString = Core.APIClient.Instance.Get(getHref, queryString); return(deserializeList(jsonString)); }
/// <summary> /// Show information about a single AccountGroup /// </summary> /// <param name="accountGroupID">ID of the AccountGroup to retrieve</param> /// <param name="view">Specific view of AccountGroup to filter result set</param> /// <returns>instance of AccountGroup based on inputs</returns> public static AccountGroup show(string accountGroupID, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); Utility.CheckStringIsNumeric(accountGroupID); string getURL = string.Format(APIHrefs.AccountGroupByID, accountGroupID); string queryString = string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(getURL, queryString); return(deserialize(jsonString)); }
/// <summary> /// Lists the publications available to this account. Only non-HEAD revisions are possible. /// </summary> /// <param name="filter">List of filters to modify the return set from API</param> /// <param name="view">Specifies how many attributes and/or expanded nexted relationships to include.</param> /// <returns>List of RightScale publications</returns> public static List <Publication> index(List <Filter> filter, string view) { if (string.IsNullOrWhiteSpace(view)) { view = "default"; } else { List <string> validViews = new List <string>() { "default" }; Utility.CheckStringInput("view", validViews, view); } List <string> validFilters = new List <string>() { "description", "name", "publisher", "revision" }; Utility.CheckFilterInput("filter", validFilters, filter); string queryString = string.Empty; if (filter != null && filter.Count > 0) { foreach (Filter f in filter) { queryString += f.ToString() + "&"; } } queryString += string.Format("view={0}", view); string jsonString = Core.APIClient.Instance.Get(APIHrefs.Publication, queryString); return(deserializeList(jsonString)); }