public ApiInterfaceContact(string domain, string dnPrefix, MASchemaType type, IManagementAgentParameters config) { this.domain = domain; this.SchemaType = type; this.dnPrefix = dnPrefix; this.config = config; }
private static void AddUserExternalIds(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield value = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = null }; AdapterCustomTypeList <ExternalID> customType = new AdapterCustomTypeList <ExternalID> { Api = "user", AttributeName = "externalIds", Fields = new List <AdapterSubfield>() { value }, FieldName = "externalIds", PropertyName = "ExternalIds", KnownTypes = config.ExternalIDsAttributeFixedTypes?.ToList(), SupportsPatch = false }; type.AttributeAdapters.Add(customType); }
private static void AddUserPhonesAttributes(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield phonesValue = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = null }; AdapterCustomTypeList <Phone> phonesType = new AdapterCustomTypeList <Phone> { Api = "user", AttributeName = "phones", Fields = new List <AdapterSubfield>() { phonesValue }, FieldName = "phones", PropertyName = "Phones", IsPrimaryCandidateType = true, KnownTypes = config.PhonesAttributeFixedTypes?.ToList(), SupportsPatch = false }; type.AttributeAdapters.Add(phonesType); }
private static void AddGroupAliases(MASchemaType type) { AdapterCollection <string> aliasesList = new AdapterCollection <string> { Api = "groupaliases", AttributeName = "aliases", FieldName = "aliases", PropertyName = "Aliases", SupportsPatch = true, Operation = AttributeOperation.ImportExport }; type.AttributeAdapters.Add(aliasesList); AdapterCollection <string> nonEditableAliasesList = new AdapterCollection <string> { Api = "group", AttributeName = "nonEditableAliases", FieldName = "nonEditableAliases", PropertyName = "NonEditableAliases", SupportsPatch = false, Operation = AttributeOperation.ImportOnly }; type.AttributeAdapters.Add(nonEditableAliasesList); }
private void AddContactExternalIds(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield value = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = null }; AdapterGDataSimpleAttributeList <ExternalId> customType = new AdapterGDataSimpleAttributeList <ExternalId> { Api = "contact", AttributeName = "externalIds", Fields = new List <AdapterSubfield>() { value }, FieldName = "externalIds", PropertyName = "ExternalIds", KnownTypes = config.ExternalIDsAttributeFixedTypes?.ToList(), SupportsPatch = false, KnownRels = new HashSet <string>() { "account", "customer", "network", "organization" } }; type.AttributeAdapters.Add(customType); }
private void AddContactEmailAttributes(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield address = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "address", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Address", AttributeNamePart = null }; AdapterGDataCommonAttributeList <EMail> customType = new AdapterGDataCommonAttributeList <EMail> { Api = "contact", AttributeName = "email", Fields = new List <AdapterSubfield>() { address }, FieldName = "email", PropertyName = "Emails", KnownTypes = config.EmailsAttributeFixedTypes?.ToList(), SupportsPatch = false, IsEmpty = (t) => string.IsNullOrWhiteSpace(t.Address), KnownRels = new Dictionary <string, string>() { { "http://schemas.google.com/g/2005#work", "work" }, { "http://schemas.google.com/g/2005#home", "home" }, { "http://schemas.google.com/g/2005#other", "other" } } }; type.AttributeAdapters.Add(customType); }
private static void AddGmailSettingsAttributes(MASchemaType type, IManagementAgentParameters config) { AdapterCollection <string> delegates = new AdapterCollection <string> { AttributeType = AttributeType.Reference, FieldName = null, Operation = AttributeOperation.ImportExport, AttributeName = $"{type.Name}_{SchemaConstants.Delegate}", PropertyName = "Delegates", Api = "userdelegates", SupportsPatch = true, }; type.AttributeAdapters.Add(delegates); AdapterCollection <string> sendas = new AdapterCollection <string> { AttributeType = AttributeType.String, FieldName = null, Operation = AttributeOperation.ImportExport, AttributeName = $"{type.Name}_{SchemaConstants.SendAs}", PropertyName = "SendAs", Api = "usersendas", SupportsPatch = true, }; type.AttributeAdapters.Add(sendas); }
public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config) { MASchemaType type = new MASchemaType { AttributeAdapters = new List <IAttributeAdapter>(), Name = "feature", AnchorAttributeNames = new[] { "id" }, SupportsPatch = true, }; type.ApiInterface = new ApiInterfaceFeature(config.CustomerID, type, config); type.AttributeAdapters.Add(new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "name", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "id", PropertyName = "Name", Api = "feature", SupportsPatch = true, IsAnchor = true }); yield return(type); }
public ApiInterfaceCalendar(string customerID, MASchemaType type, IManagementAgentParameters config) { this.SchemaType = type; this.customerID = customerID; this.config = config; this.internalInterfaces = new ApiInterfaceKeyedCollection { new ApiInterfaceCalendarAcl(config), }; }
public ApiInterfaceGroup(MASchemaType type, IManagementAgentParameters config) { this.SchemaType = type; this.config = config; this.internalInterfaces = new ApiInterfaceKeyedCollection { new ApiInterfaceGroupAliases(config), new ApiInterfaceGroupMembership(config), new ApiInterfaceGroupSettings(config) }; }
public ApiInterfaceCourse(MASchemaType type, IManagementAgentParameters config) { this.SchemaType = type; this.config = config; this.internalInterfaces = new ApiInterfaceKeyedCollection { new ApiInterfaceCourseStudents(config, this), new ApiInterfaceCourseTeachers(config, this) }; this.UserMappingCache = new ConcurrentDictionary <string, string>(); }
private void AddContactPhones(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield phonesValue = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = null }; AdapterGDataCommonAttributeList <PhoneNumber> phonesType = new AdapterGDataCommonAttributeList <PhoneNumber> { Api = "contact", AttributeName = "phones", Fields = new List <AdapterSubfield>() { phonesValue }, FieldName = "phones", PropertyName = "Phonenumbers", KnownTypes = config.PhonesAttributeFixedTypes?.ToList(), SupportsPatch = false, IsEmpty = (t) => string.IsNullOrWhiteSpace(t.Value), KnownRels = new Dictionary <string, string>() { { "http://schemas.google.com/g/2005#work_pager", "work_pager" }, { "http://schemas.google.com/g/2005#work_mobile", "work_mobile" }, { "http://schemas.google.com/g/2005#work", "work" }, { "http://schemas.google.com/g/2005#tty_tdd", "tty_tdd" }, { "http://schemas.google.com/g/2005#telex", "telex" }, { "http://schemas.google.com/g/2005#radio", "radio" }, { "http://schemas.google.com/g/2005#pager", "pager" }, { "http://schemas.google.com/g/2005#other_fax", "other_fax" }, { "http://schemas.google.com/g/2005#mobile", "mobile" }, { "http://schemas.google.com/g/2005#main", "main" }, { "http://schemas.google.com/g/2005#isdn", "isdn" }, { "http://schemas.google.com/g/2005#home_fax", "home_fax" }, { "http://schemas.google.com/g/2005#home", "home" }, { "http://schemas.google.com/g/2005#fax", "fax" }, { "http://schemas.google.com/g/2005#company_main", "company_main" }, { "http://schemas.google.com/g/2005#car", "car" }, { "http://schemas.google.com/g/2005#callback", "callback" }, { "http://schemas.google.com/g/2005#assistant", "assistant" }, } }; type.AttributeAdapters.Add(phonesType); }
public ApiInterfaceUser(MASchemaType type, IManagementAgentParameters config) { this.InternalInterfaces = new ApiInterfaceKeyedCollection { new ApiInterfaceUserAliases(config), new ApiInterfaceUserMakeAdmin(config), new ApiInterfaceUserDelegates(config, type.Name), new ApiInterfaceUserSendAs(config, type.Name) }; this.ObjectClass = type.Name; this.SchemaType = type; this.config = config; }
private void AddContactNames(MASchemaType type) { AdapterSubfield givenName = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "givenName", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "GivenName", AttributeNamePart = "givenName", NullValueRepresentation = NullValueRepresentation.NullPlaceHolder }; AdapterSubfield familyName = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "familyName", IsMultivalued = false, PropertyName = "FamilyName", Operation = AttributeOperation.ImportExport, AttributeNamePart = "familyName", NullValueRepresentation = NullValueRepresentation.NullPlaceHolder }; AdapterSubfield fullName = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "fullName", IsMultivalued = false, PropertyName = "FullName", Operation = AttributeOperation.ImportExport, AttributeNamePart = "fullName", NullValueRepresentation = NullValueRepresentation.NullPlaceHolder }; AdapterNestedType schemaItem = new AdapterNestedType { Api = "contact", AttributeName = "name", Fields = new List <AdapterSubfield>() { givenName, familyName, fullName }, FieldName = "name", PropertyName = "Name", SupportsPatch = false }; type.AttributeAdapters.Add(schemaItem); }
private static void AddTeachers(MASchemaType type) { AdapterCollection <string> teachers = new AdapterCollection <string> { AttributeType = AttributeType.Reference, FieldName = "userId", Operation = AttributeOperation.ImportExport, AttributeName = "teachers", PropertyName = "Teachers", Api = "courseteachers", SupportsPatch = true }; type.AttributeAdapters.Add(teachers); }
private void AddContactIms(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield im = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "address", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Address", AttributeNamePart = "address" }; AdapterSubfield protocol = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "protocol", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Protocol", AttributeNamePart = "protocol" }; AdapterGDataCommonAttributeList <IMAddress> customType = new AdapterGDataCommonAttributeList <IMAddress> { Api = "contact", AttributeName = "ims", Fields = new List <AdapterSubfield>() { im, protocol }, FieldName = "ims", PropertyName = "IMs", KnownTypes = config.IMsAttributeFixedTypes?.ToList(), SupportsPatch = false, IsEmpty = (t) => string.IsNullOrWhiteSpace(t.Address), KnownRels = new Dictionary <string, string>() { { "http://schemas.google.com/g/2005#work", "work" }, { "http://schemas.google.com/g/2005#netmeeting", "netmeeting" }, { "http://schemas.google.com/g/2005#home", "home" } } }; type.AttributeAdapters.Add(customType); }
public static CSEntryChangeResult PutCSEntryChangeObject(CSEntryChange csentry, SchemaType type, IManagementAgentParameters config) { MASchemaType maType = ManagementAgent.Schema[type.Name]; CSEntryChangeDetached deltaCSEntry = new CSEntryChangeDetached(Guid.NewGuid(), ObjectModificationType.Unconfigured, MAImportError.Success, null); foreach (var anchorAttributeName in maType.AnchorAttributeNames) { AnchorAttribute anchor = csentry.GetAnchorAttribute(anchorAttributeName); if (anchor != null) { deltaCSEntry.AnchorAttributes.Add(anchor); } } deltaCSEntry.ObjectType = csentry.ObjectType; try { switch (csentry.ObjectModificationType) { case ObjectModificationType.Add: return(ExportProcessor.PutCSEntryChangeAdd(csentry, deltaCSEntry, maType, type, config)); case ObjectModificationType.Delete: return(ExportProcessor.PutCSEntryChangeDelete(csentry, deltaCSEntry, maType)); case ObjectModificationType.Update: return(ExportProcessor.PutCSEntryChangeUpdate(csentry, deltaCSEntry, maType, type, config)); default: case ObjectModificationType.None: case ObjectModificationType.Replace: case ObjectModificationType.Unconfigured: throw new InvalidOperationException($"Unknown or unsupported modification type: {csentry.ObjectModificationType} on object {csentry.DN}"); } } finally { CSEntryChangeQueue.Add(deltaCSEntry); } }
public static CSEntryChange GetCSEntryChange(object source, SchemaType type, IManagementAgentParameters config) { MASchemaType maType = ManagementAgent.Schema[type.Name]; CSEntryChange csentry = CSEntryChange.Create(); csentry.ObjectModificationType = ObjectModificationType.Add; csentry.ObjectType = type.Name; foreach (string anchorAttributeName in maType.AnchorAttributeNames) { string anchorValue = maType.ApiInterface.GetAnchorValue(anchorAttributeName, source); if (anchorValue == null) { throw new AttributeNotPresentException(anchorAttributeName); } csentry.CreateAttributeAdd(anchorAttributeName, anchorValue); } try { csentry.DN = maType.ApiInterface.GetDNValue(source); foreach (AttributeChange change in maType.ApiInterface.GetChanges(csentry.DN, csentry.ObjectModificationType, type, source)) { csentry.AttributeChanges.Add(change); } Trace.WriteLine($"Created CSEntryChange for {csentry.ObjectType} {csentry.DN}"); } catch (Exception ex) { Logging.Logger.WriteException(ex); csentry.ErrorCodeImport = MAImportError.ImportErrorCustomContinueRun; csentry.ErrorDetail = ex.StackTrace; csentry.ErrorName = ex.Message; Trace.WriteLine($"Error creating CSEntryChange for {csentry.ObjectType} {csentry.DN} - {ex.Message}"); } return(csentry); }
private static void AddCalendarAcls(MASchemaType type) { type.AttributeAdapters.Add(new AdapterPlaceholder { AttributeType = AttributeType.Reference, IsMultivalued = true, FieldName = "scope.value", Operation = AttributeOperation.ImportExport, AttributeName = "freeBusyReader", Api = "calendaracl", }); type.AttributeAdapters.Add(new AdapterPlaceholder { AttributeType = AttributeType.Reference, IsMultivalued = true, FieldName = "scope.value", Operation = AttributeOperation.ImportExport, AttributeName = "reader", Api = "calendaracl", }); type.AttributeAdapters.Add(new AdapterPlaceholder { AttributeType = AttributeType.Reference, IsMultivalued = true, FieldName = "scope.value", Operation = AttributeOperation.ImportExport, AttributeName = "writer", Api = "calendaracl", }); type.AttributeAdapters.Add(new AdapterPlaceholder { AttributeType = AttributeType.Reference, IsMultivalued = true, FieldName = "scope.value", Operation = AttributeOperation.ImportExport, AttributeName = "owner", Api = "calendaracl", }); }
private static void AddGroupMembersRaw(MASchemaType type) { AdapterCollection <string> members = new AdapterCollection <string> { AttributeType = AttributeType.String, FieldName = "email", Operation = AttributeOperation.ImportExport, AttributeName = "member_raw", PropertyName = "Members", Api = "groupmembership", SupportsPatch = true, }; type.AttributeAdapters.Add(members); AdapterCollection <string> managers = new AdapterCollection <string> { AttributeType = AttributeType.String, FieldName = "email", Operation = AttributeOperation.ImportExport, AttributeName = "manager_raw", PropertyName = "Managers", Api = "groupmembership", SupportsPatch = true, }; type.AttributeAdapters.Add(managers); AdapterCollection <string> owners = new AdapterCollection <string> { AttributeType = AttributeType.String, FieldName = "email", Operation = AttributeOperation.ImportExport, AttributeName = "owner_raw", PropertyName = "Owners", Api = "groupmembership", SupportsPatch = true, }; type.AttributeAdapters.Add(owners); }
public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config) { MASchemaType type = new MASchemaType { AttributeAdapters = new List <IAttributeAdapter>(), Name = SchemaConstants.User, AnchorAttributeNames = new[] { "id" }, SupportsPatch = true, }; this.BuildBaseSchema(type, config); if (config.EnableAdvancedUserAttributes) { SchemaBuilderUsers.AddGmailSettingsAttributes(type, config); } yield return(type); if (!config.SchemaService.HasSchema(config.CustomerID, SchemaConstants.CustomGoogleAppsSchemaName)) { yield break; } foreach (string objectType in config.CustomUserObjectClasses) { type = new MASchemaType { AttributeAdapters = new List <IAttributeAdapter>(), Name = objectType, AnchorAttributeNames = new[] { "id" }, SupportsPatch = true, }; this.BuildBaseSchema(type, config); SchemaBuilderUsers.AddGmailSettingsAttributes(type, config); yield return(type); } }
private static void AddUserIms(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield im = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "im", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "IMAddress", AttributeNamePart = "address" }; AdapterSubfield protocol = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "protocol", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Protocol", AttributeNamePart = "protocol" }; AdapterCustomTypeList <IM> customType = new AdapterCustomTypeList <IM> { Api = "user", AttributeName = "ims", Fields = new List <AdapterSubfield>() { im, protocol }, FieldName = "ims", PropertyName = "Ims", IsPrimaryCandidateType = true, KnownTypes = config.IMsAttributeFixedTypes?.ToList(), SupportsPatch = false }; type.AttributeAdapters.Add(customType); }
private static void AddUserWebSites(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield webSiteValue = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = null }; AdapterSubfield webSitePrimary = new AdapterSubfield { AttributeType = AttributeType.Boolean, FieldName = "primary", IsMultivalued = false, PropertyName = "Primary", Operation = AttributeOperation.ImportExport, AttributeNamePart = "primary" }; AdapterCustomTypeList <ManagedObjects.Website> webSiteType = new AdapterCustomTypeList <Website> { Api = "user", AttributeName = "websites", Fields = new List <AdapterSubfield>() { webSitePrimary, webSiteValue }, FieldName = "websites", PropertyName = "Websites", IsPrimaryCandidateType = true, KnownTypes = config.WebsitesAttributeFixedTypes?.ToList(), SupportsPatch = false }; type.AttributeAdapters.Add(webSiteType); }
private static void AddUserNotes(MASchemaType type) { AdapterSubfield notesValue = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "value", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Value", AttributeNamePart = "value", NullValueRepresentation = NullValueRepresentation.NullPlaceHolder }; AdapterSubfield notesContentType = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "contentType", IsMultivalued = false, PropertyName = "ContentType", Operation = AttributeOperation.ImportExport, AttributeNamePart = "contentType", NullValueRepresentation = NullValueRepresentation.NullPlaceHolder }; AdapterNestedType notesType = new AdapterNestedType { Api = "user", AttributeName = "notes", Fields = new List <AdapterSubfield>() { notesContentType, notesValue }, FieldName = "notes", PropertyName = "Notes", SupportsPatch = false }; type.AttributeAdapters.Add(notesType); }
private static void AddGroupSettings(MASchemaType type) { AdapterPropertyValue includeCustomFooter = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "includeCustomFooter", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "includeCustomFooter", PropertyName = "IncludeCustomFooter", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(includeCustomFooter); AdapterPropertyValue customFooterText = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "customFooterText", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "customFooterText", PropertyName = "CustomFooterText", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(customFooterText); AdapterPropertyValue whoCanJoin = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanJoin", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanJoin", PropertyName = "WhoCanJoin", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanJoin); AdapterPropertyValue whoCanViewMembership = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanViewMembership", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanViewMembership", PropertyName = "WhoCanViewMembership", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanViewMembership); AdapterPropertyValue whoCanViewGroup = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanViewGroup", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanViewGroup", PropertyName = "WhoCanViewGroup", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanViewGroup); AdapterPropertyValue whoCanInvite = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanInvite", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanInvite", PropertyName = "WhoCanInvite", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanInvite); AdapterPropertyValue whoCanAdd = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanAdd", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanAdd", PropertyName = "WhoCanAdd", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanAdd); AdapterPropertyValue whoCanModerateMembers = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanModerateMembers", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanModerateMembers", PropertyName = "WhoCanModerateMembers", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanModerateMembers); AdapterPropertyValue allowExternalMembers = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "allowExternalMembers", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "allowExternalMembers", PropertyName = "AllowExternalMembers", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(allowExternalMembers); AdapterPropertyValue whoCanPostMessage = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanPostMessage", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanPostMessage", PropertyName = "WhoCanPostMessage", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanPostMessage); AdapterPropertyValue allowWebPosting = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "allowWebPosting", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "allowWebPosting", PropertyName = "AllowWebPosting", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(allowWebPosting); AdapterPropertyValue primaryLanguage = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "primaryLanguage", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "primaryLanguage", PropertyName = "PrimaryLanguage", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(primaryLanguage); AdapterPropertyValue maxMessageBytes = new AdapterPropertyValue { AttributeType = AttributeType.Integer, FieldName = "maxMessageBytes", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "maxMessageBytes", PropertyName = "MaxMessageBytes", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForExport = (value) => { if (value == null) { return(null); } return(Convert.ToInt32((long)value)); } }; type.AttributeAdapters.Add(maxMessageBytes); AdapterPropertyValue isArchived = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "isArchived", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "isArchived", PropertyName = "IsArchived", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(isArchived); AdapterPropertyValue archiveOnly = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "archiveOnly", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "archiveOnly", PropertyName = "ArchiveOnly", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(archiveOnly); AdapterPropertyValue messageModerationLevel = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "messageModerationLevel", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "messageModerationLevel", PropertyName = "MessageModerationLevel", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(messageModerationLevel); AdapterPropertyValue spamModerationLevel = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "spamModerationLevel", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "spamModerationLevel", PropertyName = "SpamModerationLevel", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(spamModerationLevel); AdapterPropertyValue replyTo = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "replyTo", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "replyTo", PropertyName = "ReplyTo", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(replyTo); AdapterPropertyValue customReplyTo = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "customReplyTo", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "customReplyTo", PropertyName = "CustomReplyTo", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => string.IsNullOrEmpty((string)i) ? null : i, }; type.AttributeAdapters.Add(customReplyTo); AdapterPropertyValue sendMessageDenyNotification = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "sendMessageDenyNotification", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "sendMessageDenyNotification", PropertyName = "SendMessageDenyNotification", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(sendMessageDenyNotification); AdapterPropertyValue defaultMessageDenyNotificationText = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "defaultMessageDenyNotificationText", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "defaultMessageDenyNotificationText", PropertyName = "DefaultMessageDenyNotificationText", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => string.IsNullOrEmpty((string)i) ? null : i, }; type.AttributeAdapters.Add(defaultMessageDenyNotificationText); AdapterPropertyValue showInGroupDirectory = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "showInGroupDirectory", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "showInGroupDirectory", PropertyName = "ShowInGroupDirectory", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(showInGroupDirectory); AdapterPropertyValue allowGoogleCommunication = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "allowGoogleCommunication", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "allowGoogleCommunication", PropertyName = "AllowGoogleCommunication", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(allowGoogleCommunication); AdapterPropertyValue membersCanPostAsTheGroup = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "membersCanPostAsTheGroup", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "membersCanPostAsTheGroup", PropertyName = "MembersCanPostAsTheGroup", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(membersCanPostAsTheGroup); AdapterPropertyValue messageDisplayFont = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "messageDisplayFont", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "messageDisplayFont", PropertyName = "MessageDisplayFont", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(messageDisplayFont); AdapterPropertyValue includeInGlobalAddressList = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "includeInGlobalAddressList", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "includeInGlobalAddressList", PropertyName = "IncludeInGlobalAddressList", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(includeInGlobalAddressList); AdapterPropertyValue whoCanLeaveGroup = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanLeaveGroup", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanLeaveGroup", PropertyName = "WhoCanLeaveGroup", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanLeaveGroup); AdapterPropertyValue whoCanContactOwner = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "whoCanContactOwner", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "whoCanContactOwner", PropertyName = "WhoCanContactOwner", Api = "groupsettings", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, }; type.AttributeAdapters.Add(whoCanContactOwner); }
private static void AddUserAddresses(MASchemaType type, IManagementAgentParameters config) { AdapterSubfield sourceIsStructured = new AdapterSubfield { AttributeType = AttributeType.Boolean, FieldName = "sourceIsStructured", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "SourceIsStructured", AttributeNamePart = "sourceIsStructured" }; AdapterSubfield formatted = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "formatted", IsMultivalued = false, PropertyName = "Formatted", Operation = AttributeOperation.ImportExport, AttributeNamePart = "formatted" }; AdapterSubfield poBox = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "poBox", IsMultivalued = false, PropertyName = "POBox", Operation = AttributeOperation.ImportExport, AttributeNamePart = "poBox" }; AdapterSubfield extendedAddress = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "extendedAddress", IsMultivalued = false, PropertyName = "ExtendedAddress", Operation = AttributeOperation.ImportExport, AttributeNamePart = "extendedAddress" }; AdapterSubfield streetAddress = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "streetAddress", IsMultivalued = false, PropertyName = "StreetAddress", Operation = AttributeOperation.ImportExport, AttributeNamePart = "streetAddress" }; AdapterSubfield locality = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "locality", IsMultivalued = false, PropertyName = "Locality", Operation = AttributeOperation.ImportExport, AttributeNamePart = "locality" }; AdapterSubfield region = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "region", IsMultivalued = false, PropertyName = "Region", Operation = AttributeOperation.ImportExport, AttributeNamePart = "region" }; AdapterSubfield postalCode = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "postalCode", IsMultivalued = false, PropertyName = "PostalCode", Operation = AttributeOperation.ImportExport, AttributeNamePart = "postalCode" }; AdapterSubfield country = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "country", IsMultivalued = false, PropertyName = "Country", Operation = AttributeOperation.ImportExport, AttributeNamePart = "country" }; AdapterSubfield countryCode = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "countryCode", IsMultivalued = false, PropertyName = "CountryCode", Operation = AttributeOperation.ImportExport, AttributeNamePart = "countryCode" }; AdapterCustomTypeList <Address> customType = new AdapterCustomTypeList <Address> { Api = "user", AttributeName = "addresses", Fields = new List <AdapterSubfield>() { sourceIsStructured, formatted, poBox, extendedAddress, streetAddress, locality, region, postalCode, country, countryCode }, FieldName = "addresses", PropertyName = "Addresses", IsPrimaryCandidateType = true, KnownTypes = config.AddressesAttributeFixedTypes?.ToList(), SupportsPatch = false }; type.AttributeAdapters.Add(customType); }
private static void AddUserCustomSchema(MASchemaType type, IManagementAgentParameters config) { G.Schemas schemas = null; try { schemas = config.SchemaService.ListSchemas(config.CustomerID); } catch (Google.GoogleApiException ex) { if (ex.HttpStatusCode == System.Net.HttpStatusCode.Forbidden) { Trace.WriteLine("Permission to read the user custom schema was denied"); return; } throw; } catch (TokenResponseException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.Forbidden || ex.StatusCode == System.Net.HttpStatusCode.Unauthorized) { Trace.WriteLine("Permission related TokenResponseException while reading the user custom schema"); return; } } if (schemas?.SchemasValue == null) { return; } AdapterCustomSchemas customSchemas = new AdapterCustomSchemas(); customSchemas.Api = "user"; foreach (G.Schema schema in schemas.SchemasValue) { if (schema.SchemaName.Equals(SchemaConstants.CustomGoogleAppsSchemaName)) { continue; } AdapterCustomSchema customSchema = new AdapterCustomSchema(); customSchema.SchemaName = schema.SchemaName; foreach (G.SchemaFieldSpec field in schema.Fields) { AdapterCustomSchemaField f; if (field.MultiValued ?? false) { f = new AdapterCustomSchemaMultivaluedField(); } else { f = new AdapterCustomSchemaSingleValuedField(); } switch (field.FieldType.ToLowerInvariant()) { case "int64": f.AttributeType = AttributeType.Integer; break; case "bool": f.AttributeType = AttributeType.Boolean; break; default: f.AttributeType = AttributeType.String; break; } if (f.IsMultivalued && !(f.AttributeType == AttributeType.String || f.AttributeType == AttributeType.Integer)) { continue; } f.FieldName = $"{field.FieldName}"; f.SchemaName = schema.SchemaName; f.Operation = AttributeOperation.ImportExport; f.MmsAttributeName = Regex.Replace($"{schema.SchemaName}_{field.FieldName}", "[^a-zA-Z0-9_\\-]", "_", RegexOptions.IgnoreCase); f.PropertyName = $"{field.FieldName}"; f.NullValueRepresentation = NullValueRepresentation.NullPlaceHolder; f.FieldSpec = field; customSchema.Fields.Add(f); } if (customSchema.Fields.Count > 0) { customSchemas.CustomSchemas.Add(customSchema); } } if (customSchemas.CustomSchemas.Count > 0) { type.AttributeAdapters.Add(customSchemas); } }
public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config) { MASchemaType type = new MASchemaType { AttributeAdapters = new List <IAttributeAdapter>(), Name = "group", AnchorAttributeNames = new[] { "id" }, SupportsPatch = true, }; type.ApiInterface = new ApiInterfaceGroup(type, config); AdapterPropertyValue adminCreated = new AdapterPropertyValue { AttributeType = AttributeType.Boolean, FieldName = "adminCreated", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "adminCreated", PropertyName = "AdminCreated", Api = "group", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.NullPlaceHolder, CastForImport = (i) => i ?? false }; type.AttributeAdapters.Add(adminCreated); AdapterPropertyValue description = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "description", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "description", PropertyName = "Description", Api = "group", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.EmptyString, }; type.AttributeAdapters.Add(description); AdapterPropertyValue email = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "email", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "primaryEmail", PropertyName = "Email", Api = "group", SupportsPatch = true, }; type.AttributeAdapters.Add(email); AdapterPropertyValue id = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "id", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "id", PropertyName = "Id", Api = "group", SupportsPatch = true, IsAnchor = true, }; type.AttributeAdapters.Add(id); AdapterPropertyValue name = new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "name", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "name", PropertyName = "Name", Api = "group", SupportsPatch = true, }; type.AttributeAdapters.Add(name); SchemaBuilderGroups.AddGroupAliases(type); SchemaBuilderGroups.AddGroupSettings(type); if (config.MembersAsNonReference) { SchemaBuilderGroups.AddGroupMembersRaw(type); } else { SchemaBuilderGroups.AddGroupMembers(type); } yield return(type); }
public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config) { MASchemaType type = new MASchemaType { AttributeAdapters = new List <IAttributeAdapter>(), Name = "building", AnchorAttributeNames = new[] { "id" }, SupportsPatch = true, }; type.ApiInterface = new ApiInterfaceBuilding(config.CustomerID, type, config); type.AttributeAdapters.Add(new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "buildingId", IsMultivalued = false, Operation = AttributeOperation.ImportOnly, AttributeName = "id", PropertyName = "BuildingId", Api = "building", SupportsPatch = true, IsAnchor = true }); type.AttributeAdapters.Add(new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "buildingName", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "buildingName", PropertyName = "BuildingName", Api = "building", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.EmptyString, IsAnchor = false }); type.AttributeAdapters.Add(new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "description", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "description", PropertyName = "Description", Api = "building", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.EmptyString, IsAnchor = false }); type.AttributeAdapters.Add(new AdapterPropertyValue { AttributeType = AttributeType.String, FieldName = "floorNames", IsMultivalued = false, Operation = AttributeOperation.ImportExport, AttributeName = "floorNames", PropertyName = "FloorNames", Api = "building", SupportsPatch = true, NullValueRepresentation = NullValueRepresentation.EmptyString, CastForExport = i => ((string)i)?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), CastForImport = i => i == null ? null : string.Join(",", ((IList <string>)i)), IsAnchor = false }); AdapterSubfield latitude = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "latitude", IsMultivalued = false, Operation = AttributeOperation.ImportExport, PropertyName = "Latitude", AttributeNamePart = "latitude", NullValueRepresentation = NullValueRepresentation.DoubleZero, CastForExport = value => { if (value == null) { return(null); } return(double.Parse(value.ToString())); }, CastForImport = value => ((double?)value)?.ToString("R") }; AdapterSubfield longitude = new AdapterSubfield { AttributeType = AttributeType.String, FieldName = "longitude", IsMultivalued = false, PropertyName = "Longitude", Operation = AttributeOperation.ImportExport, AttributeNamePart = "longitude", NullValueRepresentation = NullValueRepresentation.DoubleZero, CastForExport = value => { if (value == null) { return(null); } return(double.Parse(value.ToString())); }, CastForImport = value => ((double?)value)?.ToString("R") }; AdapterNestedType schemaItem = new AdapterNestedType { Api = "building", AttributeName = "coordinates", Fields = new List <AdapterSubfield>() { latitude, longitude }, FieldName = "coordinates", PropertyName = "Coordinates", SupportsPatch = false }; type.AttributeAdapters.Add(schemaItem); yield return(type); }
public ApiInterfaceFeature(string customerID, MASchemaType type, IManagementAgentParameters config) { this.SchemaType = type; this.customerID = customerID; this.config = config; }