/// <summary> /// Updates a group /// </summary> /// <param name="groupId">The groupId (required) argument identifies the ID of the new group.</param> /// <param name="groupName">The groupName (required) argument identifies the name of the group to /// which the address is being added.</param> /// <param name="description">The description argument provides a general description of the group.</param> /// <param name="emailPermission">The emailPermission argument sets the permissions level of the group.</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// update</returns> public AppsExtendedEntry UpdateGroup(String groupId, String groupName, String description, String emailPermission) { Uri updateGroupUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/" + domain + "/" + groupId); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = updateGroupUri; entry.Properties.Add( new PropertyElement( AppsGroupsNameTable.groupId, groupId)); if (groupName != null && groupName != String.Empty) { entry.Properties.Add( new PropertyElement( AppsGroupsNameTable.groupName, groupName)); } if (description != null && description != String.Empty) { entry.Properties.Add( new PropertyElement( AppsGroupsNameTable.description, description)); } if (emailPermission != null && emailPermission != String.Empty) { entry.Properties.Add( new PropertyElement( AppsGroupsNameTable.emailPermission, emailPermission)); } return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
/// <summary> /// Creates a new Google Mail senda-as alias for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="name">The name which emails sent using the alias are from</param> /// <param name="address">The email address which emails sent using the alias are from</param> /// <param name="replyTo">If set, this address will be included as the reply-to addres for the alias</param> /// <param name="makeDefault">Whether the new alias would be the default email address</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateSendAs(string userName, string name, string address, string replyTo, string makeDefault) { Uri sendasUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + sendasFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.name, name)); entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.address, address)); if (!string.IsNullOrEmpty(replyTo)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.replyTo, replyTo)); } if (!string.IsNullOrEmpty(makeDefault)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.makeDefault, makeDefault)); } return(base.Insert(sendasUri, entry) as AppsExtendedEntry); }
public void SaveAndReadTest() { entry.Properties.Add(new PropertyElement("name", "value")); StringBuilder sb = new StringBuilder(); XmlWriter writer = new XmlTextWriter(new StringWriter(sb)); entry.SaveToXml(writer); writer.Close(); XmlDocument document = new XmlDocument(); document.LoadXml(sb.ToString()); AppsExtendedEntry newEntry = new AppsExtendedEntry(); foreach (XmlNode node in document.FirstChild.ChildNodes) { ExtensionElementEventArgs args = new ExtensionElementEventArgs(); args.ExtensionElement = node; args.Base = newEntry; newEntry.Parse(args, new AtomFeedParser()); } Assert.AreEqual(entry.Properties[0].Name, newEntry.Properties[0].Name, "Parsed entry should have same name for property[0] as original entry"); Assert.AreEqual(entry.Properties[0].Value, newEntry.Properties[0].Value, "Parsed entry should have same value for property[0] as original entry"); }
/// <summary> /// Creates a new Google Mail label for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="label">the new Google Mail label</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateLabel(string userName, string label) { Uri labelUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + labelFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGoogleMailSettingsNameTable.label, label)); return base.Insert(labelUri, entry) as AppsExtendedEntry; }
/// <summary> /// Adds an owner to a group /// </summary> /// <param name="email">owner's Email to add to the group</param> /// <param name="groupId">Groups's id</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry AddOwnerToGroup(String email, String groupId) { Uri addMemberToGroupUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/" + domain + "/" + groupId + "/" + ownerUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGroupsNameTable.email, email)); return(base.Insert(addMemberToGroupUri, entry) as AppsExtendedEntry); }
/// <summary> /// Creates a new Google Mail delegation for the given userName /// </summary> /// <param name="userName">The user that grants mailbox access to another user</param> /// <param name="delegationId">Email address of the user receiving access</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateDelegate(string userName, string delegationId) { Uri delegationUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + delegationFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGoogleMailSettingsNameTable.address, delegationId)); return(base.Insert(delegationUri, entry) as AppsExtendedEntry); }
/// <summary> /// Creates a new Google Mail label for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="label">the new Google Mail label</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateLabel(string userName, string label) { Uri labelUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + labelFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGoogleMailSettingsNameTable.label, label)); return(base.Insert(labelUri, entry) as AppsExtendedEntry); }
/// <summary> /// Updates Google Mail's IMAP settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="enable">Whether to enable IMAP access</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateImap(string userName, string enable) { Uri imapUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + imapFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = imapUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
/// <summary> /// Updates Google Mail's display language for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="language">Google Mail's display language</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateLanguage(string userName, string language) { Uri languageUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + languageFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = languageUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.language, language)); return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
private static void RunSample(CalendarResourceService service) { try { const String TEST_RESOURCE_ID = "NYV-BUILDING-5-Batman"; // Create a new CalendarResource AppsExtendedEntry entry = service.CreateCalendarResource( TEST_RESOURCE_ID, "Batman", "6 Person VC", "CR"); Console.WriteLine("Created: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceId)); // Retrieve a CalendarResource entry = service.RetrieveCalendarResource(TEST_RESOURCE_ID); Console.WriteLine("Retrieved: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceEmail)); Console.WriteLine("Dscription: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceDescription)); Console.WriteLine("Resource Id: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceId)); Console.WriteLine("Common name: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceCommonName)); //Retrieve all resources Console.WriteLine("Retrieving all calendar resources (this may take some time) ..... "); AppsExtendedFeed feed = service.RetrieveAllCalendarResources(); Console.WriteLine("Retrieved Entries Count: " + feed.Entries.Count); foreach (AppsExtendedEntry resourceEntry in feed.Entries) { Console.WriteLine("Resource Emails: " + entry.getPropertyValueByName(AppsCalendarResourceNameTable.resourceEmail)); } //Delete a resource service.DeleteCalendarResource(TEST_RESOURCE_ID); Console.WriteLine("Deleted: " + TEST_RESOURCE_ID); Console.Read(); } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
/// <summary> /// Updates Google Mail's vacation-responder settings for the given userName /// </summary> /// <param name="userName">The user for whom this should</param> /// <param name="enable">Wheter to enable the vacation responder</param> /// <param name="subject">The subject line of the vacacion responder autoresponse</param> /// <param name="message">The message body of the vacation responder autoresponse</param> /// <param name="contactsOnly">Wheter to only send the autoresponse to known contacts</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateVacation(string userName, string enable, string subject, string message, string contactsOnly, string domainOnly, string startDate, string endDate) { Uri vacationUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + vacationFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = vacationUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); if (!string.IsNullOrEmpty(subject)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.subject, subject)); } if (!string.IsNullOrEmpty(message)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.message, message)); } if (!string.IsNullOrEmpty(contactsOnly)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.contactsOnly, contactsOnly)); } if (!string.IsNullOrEmpty(domainOnly)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.domainOnly, domainOnly)); } if (!string.IsNullOrEmpty(startDate)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.startDate, startDate)); } if (!string.IsNullOrEmpty(endDate)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.endDate, endDate)); } return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
private static void GroupOperations(AppsService service) { // Create a new group. AppsExtendedEntry insertedEntry = service.Groups.CreateGroup(testGroup, testGroup, testGroup, null); Console.WriteLine("Created new group '{0}'", insertedEntry.getPropertyByName("groupId").Value); // Retrieve the newly-created group. AppsExtendedEntry entry = service.Groups.RetrieveGroup(testGroup); Console.WriteLine("Retrieved group '{0}'", entry.getPropertyByName("groupId").Value); // Add Member To Group AppsExtendedEntry newMemberEntry = service.Groups.AddMemberToGroup(testUserName, testGroup); Console.WriteLine("User '{0}' was added as member to group '{1}'", newMemberEntry.getPropertyByName("memberId").Value, testGroup); // Add Owner to Group AppsExtendedEntry newOwnerEntry = service.Groups.AddOwnerToGroup(testUserName, testGroup); Console.WriteLine("User '{0}' was added as ownter to group '{1}'", newOwnerEntry.getPropertyByName("email").Value, testGroup); // Check if a User is a Group Member Console.WriteLine("Is User '{0}' member of group '{1}'? '{2}'", testUserName, testGroup, service.Groups.IsMember(testUserName, testGroup)); // Check if a User is a Group Member Console.WriteLine("Is User '{0}' owner of group '{1}'? '{2}'", testUserName, testGroup, service.Groups.IsOwner(testUserName, testGroup)); // Remove Member from Group service.Groups.RemoveMemberFromGroup(testUserName, testGroup); Console.WriteLine("User '{0}' was removed as member to group '{1}'", testUserName, testGroup); // Remove Owner from Group service.Groups.RemoveOwnerFromGroup(testUserName, testGroup); Console.WriteLine("User '{0}' was removed as ownter to group '{1}'", testUserName, testGroup); // Retreive all groups AppsExtendedFeed groupsFeed = service.Groups.RetrieveAllGroups(); Console.WriteLine("First Group from All groups: '{0}'", (groupsFeed.Entries[0] as AppsExtendedEntry).getPropertyByName("groupId").Value); }
/// <summary> /// Updates Google Mail's signature for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="signature">The signature to be appended to outgoing messages</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateSignature(string userName, string signature) { Uri signatureUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + signatureFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = signatureUri; if (signature == null) { signature = String.Empty; } entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.signature, signature)); return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
/// <summary> /// Updates Google Mail's general settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="label">the new Google Mail label</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateGeneralSettings(string userName, string pageSize, string shortcuts, string arrows, string snippets, string unicode) { Uri generalUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + generalFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = generalUri; if (!string.IsNullOrEmpty(pageSize)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.pageSize, pageSize)); } if (!string.IsNullOrEmpty(shortcuts)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shortcuts, shortcuts)); } if (!string.IsNullOrEmpty(arrows)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.arrows, arrows)); } if (!string.IsNullOrEmpty(snippets)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.snippets, snippets)); } if (!string.IsNullOrEmpty(unicode)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.unicode, unicode)); } return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
/// <summary> /// Creates a new group /// </summary> /// <param name="groupId">The groupId (required) argument identifies the ID of the new group.</param> /// <param name="groupName">The groupName (required) argument identifies the name of the group to /// which the address is being added.</param> /// <param name="description">The description argument provides a general description of the group.</param> /// <param name="emailPermission">The emailPermission argument sets the permissions level of the group.</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateGroup(String groupId, String groupName, String description, String emailPermission) { Uri createGroupUri = new Uri(AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri + "/" + domain); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGroupsNameTable.groupId, groupId)); entry.Properties.Add( new PropertyElement(AppsGroupsNameTable.groupName, groupName)); if (description != null && description != String.Empty) { entry.Properties.Add( new PropertyElement(AppsGroupsNameTable.description, description)); } if (emailPermission != null && emailPermission != String.Empty) { entry.Properties.Add( new PropertyElement(AppsGroupsNameTable.emailPermission, emailPermission)); } return(base.Insert(createGroupUri, entry) as AppsExtendedEntry); }
/// <summary> /// Updates Google Mail's POP settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="enable">Whether to enable POP3 access</param> /// <param name="enableFor">Whether to enable POP3 for all mail or mail from now on</param> /// <param name="action">What Google Mail should do with its copy of the email after /// it is retrieved using POP3</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdatePop(string userName, string enable, string enableFor, string action) { Uri popUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + popFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = popUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); if (!string.IsNullOrEmpty(enableFor)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enableFor, enableFor)); } if (!string.IsNullOrEmpty(action)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.action, action)); } return(base.Update((AtomEntry)entry) as AppsExtendedEntry); }
/// <summary> /// /// </summary> /// <param name="service"></param> private static void RunSample(MultiDomainManagementService service) { const String testUserPassword = "******"; const String testUserFirstName = "Liz"; const String testUserLastName = "Smith"; const bool testUserIsAdmin = true; const String testUserNewFirstName = "Elizabeth"; String testUserNewEmail = "liz@" + secondaryDomain; String testUserAliasEmail = "helpdesk@" + secondaryDomain; try { // Create a new Domain User Console.WriteLine("\n-----------Creating domain user-----------"); AppsExtendedEntry entry = service.CreateDomainUser(primaryDomain, testUserEmail, testUserPassword, testUserFirstName, testUserLastName, testUserIsAdmin); Console.WriteLine("Created: " + entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail)); // Update Domain User and list all properties Console.WriteLine("\n-----------Updating domain user----"); IDictionary <MultiDomainManagementService.MultiDomainUserProperty, string> updates = new Dictionary <MultiDomainManagementService.MultiDomainUserProperty, string>(); updates[MultiDomainManagementService.MultiDomainUserProperty.FirstName] = testUserNewFirstName; entry = service.UpdateDomainUser(primaryDomain, testUserEmail, updates); foreach (PropertyElement element in entry.Properties) { Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value)); } // Create a new Domain User to be renamed Console.WriteLine("\n-----------Creating domain user to be renamed-----------"); String tempEmail = "TOBERENAMED@" + primaryDomain; entry = service.CreateDomainUser(primaryDomain, tempEmail, testUserPassword, testUserFirstName, testUserLastName, testUserIsAdmin); Console.WriteLine("Created: " + entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail)); // Rename Domain User Console.WriteLine("\n-----------Renaming domain user---------------------"); entry = service.RenameDomainUser(primaryDomain, tempEmail, testUserNewEmail); Console.WriteLine("Renamed domain user: "******"\n-----------Retrieving domain user----"); entry = service.RetrieveDomainUser(primaryDomain, testUserEmail); String firstName = entry.getPropertyValueByName(AppsMultiDomainNameTable.FirstName); Console.WriteLine("FirstName: " + firstName); // Retrieve all domain users unit and list the emails Console.WriteLine("\n-----------Retrieving all domain users----"); AppsExtendedFeed feed = service.RetrieveAllDomainUsers(primaryDomain); foreach (AppsExtendedEntry unit in feed.Entries) { Console.WriteLine( unit.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail)); } // Create a new User Alias Console.WriteLine("\n-----------Creating user alias-----------"); entry = service.CreateDomainUserAlias(primaryDomain, testUserEmail, testUserAliasEmail); Console.WriteLine("Created Alias: " + entry.getPropertyValueByName(AppsMultiDomainNameTable.AliasEmail)); // Retrieve User Alias entry = service.RetrieveDomainUserAlias(primaryDomain, testUserAliasEmail); String userEmail = entry.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail); Console.WriteLine("UserEmail: " + userEmail); // Retrieve all user aliases for the domain Console.WriteLine("\n-----------Retrieving all user aliases----"); feed = service.RetrieveAllDomainUserAlias(primaryDomain); foreach (AppsExtendedEntry unit in feed.Entries) { Console.WriteLine( unit.getPropertyValueByName(AppsMultiDomainNameTable.UserEmail)); } // Retrieve all aliases for an user Console.WriteLine("\n-----------Retrieving all aliases for user----"); feed = service.RetrieveAllDomainUserAliasForUser(primaryDomain, testUserEmail); foreach (AppsExtendedEntry unit in feed.Entries) { Console.WriteLine( unit.getPropertyValueByName(AppsMultiDomainNameTable.AliasEmail)); } // Delete User Alias Console.WriteLine("\n-----------Deleting alias----"); service.DeleteDomainUserAlias(primaryDomain, testUserAliasEmail); // Delete User Console.WriteLine("\n-----------Deleting user----"); service.DeleteDomainUser(primaryDomain, testUserEmail); } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
/// <summary> /// Updates Google Mail's POP settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="enable">Whether to enable POP3 access</param> /// <param name="enableFor">Whether to enable POP3 for all mail or mail from now on</param> /// <param name="action">What Google Mail should do with its copy of the email after /// it is retrieved using POP3</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdatePop(string userName, string enable, string enableFor, string action) { Uri popUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + popFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = popUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); if (!string.IsNullOrEmpty(enableFor)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enableFor, enableFor)); if (!string.IsNullOrEmpty(action)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.action, action)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Updates Google Mail's IMAP settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="enable">Whether to enable IMAP access</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateImap(string userName, string enable) { Uri imapUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + imapFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = imapUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Updates Google Mail's vacation-responder settings for the given userName /// </summary> /// <param name="userName">The user for whom this should</param> /// <param name="enable">Wheter to enable the vacation responder</param> /// <param name="subject">The subject line of the vacacion responder autoresponse</param> /// <param name="message">The message body of the vacation responder autoresponse</param> /// <param name="contactsOnly">Wheter to only send the autoresponse to known contacts</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateVacation(string userName, string enable, string subject, string message, string contactsOnly, string domainOnly, string startDate, string endDate) { Uri vacationUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + vacationFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = vacationUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.enable, enable)); if (!string.IsNullOrEmpty(subject)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.subject, subject)); if (!string.IsNullOrEmpty(message)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.message, message)); if (!string.IsNullOrEmpty(contactsOnly)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.contactsOnly, contactsOnly)); if (!string.IsNullOrEmpty(domainOnly)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.domainOnly, domainOnly)); if (!string.IsNullOrEmpty(startDate)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.startDate, startDate)); if (!string.IsNullOrEmpty(endDate)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.endDate, endDate)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Updates Google Mail's signature for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="signature">The signature to be appended to outgoing messages</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateSignature(string userName, string signature) { Uri signatureUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + signatureFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = signatureUri; if (signature == null) signature = String.Empty; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.signature, signature)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Updates Google Mail's display language for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="language">Google Mail's display language</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateLanguage(string userName, string language) { Uri languageUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + languageFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = languageUri; entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.language, language)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Creates a new Google Mail senda-as alias for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="name">The name which emails sent using the alias are from</param> /// <param name="address">The email address which emails sent using the alias are from</param> /// <param name="replyTo">If set, this address will be included as the reply-to addres for the alias</param> /// <param name="makeDefault">Whether the new alias would be the default email address</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateSendAs(string userName, string name, string address, string replyTo, string makeDefault) { Uri sendasUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + sendasFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.name, name)); entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.address, address)); if (!string.IsNullOrEmpty(replyTo)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.replyTo, replyTo)); if (!string.IsNullOrEmpty(makeDefault)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.makeDefault, makeDefault)); return base.Insert(sendasUri, entry) as AppsExtendedEntry; }
/// <summary> /// Updates Google Mail's general settings for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="label">the new Google Mail label</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry UpdateGeneralSettings(string userName, string pageSize, string shortcuts, string arrows, string snippets, string unicode) { Uri generalUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + generalFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.EditUri = generalUri; if (!string.IsNullOrEmpty(pageSize)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.pageSize, pageSize)); if (!string.IsNullOrEmpty(shortcuts)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shortcuts, shortcuts)); if (!string.IsNullOrEmpty(arrows)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.arrows, arrows)); if (!string.IsNullOrEmpty(snippets)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.snippets, snippets)); if (!string.IsNullOrEmpty(unicode)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.unicode, unicode)); return base.Update((AtomEntry)entry) as AppsExtendedEntry; }
/// <summary> /// Creates a new Google Mail delegation for the given userName /// </summary> /// <param name="userName">The user that grants mailbox access to another user</param> /// <param name="delegationId">Email address of the user receiving access</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the /// creation</returns> public AppsExtendedEntry CreateDelegate(string userName, string delegationId) { Uri delegationUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + delegationFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); entry.Properties.Add( new PropertyElement(AppsGoogleMailSettingsNameTable.address, delegationId)); return base.Insert(delegationUri, entry) as AppsExtendedEntry; }
private static void RunSample(GoogleMailSettingsService service) { try { // Create a new Label for the user testUserName service.CreateLabel(testUserName, "Test-Label"); // Retrieve all labels for the user testUserName AppsExtendedFeed labels = service.RetrieveLabels(testUserName); Console.WriteLine(String.Format("First label: {0}", ((AppsExtendedEntry)labels.Entries[0]).getPropertyValueByName("label"))); // Create a filter for emails from [email protected] // for the user testUserName and applies the new label "Test-Label" service.CreateFilter(testUserName, "test@" + domain, "", "", "", "", "", "Test-Label", "true", ""); // Create a filter for emails having "important" in the subject // for the user testUserName to never send them to Spam and star them service.CreateFilter(testUserName, "", "", "important", "", "", "", "", "", "", "true", "true", "", ""); // Create a new Send As for the user testUserName service.CreateSendAs(testUserName, "Test email", testUserName + "@" + domain, "", ""); // Retrieve all send-as for user testUserName AppsExtendedFeed sendas = service.RetrieveSendAs(testUserName); Console.WriteLine(String.Format("First send-as: {0}", ((AppsExtendedEntry)sendas.Entries[0]).getPropertyValueByName("name"))); // Updates the forwarding rule to forward emails to // test@domain for the user testUserName and keeps the email. service.UpdateForwarding(testUserName, "true", "test@" + domain, "KEEP"); // Disable web clip for the user testUserName. service.UpdateWebclip(testUserName, "false"); // Retrieve forwarding settings for user testUserName AppsExtendedEntry forwarding = service.RetrieveForwarding(testUserName); Console.WriteLine(String.Format("Forwarding to: {0}", forwarding.getPropertyValueByName("forwardTo"))); // Deactivate POP for the user testUserName service.UpdatePop(testUserName, "false", null, null); // Retrieve POP settings for user testUserName AppsExtendedEntry pop = service.RetrievePop(testUserName); Console.WriteLine(String.Format("POP enabled: {0}", pop.getPropertyValueByName("enable"))); // Activate IMAP for the user testUserName service.UpdateImap(testUserName, "true"); // Retrieve IMAP settings for user testUserName AppsExtendedEntry imap = service.RetrieveImap(testUserName); Console.WriteLine(String.Format("IMAP enabled: {0}", imap.getPropertyValueByName("enable"))); // Activate vacation autoresponse for the user testUserName service.UpdateVacation(testUserName, "true", "vacation", "vacation text...", "false", "true", "2012-01-15", "2012-01-22"); // Retrieve vacation responder settings for user testUserName AppsExtendedEntry vacation = service.RetrieveVacation(testUserName); Console.WriteLine(String.Format("Vacation responder message: {0}", vacation.getPropertyValueByName("message"))); // Update the signature for the user testUserName service.UpdateSignature(testUserName, "Signature text..."); // Retrieve signature for user testUserName AppsExtendedEntry signature = service.RetrieveSignature(testUserName); Console.WriteLine(String.Format("Signature: {0}", signature.getPropertyValueByName("signature"))); // Update the language settings to French (fr) for the user testUserName service.UpdateLanguage(testUserName, "fr"); // Update general settings for the user testUserName service.UpdateGeneralSettings(testUserName, "50", "false", "false", "false", "false"); // Create a new Delegate for the user testUserName service.CreateDelegate(testUserName, adminEmail); // Retrieve all delegates for the user testUserName AppsExtendedFeed delegates = service.RetrieveDelegates(testUserName); Console.WriteLine(String.Format("First delegate: {0}", ((AppsExtendedEntry)delegates.Entries[0]).getPropertyValueByName("delegationId"))); // Delete the Delegate for the user testUserName service.DeleteDelegate(testUserName, adminEmail); } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
/// <summary> /// Creates a new Google Mail filter for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="from">come-from email address to be filtered</param> /// <param name="to">send-to email address to be filtered</param> /// <param name="subject">a string the email must have on the subject line to be filtered</param> /// <param name="hasTheWords">a string the email can have anywhere in its subject or body</param> /// <param name="doesNotHaveTheWords">a string the email cannot have anywhere in its subject or body</param> /// <param name="hasAttachment">a boolean representing whether or not the emails contains an attachment</param> /// <param name="label">the name of the label to apply if the message matches the filter criteria</param> /// <param name="shouldMarkAsRead">Whether to automatically mark the message as read /// if it matches the filter criteria</param> /// <param name="shouldArchive">Whether to automatically move the message to Archived state /// if it matches the filter criteria</param> /// <param name="shouldStar">Whether to automatically star the message /// if it matches the filter criteria</param> /// <param name="neverSpam">Whether to automatically move the message to Spam state /// if it matches the filter criteria</param> /// <param name="forwardTo">Whether to automatically forward the message to the given /// verified email address if it matches the filter criteria</param> /// <param name="shouldTrash">Whether to automatically move the message to Trash state /// if it matches the filter criteria</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the creation</returns> public AppsExtendedEntry CreateFilter(string userName, string from, string to, string subject, string hasTheWords, string doesNotHaveTheWords, string hasAttachment, string label, string shouldMarkAsRead, string shouldArchive, string shouldStar, string neverSpam, string forwardTo, string shouldTrash) { Uri filterUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + filterFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); if (!string.IsNullOrEmpty(from)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.from, from)); if (!string.IsNullOrEmpty(to)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.to, to)); if (!string.IsNullOrEmpty(subject)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.subject, subject)); if (!string.IsNullOrEmpty(hasTheWords)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.hasTheWord, hasTheWords)); if (!string.IsNullOrEmpty(doesNotHaveTheWords)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.doesNotHaveTheWord, doesNotHaveTheWords)); if (!string.IsNullOrEmpty(hasAttachment)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.hasAttachment, hasAttachment)); if (!string.IsNullOrEmpty(label)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.label, label)); if (!string.IsNullOrEmpty(shouldMarkAsRead)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldMarkAsRead, shouldMarkAsRead)); if (!string.IsNullOrEmpty(shouldArchive)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldArchive, shouldArchive)); if (!string.IsNullOrEmpty(shouldStar)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldStar, shouldStar)); if (!string.IsNullOrEmpty(neverSpam)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.neverSpam, neverSpam)); if (!string.IsNullOrEmpty(forwardTo)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.forwardTo, forwardTo)); if (!string.IsNullOrEmpty(shouldTrash)) entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldTrash, shouldTrash)); return base.Insert(filterUri, entry) as AppsExtendedEntry; }
public void Init() { entry = new AppsExtendedEntry(); }
/// <summary> /// Creates a new Google Mail filter for the given userName /// </summary> /// <param name="userName">The user for whom this should be done</param> /// <param name="from">come-from email address to be filtered</param> /// <param name="to">send-to email address to be filtered</param> /// <param name="subject">a string the email must have on the subject line to be filtered</param> /// <param name="hasTheWords">a string the email can have anywhere in its subject or body</param> /// <param name="doesNotHaveTheWords">a string the email cannot have anywhere in its subject or body</param> /// <param name="hasAttachment">a boolean representing whether or not the emails contains an attachment</param> /// <param name="label">the name of the label to apply if the message matches the filter criteria</param> /// <param name="shouldMarkAsRead">Whether to automatically mark the message as read /// if it matches the filter criteria</param> /// <param name="shouldArchive">Whether to automatically move the message to Archived state /// if it matches the filter criteria</param> /// <param name="shouldStar">Whether to automatically star the message /// if it matches the filter criteria</param> /// <param name="neverSpam">Whether to automatically move the message to Spam state /// if it matches the filter criteria</param> /// <param name="forwardTo">Whether to automatically forward the message to the given /// verified email address if it matches the filter criteria</param> /// <param name="shouldTrash">Whether to automatically move the message to Trash state /// if it matches the filter criteria</param> /// <returns>a <code>AppsExtendedEntry</code> containing the results of the creation</returns> public AppsExtendedEntry CreateFilter(string userName, string from, string to, string subject, string hasTheWords, string doesNotHaveTheWords, string hasAttachment, string label, string shouldMarkAsRead, string shouldArchive, string shouldStar, string neverSpam, string forwardTo, string shouldTrash) { Uri filterUri = new Uri(AppsGoogleMailSettingsNameTable.AppsGoogleMailSettingsBaseFeedUri + "/" + domain + "/" + userName + filterFeedUriSuffix); AppsExtendedEntry entry = new AppsExtendedEntry(); if (!string.IsNullOrEmpty(from)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.from, from)); } if (!string.IsNullOrEmpty(to)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.to, to)); } if (!string.IsNullOrEmpty(subject)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.subject, subject)); } if (!string.IsNullOrEmpty(hasTheWords)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.hasTheWord, hasTheWords)); } if (!string.IsNullOrEmpty(doesNotHaveTheWords)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.doesNotHaveTheWord, doesNotHaveTheWords)); } if (!string.IsNullOrEmpty(hasAttachment)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.hasAttachment, hasAttachment)); } if (!string.IsNullOrEmpty(label)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.label, label)); } if (!string.IsNullOrEmpty(shouldMarkAsRead)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldMarkAsRead, shouldMarkAsRead)); } if (!string.IsNullOrEmpty(shouldArchive)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldArchive, shouldArchive)); } if (!string.IsNullOrEmpty(shouldStar)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldStar, shouldStar)); } if (!string.IsNullOrEmpty(neverSpam)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.neverSpam, neverSpam)); } if (!string.IsNullOrEmpty(forwardTo)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.forwardTo, forwardTo)); } if (!string.IsNullOrEmpty(shouldTrash)) { entry.Properties.Add( new PropertyElement( AppsGoogleMailSettingsNameTable.shouldTrash, shouldTrash)); } return(base.Insert(filterUri, entry) as AppsExtendedEntry); }
/// <summary> /// /// </summary> /// <param name="service"></param> private static void RunSample(OrganizationService service) { try { const String testOrgunit = "TestOrgUnitForSample"; const String testOrgunitDescription = "Test Organization"; // Retrieve customer Id AppsExtendedEntry entry = service.RetrieveCustomerId(service.DomainName); String customerId = entry.getPropertyValueByName(AppsOrganizationNameTable.CustomerId); Console.WriteLine("CustomerId: " + customerId); // Delete, if all already exists try { service.DeleteOrganizationUnit(customerId, testOrgunit); } catch { } // Create a new Organization Unit Console.WriteLine("\n-----------Creating organization unit-----------"); entry = service.CreateOrganizationUnit( customerId, testOrgunit, "/", testOrgunitDescription, false); Console.WriteLine("Created: " + entry.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName)); // Retrieve Organization Unit and list all properties Console.WriteLine("\n-----------Retrieving organization unit---------"); entry = service.RetrieveOrganizationUnit(customerId, testOrgunit); foreach (PropertyElement element in entry.Properties) { Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value)); } // Update organization unit and list all properties Console.WriteLine("\n-----------Updating organization unit----"); IDictionary <OrganizationService.OrgUnitProperty, string> updates = new Dictionary <OrganizationService.OrgUnitProperty, string>(); updates[OrganizationService.OrgUnitProperty.Description] = "Updated description"; entry = service.UpdateOrganizationUnit(customerId, testOrgunit, updates); foreach (PropertyElement element in entry.Properties) { Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value)); } // Retrieve all organization units and list the names Console.WriteLine("\n-----------Retrieving all organization units----"); AppsExtendedFeed feed = service.RetrieveAllOrganizationUnits(customerId); foreach (AppsExtendedEntry unit in feed.Entries) { Console.WriteLine( unit.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName)); } // Retrieve child organization unit of a given unit Console.WriteLine("\n-----------Retrieving child organization units----"); feed = service.RetrieveChildOrganizationUnits(customerId, testOrgunit); foreach (AppsExtendedEntry unit in feed.Entries) { Console.WriteLine( unit.getPropertyValueByName(AppsOrganizationNameTable.OrgUnitName)); } // Retrieve org user Console.WriteLine("\n-----------Retrieving Org User-------------------"); entry = service.RetrieveOrganizationUser(customerId, testUser); Console.WriteLine("Retrieved OrgUser"); foreach (PropertyElement element in entry.Properties) { Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value)); } // update org user i.e. move from one org unit to another Console.WriteLine("\n-----------Updating Org User---------------------"); entry = service.UpdateOrganizationUser(customerId, testUser, testOrgunit, "/"); Console.WriteLine("Updated OrgUser"); foreach (PropertyElement element in entry.Properties) { Console.WriteLine(String.Format("{0} - {1}", element.Name, element.Value)); } // Retrieve all org users Console.WriteLine("\n-----------Retrieving all Org Users--------------"); feed = service.RetrieveAllOrganizationUsers(customerId); Console.WriteLine("Retrieved User count: " + feed.Entries.Count); //using pagination Console.WriteLine("\n--------Retrieving all Org Users(paginated)------"); feed = service.RetrieveFirstPageOrganizationUsers(customerId); Console.WriteLine("Retrieved User count: " + feed.Entries.Count); AtomLink next, prev = null; while ((next = feed.Links.FindService("next", null)) != null && prev != next) { feed = service.RetrieveNextPageFromResumeKey(next.HRef.ToString()); prev = next; Console.WriteLine("Retrieved User count: " + feed.Entries.Count); } // Retrieve org users by org unit Console.WriteLine("\n-----------Retrieving Org Users by orgunit--------------"); feed = service.RetrieveAllOrganizationUsersByOrgUnit(customerId, testOrgunit); Console.WriteLine("Retrieved User count: " + feed.Entries.Count); //cleanup try { Console.WriteLine("\nCleaning up..."); entry = service.UpdateOrganizationUser(customerId, testUser, "/", testOrgunit); service.DeleteOrganizationUnit(customerId, testOrgunit); } catch { } } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
/// <summary> /// /// </summary> /// <param name="service"></param> private static void RunSample(AuditService service) { //A sample base64 encoded PGP format key string sampleKey = "LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tClZlcnNpb246IEdudVBHIHYxLjQu\n" + "MTAgKEdOVS9MaW51eCkKCm1RRU5CRXhGbWM0QkNBRG9RUU5OVzdRQTB5anNIWkhNVEY5RU9pMjJa\n" + "TTR2QkQrK3E5TkNvME5OcTA1b0R1WDQKR3JUWFVGdk9KV1ZoVDNtdCtaaCtSQlBhS3NYVUd3ZEpw\n" + "R1ZzMk4rbzZyMXF6TXorZ0paNEN3NDJZMzNRbjZJRgpPOTh4Mkh0TVNTUGk1QlVTYlExSnA3czYx\n" + "MVlPMWtzTmtUOFpiSDAvSHErcUhSQzF6L1g4cVZNK3hlSGh4Ull6Cml6MEx2bytYZGMvNDUwRUEx\n" + "dkRhNTRyM3Z5MUFIT0xhWDRpcmFzQ0I4N3NLV0YxcUp6UTQ5Zkw5SnRxZWVDOFAKYUtVbmlmQi9h\n" + "UXNHdER2cGVVVWt6NDRPRjB5R2pjRTg3b1NHTTdWSEJxZmVKb0xubStzYmgyWkZaSnZEZWVJWAph\n" + "ZzJSS3hpakJhcGlmR0xCcGkvc0p6c3pDekUrOFhFRDBCVEJBQkVCQUFHMEprTnNZWFZrYVc4Z1Ey\n" + "aGxjblZpCmFXNXZJRHhqYkdGMVpHbHZRR2R2YjJkc1pTNWpiMjAraVFFNEJCTUJBZ0FpQlFKTVJa\n" + "bk9BaHNEQmdzSkNBY0QKQWdZVkNBSUpDZ3NFRmdJREFRSWVBUUlYZ0FBS0NSRGJmeldDc0dtQWUw\n" + "SzRCLzlZaEpGdXN3NGE5Q1JEYXU2dgpDVnJNRTlrVko4UmxocEpCZEY2V1pndGRPZlhsbzJycEVt\n" + "Q1FRZ0lCRGJEeS9aQ3JHRWZDWlRIa0VLeXQrVVNpCndnUWY3NFRZZ0NzMTR0WmF5WHZKT3dENkIz\n" + "QW1NYkRtQVFVM0ppdVRaMXIzZEZYV3BnUTE4RDI0YUEwcGVCOWMKbmcwbXc0enhGUW15b29paG14\n" + "NWwvZmZ4UDFQUHNrL1kvV3F5ck5HQVhDUGxmRUFRdFN3bWRGYXNoVjYyZElEdwpOZXBMeTZSeE15\n" + "TFRTL2ZvMExmSnEreWVjWjZkck91bTlkUnA3T0ZUOERSWmNqSTQ4eVM5VFNMd1Rtc0hHUm1uCkNO\n" + "Nk1BWnBaK2lkVks5VEkveXVhOG4xQndNU3kwU3NGSjVpSG8wUFFHbSt5MHZxcDdGN2RCUlVCYWFw\n" + "MGc0K3QKOTEyRQo9aFpYYwotLS0tLUVORCBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCg=="; try { // Upload public key Console.WriteLine("\n-----------Uploading public key-----------"); AppsExtendedEntry keyEntry = service.UploadPublicKey(sampleKey); // Setting the parameters for a MailMonitor request MailMonitor monitor = new MailMonitor(); monitor.BeginDate = new DateTime(2011, 6, 15); monitor.EndDate = new DateTime(2011, 6, 30, 23, 20, 0); monitor.IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE; monitor.OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY; monitor.DraftMonitorLevel = MonitorLevel.FULL_MESSAGE; monitor.ChatMonitorLevel = MonitorLevel.FULL_MESSAGE; monitor.DestinationUserName = destUsername; // Send the MailMonitor creation request Console.WriteLine("\n-----------Creating mail monitor-----------"); MailMonitor monitorEntry = service.CreateMailMonitor(srcUsername, monitor); // Retrieve all MailMonitors for the source user Console.WriteLine("\n-----------Retrieving all mail monitors-----------"); GenericFeed <MailMonitor> monitors = service.RetrieveMailMonitors(srcUsername); foreach (MailMonitor m in monitors.Entries) { Console.WriteLine(m.DestinationUserName); } // Delete MailMonitor Console.WriteLine("\n-----------Deleting mail monitor-----------"); service.DeleteMailMonitor(srcUsername, destUsername); // Create Account Info request Console.WriteLine("\n-----------Creating account info request-----------"); AccountInfo accountInfoRequest = service.CreateAccountInfoRequest(srcUsername); Console.WriteLine("Request ID: " + accountInfoRequest.RequestId); // Retrieve Account Info request Console.WriteLine("\n-----------Retrieving account info request-----------"); AccountInfo accountInfo = service.RetrieveAccountInfoRequest(srcUsername, accountInfoRequest.RequestId); Console.WriteLine("Status: " + accountInfo.Status); // Retrieve all Account Info requests from April 1st 2011 Console.WriteLine("\n-----------Retrieving all account info requests-----------"); GenericFeed <AccountInfo> accountInfoRequests = service.RetrieveAllAccountInfoRequests(new DateTime(2011, 4, 1)); foreach (AccountInfo info in accountInfoRequests.Entries) { Console.WriteLine(info.RequestId + " - " + info.Status); } // Delete Account Info request // This can only be done when the Status is COMPLETED or MARKED_DELETE //Console.WriteLine("\n-----------Deleting the account info request-----------"); //service.DeleteAccountInfoRequest(srcUsername, accountInfoRequest.RequestId); // Setting the parameters for a MailboxDump request MailboxDumpRequest mailboxDumpRequest = new MailboxDumpRequest(); mailboxDumpRequest.BeginDate = new DateTime(2009, 6, 15); mailboxDumpRequest.EndDate = new DateTime(2009, 6, 30, 23, 20, 0); mailboxDumpRequest.SearchQuery = "in:chat"; mailboxDumpRequest.PackageContent = MonitorLevel.FULL_MESSAGE; // Create Mailbox Dump request Console.WriteLine("\n-----------Creating mailbox dump request-----------"); MailboxDumpRequest dumpRequest = service.CreateMailboxDumpRequest(srcUsername, mailboxDumpRequest); Console.WriteLine("Request ID: " + dumpRequest.RequestId); // Retrieve Mailbox Dump request Console.WriteLine("\n-----------Retrieving mailbox dump request-----------"); MailboxDumpRequest checkRequest = service.RetrieveMailboxDumpRequest(srcUsername, dumpRequest.RequestId); Console.WriteLine("Status: " + dumpRequest.Status); // Retrieve all Mailbox Dump requests Console.WriteLine("\n-----------Retrieving all mailbox dump requests-----------"); GenericFeed <MailboxDumpRequest> dumpRequests = service.RetrieveAllMailboxDumpRequests(); foreach (MailboxDumpRequest dump in dumpRequests.Entries) { Console.WriteLine(dump.RequestId + " - " + dump.Status); } // Delete Mailbox Dump request // This can only be done when the Status is COMPLETED or MARKED_DELETE //Console.WriteLine("\n-----------Deleting the mailbox dump request-----------"); //service.DeleteMailboxDumpRequest(srcUsername, dumpRequest.RequestId); } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }