-
Notifications
You must be signed in to change notification settings - Fork 88
Tag Replace
- Python Regular Expressions Sub function
- Definitions
- Introduction
- Simple
replace <Tag> <String>
processing - User attribute
replace <Tag> <UserReplacement>
processing - Example
<AddressSubfieldName> ::=
country|
countrycode|
customtype|
extendedaddress|
formatted|
locality|
pobox|
postalcode|
primary|
region|
streetaddress|
type
<EmailSubfieldName> ::=
domain|
primaryemail|
username
<ExternalIdSubfieldName> ::=
customtype|
type|
value
<GenderSubfieldName> ::=
addressmeas|
customgender|
type
<IMSubfieldName> ::=
customtype|
type|
value
<KeywordSubfieldName> ::=
customtype|
type|
value
<LocationSubfieldName> ::=
area|
buildingid|
buildingname|
customtype|
deskcode|
floorname|
floorsection|
type
<NameSubfieldName> ::=
familyname|
fullname|
givenname
<OrganizationSubfieldName> ::=
costcenter|
customtype|
department|
description|
domain|
fulltimeequivalent|
location|
name|
primary|
symbol|
title|
type
<OtherEmailSubfieldName> ::=
address|
customtype|
primary|
type
<PhoneSubfieldName> ::=
customtype|
primary|
type|
value
<PosixSubfieldName> ::=
accountid|
gecos|
gid|
homedirectory|
operatingsystemtype|
primary|
shell|
systemid|
uid|
username
<RelationSubfieldName> ::=
customtype|
type|
value
<SSHkeysSubfieldName> ::=
expirationtimeusec|
fingerprint|
key
<WebsiteSubfieldName> ::=
customtype|
primary|
type|
value
<UserReplacementFieldSubfield> ::=
address.<AddressSubfieldName>|
email.<EmailSubfieldName>|
externalid.<ExternalIdSubfieldName>|
gender.<GenderSubfieldName>|
im.<IMSubfieldName>|
keyword.<KeywordSubfieldName>|
location.<LocationSubfieldName>|
name.<NameSubfieldName>|
organization.<OrganizationSubfieldName>|
otheremail.<OtherEmailSubfieldName>|
phone.<PhoneSubfieldName>|
posix.<PosixSubfieldName>|
relation.<RelationSubfieldName>|
sshkeys.<SSHkeysSubfieldName>|
website.<WebsiteSubfieldName>|
<UserReplacementFieldSubfieldMatchSubfield> ::=
address.<AddressSubfieldName>.<AddressSubfieldName>.<String>|
externalid.<ExternalIdSubfieldName>.<ExternalIdSubfieldName>.<String>|
im.<IMSubfieldName>.<IMSubfieldName>.<String>|
keyword.<KeywordSubfieldName>.<KeywordSubfieldName>.<String>|
location.<LocationSubfieldName>.<LocationSubfieldName>.<String>|
organization.<OrganizationSubfieldName>.<OrganizationSubfieldName>.<String>|
otheremail.<OtherEmailSubfieldName>.<OtherEmailSubfieldName>.<String>|
phone.<PhoneSubfieldName>.<PhoneSubfieldName>.<String>|
posix.<PosixSubfieldName>.<PosixSubfieldName>.<String>|
relation.<RelationSubfieldName>.<RelationSubfieldName>.<String>|
sshkeys.<SSHkeysSubfieldName>.<SSHkeysSubfieldName>.<String>|
website.<WebsiteSubfieldName>.<WebsiteSubfieldName>.<String>
<UserReplacementField> ::=
photourl
<Tag> ::= <String>
<UserReplacement> ::=
(field:<UserReplacementField>)|
(field:<UserReplacementFieldSubfield>)|
(field:<UserReplacementFieldSubfieldMatchSubfield>)|
(schema:<SchemaName>.<FieldName>)|
<String>
Several commands use template files for messages and signatures; Gam has the ability to replace tags in the template with data from the command line or from user attributes.
This command allows simple text replacement in the message.
gam sendemail <EmailAddressEntity> [from <UserItem>] [replyto <EmailAddress>]
[cc <EmailAddressEntity>] [bcc <EmailAddressEntity>] [singlemessage [<Boolean>]]
[subject <String>] [message <String>|(file <FileName> [charset <Charset>])]
(replace <Tag> <String>)* [html [<Boolean>]] (attach <FileName>)*
- Every instance of
{Tag}
in the message will be replaced by<String>
. - Instances of the form
{RT}...{Tag1}...{Tag2}...{/RT}
will be eliminated if there are no<String>
values for allTagN
or if the<String>
values are all empty strings. - Instances of the form
{RTL}...{RT}...{Tag1}...{/RT}{RT}...{Tag2}...{/RT}{/RTL}
will be eliminated if none of the embedded{RT}...{Tag}...{/RT}
have values.
You can control the case of the letters in replace <Tag> <String>
:
-
{PC}...{Tag1}...{Tag2}...{/PC}
- For all sequences of letters between{PC}
and{/PC}
, the first letter is converted to uppercase, subsequent letters to lowercase. -
{UC}...{Tag1}...{Tag2}...{/UC}
- All letters between{UC}
and{/UC}
will be converted to uppercase -
{LC}...{Tag1}...{Tag2}...{/LC}
- All letters between{LC}
and{/LC}
will be converted to lowercase
These commands allow simple text replacement in the message/signature as well as substitution of select user attributes.
gam create user <EmailAddress> <UserAttribute>*
[notify <EmailAddress>] [subject <String>]
[message <String>|(file <FileName> [charset <Charset>])] [html [<Boolean>]]
(replace <Tag> <UserReplacement>)*
gam update user <UserItem> <UserAttribute>
[updateprimaryemail <RegularExpression> <EmailReplacement>]
[updateoufromgroup <FileName> [charset <Charset>]
[columndelimiter <Character>] [noescapechar <Boolean>] [quotechar <Character>]
[fields <FieldNameList>] [keyfield <FieldName>] [datafield <FieldName>]]
[clearschema <SchemaName>] [clearschema <SchemaName>.<FieldName>]
[createifnotfound] [notify <EmailAddress>] [subject <String>]
[message <String>|(file <FileName> [charset <Charset>])] [html [<Boolean>]]
(replace <Tag> <UserReplacement>)*
gam <UserTypeEntity> draft message (<SMTPDateHeader> <Time>)*
(<SMTPHeader> <String>)* (header <String> <String>)*
(addlabel <LabelName>)* [labels <LabelNameList>]
(textmessage|message <String>)|(textfile|file <FileName> [charset <Charset>])
(htmlmessage <String>)|(htmlfile <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)* (attach <FileName> [charset <Charset>])*
gam <UserTypeEntity> import message (<SMTPDateHeader> <Time>)*
(<SMTPHeader> <String>)*
(header <String> <String>)*
(addlabel <LabelName>)*
(textmessage <String>)|(textfile <FileName> [charset <Charset>])
(htmlmessage <String>)|(htmlfile <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)* (attach <FileName>)*
[deleted [<Boolean>]] [nevermarkspam [<Boolean>]]
[processforcalendar [<Boolean>]]
gam <UserTypeEntity> insert message
(<SMTPDateHeader> <Time>)*
(<SMTPHeader> <String>)*
(header <String> <String>)*
(addlabel <LabelName>)*
(textmessage <String>)|(textfile <FileName> [charset <Charset>])
(htmlmessage <String>)|(htmlfile <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)* (attach <FileName>)*
[deleted [<Boolean>]]
gam <UserTypeEntity> [create|add] sendas <EmailAddress> <String>
[signature|sig <String>|(file <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)*]
[html [<Boolean>]] [replyto <EmailAddress>]
[default] [treatasalias <Boolean>]
gam <UserTypeEntity> update sendas <EmailAddress>
[name <String>] [signature|sig <String>|(file <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)*]
[html [<Boolean>]] [replyto <EmailAddress>] [default] [treatasalias <Boolean>]
gam <UserTypeEntity> signature|sig <String>|(file <FileName> [charset <Charset>])
(replace <Tag> <UserReplacement>)*
[html [<Boolean>]] [name <String>] [replyto <EmailAddress>]
[default] [primary] [treatasalias <Boolean>]
gam <UserTypeEntity> vacation <TrueValues> subject <String>
[message <String>|(file <FileName> [charset <Charset>])]
(replace <Tag> <UserReplacement>)*
[html [<Boolean>]] [contactsonly [<Boolean>]] [domainonly [<Boolean>]]
[startdate <Date>|Started] [enddate <Date>|NotSpecified]
- Every instance of
{Tag}
in the message/signature will be replaced by<UserReplacement>
. - Instances of the form
{RT}...{Tag1}...{Tag2}...{/RT}
will be eliminated if there are no<UserReplacement>
values for allTagN
or if the<UserReplacement>
values are all empty strings. - Instances of the form
{RTL}...{RT}...{Tag1}...{/RT}{RT}...{Tag2}...{/RT}{/RTL}
will be eliminated if none of the embedded{RT}...{Tag}...{/RT}
have values.
You can control the case of the letters in replace <Tag> <UserReplacement>
:
-
{PC}...{Tag1}...{Tag2}...{/PC}
- For all sequences of letters between{PC}
and{/PC}
, the first letter is converted to uppercase, subsequent letters to lowercase. -
{UC}...{Tag1}...{Tag2}...{/UC}
- All letters between{UC}
and{/UC}
will be converted to uppercase -
{LC}...{Tag1}...{Tag2}...{/LC}
- All letters between{LC}
and{/LC}
will be converted to lowercase
<UserReplacement>
specifies the data that replaces {Tag}
in the message/signature.
-
field:<UserReplacementFieldSubfield>
- A subfield value from a user attribute- For attributes
address
,organization
,otheremails
andphone
, the attribute instance markedprimary
will be used. If there is no attribute instance markedprimary
, the first attribute instance will be used. - For attribute
location
, the first attribute instance will be used. - If
<UserReplacementFieldSubfield>
is empty or does not exist, an empty string will be used
- For attributes
-
field:<UserReplacementFieldSubfieldMatchSubfield>
- A subfield value from a user attribute where a second subfield value is used to select the attribute- Select based on type:
phone.value.type.work
- Select primary instance:
otheremails.address.primary.true
- Select based on type:
-
schema:<SchemaName>.<FieldName>
- A custom schema value from the user's profile. -
<String>
- A literal string in which the following substitutions will be made:-
#email#
and#user#
will be replaced by the user's primary email address -
#username#
will be replaced by the local part of the user's primary email address
-
The file SigTemplate.txt contains:
<div dir='ltr' style='color:rgb(0,0,0);font-family:Helvetica;font-size:12px'>
<p>Name: {first} {last}<br />
{RT}Address: {address}<br />{/RT}
{RT}Department: {department}, Title: {title}<br />{/RT}
{RT}Location: Building: {building}, Floor: {floor}, Section: {section}, Desk: {desk}<br />{/RT}
{RTL}{RT}Office: {officephone} {/RT}{RT}Mobile: {mobilephone}{/RT}<br />{/RTL}
Email: {email}</p>
</div>
This command will update the signatures of the specified users.
- The
replace
arguments can appear in any order.
gam <UserTypeEntity> signature file SigTemplate.txt html
replace first field:name.givenname replace last field:name.familyname
replace officephone field:phone.value.type.work replace mobilephone field:phone.value.type.mobile
replace email field:email.primaryemail
replace address field:address.formatted
replace department field:organization.department replace title field:organization.title
replace building field:location.buildingname replace floor field:location.floorname
replace section field:location.floorsection replace desk field:location.deskcode
Need more help? Ask on the GAM Discussion Group
Update History
Installation
- How to Install GAM7
- How to Update Advanced GAM to GAM7
- How to Update GAM7
- How to Upgrade from Legacy GAM
- Install GAM as Python Library
- GAM7 on Chrome OS Devices
- GAM7 on Android Devices
- Google Network Addresses
- HTTPS Proxy
- SSL Root CA Certificates
- How to Uninstall GAM7
Configuration
- Authorization
- GAM Configuration
- Running GAM7 securely on a Google Compute Engine
- Using GAM7 with a delegated admin service account
- Using GAM7 with a YubiKey
Notes and Information
- Upgrade Benefits
- Questions? Visit the GAM Discussion Forum
- Scripts
- Other Resources
- Drive REST API v3
- BNF Syntax
- GAM Return Codes
- Python Regular Expressions
- Rclone
Definitions
Command Processing
- Bulk Processing
- Command Line Parsing
- Command Logging and Progress
- Command data from Google Docs/Sheets/Storage
- CSV Special Characters
- CSV Input Filtering
- CSV Output Filtering
- Meta Commands and File Redirection
- Permission matches
- Tag Replace
- Todrive
Collections
Client Access
- Addresses
- Administrators
- Alert Center
- Aliases
- Calendars
- Calendars - Access
- Calendars - Events
- Chrome Auto Update Expiration Counts
- Chrome Browser Cloud Management
- Chrome Device Needs Attention Counts
- Chrome Installed Apps
- Chrome Policies
- Chrome Printers
- Chrome Version Counts
- Chrome Version History
- ChromeOS Devices
- Classroom - Courses
- Classroom - Guardians
- Classroom - Invitations
- Classroom - Membership
- Cloud Channel
- Cloud Identity Devices
- Cloud Identity Groups
- Cloud Identity Groups - Membership
- Cloud Identity Policies
- Cloud Storage
- Context Aware Access Levels
- Customer
- Domains
- Domains - Verification
- Domain People - Contacts & Profiles
- Domain Shared Contacts - Global Address List
- Email Audit Monitor
- Find File Owner
- Google Data Transfers
- Groups
- Groups - Membership
- Inbound SSO
- Licenses
- Mobile Devices
- Organizational Units
- Reports
- Reseller
- Resources
- Send Email
- Schemas
- Shared Drives
- Sites
- Users
- Unmanaged Accounts
- Users - Signout and Turn off 2-Step Verification
- Vault - Takeout
- Version and Help
Special Service Account Access
Service Account Access
- Users - Analytics Admin
- Users - Application Specific Passwords
- Users - Backup Verification Codes
- Users - Calendars
- Users - Calendars - Access
- Users - Calendars - Events
- Users - Chat
- Users - Classification Labels
- Users - Classroom - Profile
- Users - Deprovision
- Users - Contacts
- Users - Contacts - Delegates
- Users - Drive - File Selection
- Users - Drive - Activity/Settings
- Users - Drive - Cleanup
- Users - Drive - Comments
- Users - Drive - Copy/Move
- Users - Drive - Files-Display
- Users - Drive - Files-Manage
- Users - Drive - Orphans
- Users - Drive - Ownership
- Users - Drive - Permissions
- Users - Drive - Query
- Users - Drive - Revisions
- Users - Drive - Shortcuts
- Users - Drive - Transfer
- Users - Forms
- Users - Gmail - Client Side Encryption
- Users - Gmail - Delegates
- Users - Gmail - Filters
- Users - Gmail - Forwarding
- Users - Gmail - Labels
- Users - Gmail - Messages/Threads
- Users - Gmail - Profile
- Users - Gmail - S/MIME
- Users - Gmail - SendAs/Signature/Vacation
- Users - Gmail - Settings
- Users - Group Membership
- Users - Keep
- Users - Looker Studio
- Users - Meet
- Users - Classroom - Profile
- Users - People - Contacts & Profiles
- Users - Photo
- Users - Profile Sharing
- Users - Shared Drives
- Users - Spreadsheets
- Users - Tasks
- Users - Tokens
- Users - YouTube