accountGroupHrefByID() public static method

Helper method returns a properly formatted account group href for a specific account group
public static accountGroupHrefByID ( string accountGroupID ) : string
accountGroupID string ID of account group
return string
Ejemplo n.º 1
0
        /// <summary>
        /// Publishes a given ServerTemplate and its subordinates
        /// </summary>
        /// <param name="serverTemplateID">ID of the ServerTemplate to publish</param>
        /// <param name="accountGroupIDs">Collection of Account Group IDs to publish to </param>
        /// <param name="allowComments">Allow users to leave comments on this ServerTemplate</param>
        /// <param name="description">Description for this publish</param>
        /// <param name="email_comments">Email me when a user comments on this ServerTemplate</param>
        /// <param name="categories">List of Categories</param>
        /// <returns>ID of the newly created publication</returns>
        public static string publish(string serverTemplateID, List <string> accountGroupIDs, bool allowComments, Description description, bool email_comments, List <string> categories)
        {
            string postHref = string.Format(APIHrefs.ServerTemplatePublish, serverTemplateID);
            List <KeyValuePair <string, string> > postParams = new List <KeyValuePair <string, string> >();

            if (accountGroupIDs != null && accountGroupIDs.Count > 0)
            {
                foreach (string accountGroupID in accountGroupIDs)
                {
                    Utility.addParameter(Utility.accountGroupHrefByID(accountGroupID), "account_group_hrefs[]", postParams);
                }
            }

            Utility.addParameter(allowComments.ToString().ToLower(), "allow_comments", postParams);

            if (categories != null && categories.Count > 0)
            {
                foreach (string category in categories)
                {
                    Utility.addParameter(category, "categories[]", postParams);
                }
            }

            if (description != null)
            {
                postParams.AddRange(description.descriptionParameters("descriptions[{0}]"));
            }

            Utility.addParameter(email_comments.ToString().ToLower(), "email_comments", postParams);

            return(Core.APIClient.Instance.Post(postHref, postParams, "location").Last <string>().Split('/').Last <string>());
        }