/// <summary> /// Remove a routing rule condition from a routing rule in the Connection directory. /// </summary> /// <param name="pConnectionServer"> /// Connection server being edited /// </param> /// <param name="pRoutingRuleObjectId"> /// ObjectId of the routing rule that owns the condition to be deleted /// </param> /// <param name="pObjectId"> /// ObjectId of the routing rule condition to be removed. /// </param> /// <returns> /// Instance of the WebCallResult class /// </returns> public static WebCallResult DeleteRoutingRuleCondition(ConnectionServerRest pConnectionServer, string pRoutingRuleObjectId, string pObjectId) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer reference passed to DeleteRoutingRuleCondition"; return(res); } if (string.IsNullOrEmpty(pRoutingRuleObjectId)) { res.ErrorText = "Empty RoutingRuleObjectId passed to DeleteRoutingRuleCondition"; return(res); } if (string.IsNullOrEmpty(pObjectId)) { res.ErrorText = "Empty ObjectId passed to DeleteRoutingRuleCondition"; return(res); } return(pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules/" + pRoutingRuleObjectId + "/routingruleconditions/" + pObjectId, MethodType.DELETE, "")); }
/// <summary> /// Removes a role assignment from a user. Returns a failure response if that user does not have the role assigned to them. /// </summary> /// <param name="pConnectionServer" type="Cisco.UnityConnection.RestFunctions.ConnectionServerRest"> /// Connection server that the user being edited lives on. /// </param> /// <param name="pUserObjectId" type="string"> /// Unique ID of the user to remove the role from /// </param> /// <param name="pRoleObjectId" type="string"> /// unique Id of the role to remove from the user - this is the unique id of the user's role mapping, not the id of the role in the system. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult RemoveRoleFromUser(ConnectionServerRest pConnectionServer, string pUserObjectId, string pRoleObjectId) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to RemoveRoleFromUser"; return(res); } if (string.IsNullOrEmpty(pUserObjectId)) { res.ErrorText = "Empty user ObjectId passed to RemoveRoleFromUser"; return(res); } if (string.IsNullOrEmpty(pRoleObjectId)) { res.ErrorText = "Empty role ObjectId passed to RemoveRoleFromUser"; return(res); } return(pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/userroles/{2}", pConnectionServer.BaseUrl, pUserObjectId, pRoleObjectId), MethodType.DELETE, "", false)); }
/// <summary> /// Gets the list of all schedule sets and resturns them as a generic list of ScheduleSet objects. /// </summary> /// <param name="pConnectionServer"> /// The Connection server object that references the server the schedulesets should be pulled from /// </param> /// <param name="pScheduleSets"> /// Out parameter that is used to return the list of ScheduleSet objects defined on Connection - there must be at least one. /// </param> /// <param name="pPageNumber"> /// Results page to fetch - defaults to 1 /// </param> /// <param name="pRowsPerPage"> /// Results to return per page, defaults to 20 /// </param> /// <param name="pClauses"> /// Zero or more strings can be passed for clauses (filters, sorts, page directives). Only one query and one sort parameter /// at a time are currently supported by CUPI - in other words you can't have "query=(alias startswith ab)" in /// the same call. Also if you have a sort and a query clause they must both reference the same column. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetSchedulesSets(ConnectionServerRest pConnectionServer, out List<ScheduleSet> pScheduleSets, int pPageNumber = 1, int pRowsPerPage = 20, params string[] pClauses) { WebCallResult res; pScheduleSets = new List<ScheduleSet>(); if (pConnectionServer == null) { res = new WebCallResult(); res.ErrorText = "Null ConnectionServer referenced passed to GetSchedulesSets"; return res; } List<String> oParams; if (pClauses == null) { oParams = new List<string>(); } else { oParams = pClauses.ToList(); } oParams.Add("pageNumber=" + pPageNumber); oParams.Add("rowsPerPage=" + pRowsPerPage); string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "schedulesets",oParams.ToArray()); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return res; } if (string.IsNullOrEmpty(res.ResponseText)) { res.ErrorText = "Empty response received"; res.Success = false; return res; } //no error here - just return the empty list. if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25) { return res; } pScheduleSets = pConnectionServer.GetObjectsFromJson<ScheduleSet>(res.ResponseText); //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pScheduleSets) { oObject.HomeServer = pConnectionServer; } return res; }
/// <summary> /// Allows one or more properties on an external service to be udpated. The caller needs to construct a list of property /// names and new values using the ConnectionPropertyList class's "Add" method. At least one property pair needs to be passed in /// but as many as are desired can be included in a single call. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the service is homed. /// </param> /// <param name="pObjectId"> /// Unique identifier for the external service to update. /// </param> /// <param name="pPropList"> /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the object /// being updated. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult UpdateExternalService(ConnectionServerRest pConnectionServer, string pObjectId, ConnectionPropertyList pPropList) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to UpdateExternalService"; return(res); } if (pPropList == null || pPropList.Count < 1) { res.ErrorText = "empty property list passed to UpdateExternalService"; return(res); } string strBody = "<ExternalService>"; foreach (var oPair in pPropList) { strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue); } strBody += "</ExternalService>"; return(pConnectionServer.GetCupiResponse(string.Format("{0}externalservices/{1}", pConnectionServer.BaseUrl, pObjectId), MethodType.PUT, strBody, false)); }
/// <summary> /// DELETE an alternate extension associated with a user. /// </summary> /// <param name="pConnectionServer"> /// The Connection server that houses the user that owns the alternate extension to be removed. /// </param> /// <param name="pUserObjectId"> /// The GUID of the user that owns the alternate extension to be removed. /// </param> /// <param name="pObjectId"> /// ObjectId of the alternate extension to remove /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult DeleteAlternateExtension(ConnectionServerRest pConnectionServer, string pUserObjectId, string pObjectId) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to DeleteAlternateExtension"; return(res); } if (string.IsNullOrEmpty(pUserObjectId)) { res.ErrorText = "Empty user objectId passed to DeleteAlternateExtension"; return(res); } if (string.IsNullOrEmpty(pObjectId)) { res.ErrorText = "Empty objectId passed to DeleteAlternateExtension"; return(res); } return(pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/alternateextensions/{2}", pConnectionServer.BaseUrl, pUserObjectId, pObjectId), MethodType.DELETE, "")); }
/// <summary> /// Allows one or more properties on a message handler to be udpated. The caller needs to construct a list of property /// names and new values using the ConnectionPropertyList class's "Add" method. At least one property pair needs to be passed in /// but as many as are desired can be included in a single call. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the object is homed. /// </param> /// <param name="pUserObjectId"> /// Unique identifier for user that owns the message handler being updated /// </param> /// <param name="pPropList"> /// List ConnectionProperty pairs that identify a transfer option property name and a new value for that property to apply to the option /// being updated. This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances. At least one /// property pair needs to be included for the funtion to execute. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult UpdateMessageHandler(ConnectionServerRest pConnectionServer, string pUserObjectId, string pObjectId, ConnectionPropertyList pPropList) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to UpdateMessageHandler"; return(res); } if (pPropList == null || pPropList.Count < 1) { res.ErrorText = "empty property list passed to UpdateMessageHandler"; return(res); } string strBody = "<MessageHandler>"; foreach (var oPair in pPropList) { strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue); } strBody += "</MessageHandler>"; return(pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/messagehandlers/{2}", pConnectionServer.BaseUrl, pUserObjectId, pObjectId), MethodType.PUT, strBody, false)); }
/// <summary> /// Add a public distribution list as a member of a private list /// </summary> /// <param name="pConnectionServer"> /// Connection server being updated /// </param> /// <param name="pPrivateListObjectId"> /// Private list being updated /// </param> /// <param name="pListObjectId"> /// Public list to add to the private list membership /// </param> /// <param name="pOwnerUserObjectId"> /// User that is the owner of the list being edited. /// </param> /// <returns> /// Instance of the WebCallResult class. /// </returns> public static WebCallResult AddMemberPublicList(ConnectionServerRest pConnectionServer, string pPrivateListObjectId, string pListObjectId, string pOwnerUserObjectId) { if (pConnectionServer == null) { return(new WebCallResult { ErrorText = "Null ConnectionServer passed to AddMemberPublicList", Success = false }); } if (string.IsNullOrEmpty(pOwnerUserObjectId) || string.IsNullOrEmpty(pPrivateListObjectId)) { return(new WebCallResult { ErrorText = "Null ConnectionServer passed to AddMemberPublicList", Success = false }); } string strUrl = string.Format("{0}users/{1}/privatelists/{2}/privatelistmembers", pConnectionServer.BaseUrl, pOwnerUserObjectId, pPrivateListObjectId); string strBody = "<PrivateListMember>\n\r"; strBody += string.Format("<MemberDistributionListObjectId>{0}</MemberDistributionListObjectId>\n\r", pListObjectId); strBody += "</PrivateListMember>\n\r"; return(pConnectionServer.GetCupiResponse(strUrl, MethodType.POST, strBody, false)); }
/// <summary> /// Allows one or more properties on a list to be udpated (for instance display name/DTMFAccessID etc...). The caller needs to construct a list /// of property names and new values using the ConnectionPropertyList class's "Add" method. At least one property pair needs to be passed in /// but as many as are desired can be included in a single call. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the list is homed. /// </param> /// <param name="pObjectId"> /// The unqiue GUID identifying the list to be updated. /// </param> /// <param name="pPropList"> /// List ConnectionProperty pairs that identify a list property name and a new value for that property to apply to the list being updated. /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances. At least one property /// pair needs to be included for the funtion to execute. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult UpdateClassOfService(ConnectionServerRest pConnectionServer, string pObjectId, ConnectionPropertyList pPropList) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to UpdateClassOfService"; return(res); } //the update command takes a body in the request, construct it based on the name/value pair of properties passed in. //at lest one such pair needs to be present if (pPropList == null || pPropList.Count < 1) { res.ErrorText = "empty property list passed to UpdateClassOfService"; return(res); } string strBody = "<Cos>"; foreach (var oPair in pPropList) { //tack on the property value pair with appropriate tags strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue); } strBody += "</Cos>"; return(pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "coses/" + pObjectId, MethodType.PUT, strBody, false)); }
/// <summary> /// Update a post greeting recording - the only item you're allowed to change is the display name /// </summary> /// <param name="pConnectionServer"> /// Connection server that object is homed on. /// </param> /// <param name="pObjectId"> /// Unique identifier for the post greeting recording /// </param> /// <param name="pDisplayName"> /// Updated name /// </param> /// <returns> /// Instance of the WebCallResult class /// </returns> public static WebCallResult UpdatePostGreetingRecording(ConnectionServerRest pConnectionServer, string pObjectId, string pDisplayName) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to UpdatePostGreetingRecording"; return(res); } if (string.IsNullOrEmpty(pObjectId)) { res.ErrorText = "Empty objectId passed to UpdatePostGreetingRecording"; return(res); } string strBody = "<PostGreetingRecording>"; //tack on the property value pair with appropriate tags strBody += string.Format("<{0}>{1}</{0}>", "ObjectId", pObjectId); strBody += string.Format("<{0}>{1}</{0}>", "DisplayName", pDisplayName); strBody += "</PostGreetingRecording>"; return(pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "postgreetingrecordings/" + pObjectId, MethodType.PUT, strBody, false)); }
/// <summary> /// Gets the list of all servers and resturns them as a generic list of Server objects. /// </summary> /// <param name="pConnectionServer"> /// The Connection server object that is being queried /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> private WebCallResult GetServers(ConnectionServerRest pConnectionServer) { _servers = new List <Server>(); string strUrl = pConnectionServer.BaseUrl + "cluster"; //issue the command to the CUPI interface WebCallResult res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.Success = false; res.ErrorText = "Empty response received"; return(res); } _servers = pConnectionServer.GetObjectsFromJson <Server>(res.ResponseText); return(res); }
/// <summary> /// Delete a port group server from a port group /// </summary> /// <param name="pConnectionServer"> /// Connection server that houses the port group server to be deleted /// </param> /// <param name="pObjectId"> /// Unique identifier for port group server /// </param> /// <param name="pPortGroupObjectId"> /// Unique identifier for port group that owns the port group server. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult DeletePortGroupServer(ConnectionServerRest pConnectionServer, string pObjectId, string pPortGroupObjectId) { if (pConnectionServer == null) { return(new WebCallResult { ErrorText = "Null ConnectionServer referenced passed to DeletePortGroupServer" }); } if (string.IsNullOrEmpty(pObjectId)) { return(new WebCallResult { ErrorText = "Empty ObjectId passed to DeletePortGroupServer" }); } if (string.IsNullOrEmpty(pPortGroupObjectId)) { return(new WebCallResult { ErrorText = "Empty PortGroupServerObjectId passed to DeletePortGroupServer" }); } return(pConnectionServer.GetCupiResponse(string.Format("{0}portgroups/{1}/portgroupservers/{2}", pConnectionServer.BaseUrl, pPortGroupObjectId, pObjectId), MethodType.DELETE, "")); }
/// <summary> /// Remove a schedule set from the Connection directory. If this schedule set is being referenced the removal will fail. /// </summary> /// <param name="pConnectionServer"> /// Connection server being edited /// </param> /// <param name="pScheduleSetObjectId"> /// ObjectId of the schedule set to delete /// </param> /// <param name="pRemoveAllSchedules"> /// By default when removing a schedule set all the schedules associated with it are removed as well - if passed as false then /// the schedules are left alone and you need to clean them up (or reuse them in another schedule set) or they will possibly /// show up the CUCA web admin interface as "stranded" schedule elements /// </param> /// <returns> /// Instance of the WebCallResult class /// </returns> public static WebCallResult DeleteScheduleSet(ConnectionServerRest pConnectionServer, string pScheduleSetObjectId, bool pRemoveAllSchedules=true) { WebCallResult res =new WebCallResult {Success = false}; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer reference passed to DeleteScheduleSet"; return res; } if (string.IsNullOrEmpty(pScheduleSetObjectId)) { res.ErrorText = "Empty objectId passed to DeleteScheduleSet"; return res; } //delete all schedules associated with set if requested if (pRemoveAllSchedules) { //don't proceed if there's an error removing one of the schedules in this case res = DeleteAllSchedulesAssociatedWithScheduleSet(pConnectionServer, pScheduleSetObjectId); if (res.Success == false) { return res; } } return pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "schedulesets/" + pScheduleSetObjectId, MethodType.DELETE, ""); }
/// <summary> /// To reorder routing rules you must list ALL the routing rules in the order you wish them to be and it's done as /// a single operation. /// </summary> /// <param name="pConnectionServer"> /// Connection server being updated /// </param> /// <param name="pParams"> /// List of the routing rule ObjectIds (all of them) in the order you want the rules sorted /// </param> /// <returns> /// Instance of the WebCallResult class with details of the output of the operation /// </returns> public static WebCallResult UpdateOrderOfAllRoutingRules(ConnectionServerRest pConnectionServer, params string[] pParams) { if (pConnectionServer == null) { return(new WebCallResult { Success = false, ErrorText = "Null ConnectionServer passed to UpdateOrderOfAllRoutingRules" }); } if (pParams == null || pParams.Length < 1) { return(new WebCallResult { Success = false, ErrorText = "Empty parameter list passed to UpdateOrderOfAllRoutingRules" }); } StringBuilder strBody = new StringBuilder("<RoutingRules>"); foreach (string pParam in pParams) { strBody.AppendFormat("<{0}><ObjectId>{1}</ObjectId></{0}>", "RoutingRule", pParam); } strBody.AppendFormat("</RoutingRules>"); return(pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules", MethodType.PUT, strBody.ToString(), false)); }
/// <summary> /// Find the SearchSpaceMemberObjectId from the partitionObjectId value - the partition objectId is unique for the collection associated /// with a search space and this is much easier than having the user have to go fetch the associated objectId when removing. /// </summary> /// <param name="pConnectionServer"> /// Connection server being edited /// </param> /// <param name="pPartitionObjectId"> /// Partition to remove from the search space member list /// </param> /// <param name="pSearchSpaceObjectId"> /// Search space to edit /// </param> /// <returns> /// SearchSpaceMember ObjectId value if found, empty string if not. /// </returns> private static string GetSearchSpaceMemberObjectIdFromPartitionObjectId(ConnectionServerRest pConnectionServer, string pPartitionObjectId, string pSearchSpaceObjectId) { string strUrl = string.Format("{0}searchspaces/{1}/searchspacemembers/?query=(PartitionObjectId is {2})", pConnectionServer.BaseUrl, pSearchSpaceObjectId, pPartitionObjectId); //issue the command to the CUPI interface WebCallResult res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false || res.TotalObjectCount == 0) { return(""); } List <SearchSpaceMember> oMembers = pConnectionServer.GetObjectsFromJson <SearchSpaceMember>(res.ResponseText); foreach (var oMap in oMembers) { if (oMap.PartitionObjectId.Equals(pPartitionObjectId, StringComparison.InvariantCultureIgnoreCase)) { return(oMap.ObjectId); } } return(""); }
/// <summary> /// remove a partition as member of a search space /// </summary> /// <param name="pConnectionServer"> /// Connection server being edited /// </param> /// <param name="pSearchSpaceObjectId"> /// Search space to be edited /// </param> /// <param name="pPartitionObjectId"> /// Partition to be removed /// </param> /// <returns> /// Instance of the WebCallResult class. /// </returns> public static WebCallResult DeleteSearchSpaceMember(ConnectionServerRest pConnectionServer, string pSearchSpaceObjectId, string pPartitionObjectId) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to DeleteSearchSpaceMember"; return(res); } //make sure that something is passed in for the 2 required params if (String.IsNullOrEmpty(pSearchSpaceObjectId) | string.IsNullOrEmpty(pPartitionObjectId)) { res.ErrorText = "Empty value passed for partition or search space identifiers name in DeleteSearchSpaceMember"; return(res); } //get the ObjectId of the searchspace member based on the partition objectId passed in string strObjectId = GetSearchSpaceMemberObjectIdFromPartitionObjectId(pConnectionServer, pPartitionObjectId, pSearchSpaceObjectId); if (string.IsNullOrEmpty(strObjectId)) { res.ErrorText = "Could not find search space member by partition objectId=" + pPartitionObjectId; return(res); } return(pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + string.Format("searchspaces/{0}/searchspacemembers/{1}", pSearchSpaceObjectId, strObjectId), MethodType.DELETE, "")); }
/// <summary> /// Adds a role assignment to a user. Returns a failure response if that user already has the role assigned to them. /// </summary> /// <param name="pConnectionServer" type="Cisco.UnityConnection.RestFunctions.ConnectionServerRest"> /// Connection server that the user being edited lives on. /// </param> /// <param name="pUserObjectId" type="string"> /// Unique ID of the user to add the role to /// </param> /// <param name="pRoleObjectId" type="string"> /// Unique ID of the role to add to the user /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult AddRoleToUser(ConnectionServerRest pConnectionServer, string pUserObjectId, string pRoleObjectId) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddRoleToUser"; return(res); } if (string.IsNullOrEmpty(pUserObjectId)) { res.ErrorText = "Empty user ObjectId passed to AddRoleToUser"; return(res); } if (string.IsNullOrEmpty(pRoleObjectId)) { res.ErrorText = "Empty role ObjectId passed to AddRoleToUser"; return(res); } string strBody = "<UserRole>"; strBody += string.Format("<RoleObjectId>{0}</RoleObjectId>", pRoleObjectId); strBody += "</UserRole>"; return(pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/userroles", pConnectionServer.BaseUrl, pUserObjectId), MethodType.POST, strBody, false)); }
/// <summary> /// Add a new MWI device for a user /// </summary> /// <param name="pConnectionServer"> /// Connection server the user is homed on /// </param> /// <param name="pUserObjectId"> /// Unique identifier for user to add new MWI to /// </param> /// <param name="pDeviceDisplayName"> /// Display name for MWI device /// </param> /// <param name="pMediaSwitchObjectId"> /// Phone system the MWI will be associated with /// </param> /// <param name="pMwiExtension"> /// Extension number for the new MWI device to activate /// </param> /// <param name="pActivated"> /// Is the MWI active or not - you can add MWI devices that are not active that can be turned on later. /// </param> /// <returns> /// Instance of the WebCallResult class with details of the request/response from the server. /// </returns> public static WebCallResult AddMwi(ConnectionServerRest pConnectionServer, string pUserObjectId, string pDeviceDisplayName, string pMediaSwitchObjectId, string pMwiExtension, bool pActivated) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddMwi"; return(res); } //make sure that something is passed in for the 2 required params - the extension is optional. if (String.IsNullOrEmpty(pDeviceDisplayName) | (String.IsNullOrEmpty(pUserObjectId)) | (String.IsNullOrEmpty(pMediaSwitchObjectId)) | (String.IsNullOrEmpty(pMwiExtension))) { res.ErrorText = "Empty value passed for one or more required parameters in AddMwi"; return(res); } ConnectionPropertyList oProps = new ConnectionPropertyList(); oProps.Add("DisplayName", pDeviceDisplayName); oProps.Add("MwiExtension", pMwiExtension); oProps.Add("MediaSwitchObjectId", pMediaSwitchObjectId); oProps.Add("Active", pActivated); string strBody = "<Mwi>"; //tack on the property value pair with appropriate tags foreach (var oProp in oProps) { strBody += string.Format("<{0}>{1}</{0}>", oProp.PropertyName, oProp.PropertyValue); } strBody += "</Mwi>"; res = pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/mwis", pConnectionServer.BaseUrl, pUserObjectId), MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { string strPrefix = @"/vmrest/users/" + pUserObjectId + "/mwis/"; if (res.ResponseText.Contains(strPrefix)) { res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim(); } } return(res); }
/// <summary> /// Allows for the creation of a new private list for the currently logged in user. The display name and number ID must be provided. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the list is being added. /// </param> /// <param name="pUserOwnerObjectId"> /// User that will own the newly created private list /// </param> /// <param name="pDisplayName"> /// Display name to be used for the new list. /// </param> /// <param name="pNumericId"> /// Private list Id from 1 to 99 (depending on settings - by default private lists are limited to 20, however this routine does not check /// for that). Pass the default of 0 and the list will be created in the next available slot - this is the best method. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult AddPrivateList(ConnectionServerRest pConnectionServer, string pUserOwnerObjectId, string pDisplayName, int pNumericId = 0) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddPrivateList"; return(res); } //make sure that something is passed in for the 2 required params - the extension is optional. if (string.IsNullOrEmpty(pDisplayName)) { res.ErrorText = "Empty value passed for DisplayName in AddPrivateList on ConnectionServer.cs"; return(res); } if (pNumericId < 1 | pNumericId > 99) { res.ErrorText = "Invalid list Id passed to AddPrivateList on ConnectionServer.cs:" + pNumericId.ToString(); return(res); } ConnectionPropertyList oPropList = new ConnectionPropertyList(); //cheat here a bit and simply add the alias and display name values to the proplist where it can be tossed into the body later. oPropList.Add("DisplayName", pDisplayName); oPropList.Add("NumericId", pNumericId); string strBody = "<PrivateList>"; foreach (var oPair in oPropList) { //tack on the property value pair with appropriate tags strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue); } strBody += "</PrivateList>"; res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + string.Format("users/{0}/privatelists", pUserOwnerObjectId), MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { string strTemp = string.Format(@"/vmrest/users/{0}/privatelists/", pUserOwnerObjectId); if (res.ResponseText.Contains(strTemp)) { res.ReturnedObjectId = res.ResponseText.Replace(strTemp, "").Trim(); } } return(res); }
/// <summary> /// Fetches all private lists defined for the currently logged in user (if any). An empty list may be returned. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the lists are being fetched from. /// </param> /// <param name="pOwnerUserObjectId"> /// Owner of the private distribution list /// </param> /// <param name="pPrivateLists"> /// The list of private lists returned from the CUPI call (if any) is returned as a generic list of PrivateList class /// instances via this out param. If no lists are found found an empty list is returned. /// </param> /// <param name="pPageNumber"> /// Results page to fetch - defaults to 1 /// </param> /// <param name="pRowsPerPage"> /// Results to return per page, defaults to 20 /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetPrivateLists(ConnectionServerRest pConnectionServer, string pOwnerUserObjectId, out List <PrivateList> pPrivateLists, int pPageNumber = 1, int pRowsPerPage = 20) { WebCallResult res = new WebCallResult { Success = false }; pPrivateLists = new List <PrivateList>(); if (pConnectionServer == null) { res.ErrorText = "Null Connection server object passed to GetPrivateLists"; return(res); } if (string.IsNullOrEmpty(pOwnerUserObjectId)) { res.ErrorText = "Empty OWnerUserObjectId passed to GetPrivateLists"; return(res); } string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}users/{1}/privatelists", pConnectionServer.BaseUrl, pOwnerUserObjectId), "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.ErrorText = "Empty response received"; res.Success = false; return(res); } //not an error, just return empty list if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25) { return(res); } pPrivateLists = pConnectionServer.GetObjectsFromJson <PrivateList>(res.ResponseText); //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pPrivateLists) { oObject.HomeServer = pConnectionServer; oObject.UserObjectId = pOwnerUserObjectId; oObject.ClearPendingChanges(); } return(res); }
/// <summary> /// Import an LDAP user as a local Unity Connection user. /// </summary> /// <param name="pConnectionServer"> /// Connection server to import the user on. /// </param> /// <param name="pTemplateAlias"> /// Alias of the user template to use when importing the user, required. /// </param> /// <param name="pPkid"> /// Unique ID from the Call Manager database for the LDAP synchronized user. /// </param> /// <param name="pAlias"> /// Alias of the user in LDAP to import /// </param> /// <param name="pFirstName"> /// First name of the user to import /// </param> /// <param name="pLastName"> /// Last name of the user to import /// </param> /// <param name="pExtension"> /// Extension number to assign the user in Connection's diretory /// </param> /// <param name="pPropList"> /// Name value pair list of optional values to include in the import. /// </param> /// <returns> /// Instance of the WebCallResults class with details of the call and results from the server. /// </returns> public static WebCallResult ImportLdapUser(ConnectionServerRest pConnectionServer, string pTemplateAlias, string pPkid, string pAlias, string pFirstName, string pLastName, string pExtension, ConnectionPropertyList pPropList) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to ImportLdapUser"; return(res); } //make sure that something is passed in for the 3 required params if (String.IsNullOrEmpty(pTemplateAlias) || string.IsNullOrEmpty(pPkid) || string.IsNullOrEmpty(pExtension)) { res.ErrorText = "Empty value passed for one or more required parameters in ImportLdapUser on ConnectionServer.cs"; return(res); } //create an empty property list if it's passed as null since we use it below if (pPropList == null) { pPropList = new ConnectionPropertyList(); } //cheat here a bit and simply add the alias and extension values to the proplist where it can be tossed into the body later. pPropList.Add("pkid", pPkid); pPropList.Add("alias", pAlias); pPropList.Add("firstName", pFirstName); pPropList.Add("lastName", pLastName); pPropList.Add("dtmfAccessId", pExtension); //use JSON style body payload string strBody = "{"; foreach (var oPair in pPropList) { //tack on the property value pair with appropriate tags strBody += string.Format("\"{0}\":\"{1}\",", oPair.PropertyName, oPair.PropertyValue); } strBody = strBody.TrimEnd(',') + "}"; res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "import/users/ldap?templateAlias=" + pTemplateAlias, MethodType.POST, strBody); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { if (!string.IsNullOrEmpty(res.ResponseText) && res.ResponseText.Contains(@"/vmrest/users/")) { res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/users/", "").Trim(); } } return(res); }
/// <summary> /// Returns all the greeting streams for a directory handler /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the greetings are being fetched from. /// </param> /// <param name="pDirectoryHandlerObjectId"> /// GUID identifying the directory handler that owns the greetings being fetched /// </param> /// <param name="pGreetingStreamFiles"> /// The list of DirectoryHandlerGreetingStreamFile objects are returned using this out parameter. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetGreetingStreamFiles(ConnectionServerRest pConnectionServer, string pDirectoryHandlerObjectId, out List <DirectoryHandlerGreetingStreamFile> pGreetingStreamFiles) { WebCallResult res = new WebCallResult(); res.Success = false; pGreetingStreamFiles = null; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer passed to GetGreetingStreamFiles"; return(res); } if (string.IsNullOrEmpty(pDirectoryHandlerObjectId)) { res.ErrorText = "Empty DirectoryHandlerObjectId passed to GetGreetingStreamFiles"; return(res); } string strUrl = string.Format("{0}handlers/directoryhandlers/{1}/directoryhandlerstreamfiles", pConnectionServer.BaseUrl, pDirectoryHandlerObjectId); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } //if the call was successful the JSON dictionary should always be populated with something, but just in case do a check here. //if this is empty that does not mean an error - return true here along with an empty list. if (string.IsNullOrEmpty(res.ResponseText) || res.ResponseText.Equals("null")) { pGreetingStreamFiles = new List <DirectoryHandlerGreetingStreamFile>(); return(res); } pGreetingStreamFiles = pConnectionServer.GetObjectsFromJson <DirectoryHandlerGreetingStreamFile>(res.ResponseText, "DirectoryHandlerStreamFile"); if (pGreetingStreamFiles == null) { pGreetingStreamFiles = new List <DirectoryHandlerGreetingStreamFile>(); return(res); } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pGreetingStreamFiles) { oObject.HomeServer = pConnectionServer; oObject.DirectoryHandlerObjectId = pDirectoryHandlerObjectId; } return(res); }
/// <summary> /// This function allows for a GET of coses from Connection via HTTP - it allows for passing any number of additional clauses /// for filtering (query directives), sorting and paging of results. The format of the clauses should look like: /// filter: "query=(displayname startswith ab)" /// sort: "sort=(displayname asc)" /// page: "pageNumber=0" /// : "rowsPerPage=8" /// Escaping of spaces is done automatically, no need to account for that. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the lists are being fetched from. /// </param> /// <param name="pClassOfServices"> /// The list of coses returned from the CUPI call (if any) is returned as a generic list of ClassOfService class /// instances via this out param. If no COSes are found an empty list is returned. /// </param> /// <param name="pClauses"> /// Zero or more strings can be passed for clauses (filters, sorts, page directives). Only one query and one sort parameter at a time /// are currently supported by CUPI - in other words you can't have "query=(alias startswith ab)" and "query=(FirstName startswith a)" in /// the same call. Also if you have a sort and a query clause they must both reference the same column. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetClassesOfService(ConnectionServerRest pConnectionServer, out List <ClassOfService> pClassOfServices, params string[] pClauses) { WebCallResult res = new WebCallResult(); res.Success = false; pClassOfServices = new List <ClassOfService>(); if (pConnectionServer == null) { res.ErrorText = "Null Connection server object passed to GetClassOfService"; return(res); } string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "coses", pClauses); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.Success = false; res.ErrorText = "Empty response recieved"; return(res); } //not a failure, just return an empty list if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25) { return(res); } pClassOfServices = pConnectionServer.GetObjectsFromJson <ClassOfService>(res.ResponseText, "cos"); if (pClassOfServices == null) { pClassOfServices = new List <ClassOfService>(); res.ErrorText = "Could not parse JSON into COS objects:" + res.ResponseText; res.Success = false; return(res); } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pClassOfServices) { oObject.HomeServer = pConnectionServer; oObject.ClearPendingChanges(); } return(res); }
/// <summary> /// Returns a generic list of partitions that are members of the search space /// </summary> /// <param name="pConnectionServer"> /// Connection server being updated /// </param> /// <param name="pSearchSpaceObjectId"> /// ObjectId of the search space to fetch partitions for /// </param> /// <param name="pPartitions"> /// Genreic list of Partition objects associated with the search space - this list can be empty. /// </param> /// <returns> /// Instance of the WebCallResult class. /// </returns> private static WebCallResult GetPartitions(ConnectionServerRest pConnectionServer, string pSearchSpaceObjectId, out List <Partition> pPartitions) { pPartitions = new List <Partition>(); string strUrl = pConnectionServer.BaseUrl + string.Format("searchspaces/{0}/searchspacemembers", pSearchSpaceObjectId); //issue the command to the CUPI interface WebCallResult res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.ErrorText = "Empty response received"; res.Success = false; return(res); } //no error, just return an empty list if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25) { return(res); } List <SearchSpaceMember> oMembers = pConnectionServer.GetObjectsFromJson <SearchSpaceMember>(res.ResponseText); if (oMembers == null) { return(res); } //create an instance of each partition found in the membership list foreach (var oMember in oMembers) { try { Partition oPartition = new Partition(pConnectionServer, oMember.PartitionObjectId); pPartitions.Add(oPartition); } catch (UnityConnectionRestException ex) { return(ex.WebCallResult); } } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pPartitions) { oObject.HomeServer = pConnectionServer; } return(res); }
/// <summary> /// Gets the list of all restriction patterns and resturns them as a generic list of RestrictionPattern objects. /// </summary> /// <param name="pConnectionServer"> /// The Connection server object that references the server the templates should be pulled from /// </param> /// <param name="pRestrictionTableObjectId"> /// The objectId of the restriction table to fetch patterns for. /// </param> /// <param name="pRestrictionPatterns"> /// Out parameter that is used to return the list of RestrictionTable objects defined on Connection - there must be at least one. /// </param> /// <param name="pPageNumber"> /// Results page to fetch - defaults to 1 /// </param> /// <param name="pRowsPerPage"> /// Results to return per page, defaults to 20 /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetRestrictionPatterns(ConnectionServerRest pConnectionServer, string pRestrictionTableObjectId, out List <RestrictionPattern> pRestrictionPatterns, int pPageNumber = 1, int pRowsPerPage = 20) { WebCallResult res; pRestrictionPatterns = new List <RestrictionPattern>(); if (pConnectionServer == null) { res = new WebCallResult(); res.ErrorText = "Null ConnectionServer referenced passed to GetRestrictionPatterns"; return(res); } if (string.IsNullOrEmpty(pRestrictionTableObjectId)) { res = new WebCallResult(); res.ErrorText = "Empty restriction table objectId passed to GetRestrictionPatterns"; return(res); } string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}restrictiontables/{1}/restrictionpatterns", pConnectionServer.BaseUrl, pRestrictionTableObjectId), "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.ErrorText = "Empty response received"; res.Success = false; return(res); } //no error, just return an empty list if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25) { return(res); } pRestrictionPatterns = pConnectionServer.GetObjectsFromJson <RestrictionPattern>(res.ResponseText); //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pRestrictionPatterns) { oObject.HomeServer = pConnectionServer; oObject.RestrictionTableObjectId = pRestrictionTableObjectId; } return(res); }
/// <summary> /// /// </summary> /// <param name="pConnectionServer"></param> /// <param name="pRestrictionTable"></param> /// <param name="pPropList"></param> /// <returns></returns> public static WebCallResult UpdateRestrictionTable(ConnectionServerRest pConnectionServer, RestrictionTable pRestrictionTable, ConnectionPropertyList pPropList) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to UpdateRestrictionTable"; return(res); } if (pRestrictionTable == null) { res.ErrorText = "Null RestrictionTable passed to UpdateRestrictionTable"; return(res); } string strBody = "<RestrictionTable>"; foreach (var oPair in pPropList) { strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue); } strBody += "</RestrictionTable>"; string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId); res = pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false); if (res.Success == false) { return(res); } strBody = "<RestrictionPattern>"; foreach (RestrictionPattern oPattern in pRestrictionTable.RestrictionPatterns()) { strBody += string.Format("<{0}>{1}</{0}>", "ObjectId", oPattern.ObjectId); } strBody += "</RestrictionPattern>"; strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId + "/restrictionpatterns"); return(pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false)); }
/// <summary> /// This function allows for a GET of port group templates from Connection via HTTP - typically there are only three templates defined /// on the server and there's no provision for creating more so there's no filter clauses or the like supported to keep it simple. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the templates are being fetched from. /// </param> /// <param name="pTemplates"> /// The list of port group templates is returned via this out parameter /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetPortGroupTemplates(ConnectionServerRest pConnectionServer, out List <PortGroupTemplate> pTemplates) { WebCallResult res = new WebCallResult(); res.Success = false; pTemplates = new List <PortGroupTemplate>(); if (pConnectionServer == null) { res.ErrorText = "Null Connection server object passed to GetPortGroupTemplates"; return(res); } string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "portgrouptemplates"); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.Success = false; res.ErrorText = "Empty response received"; return(res); } //not an error, just return an empty list if (res.TotalObjectCount == 0 || res.ResponseText.Length < 20) { return(res); } pTemplates = pConnectionServer.GetObjectsFromJson <PortGroupTemplate>(res.ResponseText); if (pTemplates == null) { pTemplates = new List <PortGroupTemplate>(); res.ErrorText = "Failed to parse JSON into PortGroupTemplates:" + res.ResponseText; res.Success = false; return(res); } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pTemplates) { oObject.HomeServer = pConnectionServer; } return(res); }
/// <summary> /// Get a list of all users associated with a phone system /// </summary> /// <param name="pConnectionServer"> /// Connection server to do the query against /// </param> /// <param name="pObjectId"> /// ObjectId of the phone system to get associations for /// </param> /// <param name="pAssociations"> /// List of associated users is returned on this parameter /// </param> /// <param name="pPageNumber"> /// Results page to fetch - defaults to 1 /// </param> /// <param name="pRowsPerPage"> /// Results to return per page, defaults to 20 /// </param> /// <returns> /// Instance of the WebCallResults class with details of the fetch results. /// </returns> public static WebCallResult GetPhoneSystemAssociations(ConnectionServerRest pConnectionServer, string pObjectId, out List <PhoneSystemAssociation> pAssociations, int pPageNumber = 1, int pRowsPerPage = 20) { WebCallResult res = new WebCallResult { Success = false }; pAssociations = new List <PhoneSystemAssociation>(); if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to GetPhoneSystemAssociation"; return(res); } if (string.IsNullOrEmpty(pObjectId)) { res.ErrorText = "Blank ObjectId passed to GetPhonesystemAssociations"; return(res); } string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}phonesystems/{1}/phonesystemassociations", pConnectionServer.BaseUrl, pObjectId), "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage); res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } if (string.IsNullOrEmpty(res.ResponseText)) { res.Success = false; res.ErrorText = "Empty response received"; return(res); } //not an error, just return the empty list if (res.TotalObjectCount == 0) { return(res); } pAssociations = pConnectionServer.GetObjectsFromJson <PhoneSystemAssociation>(res.ResponseText); if (pAssociations == null) { pAssociations = new List <PhoneSystemAssociation>(); res.ErrorText = "Could not parse JSON into PhoneSystemAssociations:" + res.ResponseText; res.Success = false; return(res); } return(res); }
/// <summary> /// Returns all the menu entries for a call handler. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the menu entries are being fetched from. /// </param> /// <param name="pCallHandlerObjectId"> /// GUID identifying the call handler that owns the menu entries being fetched /// </param> /// <param name="pMenuEntries"> /// The list of MenuEntry objects are returned using this out parameter. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetMenuEntries(ConnectionServerRest pConnectionServer, string pCallHandlerObjectId, out List <MenuEntry> pMenuEntries) { WebCallResult res = new WebCallResult(); res.Success = false; pMenuEntries = null; if (pConnectionServer == null) { res.ErrorText = "Null Connection server object passed to GetMenuEntries"; return(res); } string strUrl = string.Format("{0}handlers/callhandlers/{1}/menuentries", pConnectionServer.BaseUrl, pCallHandlerObjectId); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } //if the call was successful the JSON dictionary should always be populated with something, but just in case do a check here. //if this is empty thats an error - there should alway be menu entries returned if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0) { pMenuEntries = new List <MenuEntry>(); res.Success = false; return(res); } pMenuEntries = pConnectionServer.GetObjectsFromJson <MenuEntry>(res.ResponseText); if (pMenuEntries == null) { pMenuEntries = new List <MenuEntry>(); res.ErrorText = "Could not parse JSON into MenuEntry list:" + res.ResponseText; res.Success = false; return(res); } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pMenuEntries) { oObject.HomeServer = pConnectionServer; oObject.CallHandlerObjectId = pCallHandlerObjectId; oObject.ClearPendingChanges(); } return(res); }
/// <summary> /// Adds a new alternate extension at the index passed in for the user identified with the UserObjectID parameter. If the extension /// conflicts with another in the partition or that alternate extension "slot" is already in use, Connection will return an error. /// </summary> /// <param name="pConnectionServer"> /// The Connection server that houses the user that owns the new alternate extension to be added. /// </param> /// <param name="pUserObjectId"> /// GUID that identifies the user to add the alternate extension for. /// </param> /// <param name="pIdIndex"> /// The alternate extension id to add the alternate extension to. 1-10 are administrator added extensions, 11 through 20 are user added. /// </param> /// <param name="pExtension"> /// The DMTFAccessID (extension) to add. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult AddAlternateExtension(ConnectionServerRest pConnectionServer, string pUserObjectId, int pIdIndex, string pExtension) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddAlternateExtension"; return(res); } //make sure that something is passed in for the 2 required params - the extension is optional. if (String.IsNullOrEmpty(pExtension) || (string.IsNullOrEmpty(pUserObjectId))) { res.ErrorText = "Empty value passed for one or more required parameters in AddAlternateExtension"; return(res); } //1 through 10 is admin added, 11 through 20 is user added. Different versions of Connection allow for different numbers //in the SA etc... however 20 is currently the max upper bound so we check for that here - the back end CUPI call will fail //appropriately. if (pIdIndex > 20) { res.ErrorText = "Invalid IDIndex passed to AddAlternateExtension:" + pIdIndex.ToString(); return(res); } string strBody = "<AlternateExtension>"; //tack on the property value pair with appropriate tags strBody += string.Format("<IdIndex>{0}</IdIndex>", pIdIndex); strBody += string.Format("<DtmfAccessId>{0}</DtmfAccessId>", pExtension); strBody += "</AlternateExtension>"; res = pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/alternateextensions", pConnectionServer.BaseUrl, pUserObjectId), MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { string strPrefix = @"/vmrest/users/" + pUserObjectId + "/alternateextensions/"; if (res.ResponseText.Contains(strPrefix)) { res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim(); } } return(res); }
/// <summary> /// Returns all the Transfer Options for a call handler. /// </summary> /// <param name="pConnectionServer"> /// Reference to the ConnectionServer object that points to the home server where the transfer options are being fetched from. /// </param> /// <param name="pCallHandlerObjectId"> /// GUID identifying the call handler that owns the transfer options being fetched /// </param> /// <param name="pTransferOptions"> /// The list of TransferOption objects are returned using this out parameter. /// </param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult GetTransferOptions(ConnectionServerRest pConnectionServer, string pCallHandlerObjectId, out List <TransferOption> pTransferOptions) { WebCallResult res = new WebCallResult(); res.Success = false; pTransferOptions = new List <TransferOption>(); if (pConnectionServer == null) { res.ErrorText = "Null Connection server object passed to GetTransferOptions"; return(res); } string strUrl = string.Format("{0}handlers/callhandlers/{1}/transferoptions", pConnectionServer.BaseUrl, pCallHandlerObjectId); //issue the command to the CUPI interface res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, ""); if (res.Success == false) { return(res); } //if this is empty thats an error - there should always be transfer options. if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0) { res.ErrorText = "No transfer options found for call handler"; res.Success = false; return(res); } pTransferOptions = pConnectionServer.GetObjectsFromJson <TransferOption>(res.ResponseText); if (pTransferOptions == null) { pTransferOptions = new List <TransferOption>(); res.Success = false; res.ErrorText = "Could not parse JSON into TransferOptions:" + res.ResponseText; return(res); } //the ConnectionServer property is not filled in in the default class constructor used by the Json parser - //run through here and assign it for all instances. foreach (var oObject in pTransferOptions) { oObject.HomeServer = pConnectionServer; oObject.CallHandlerObjectId = pCallHandlerObjectId; oObject.ClearPendingChanges(); } return(res); }