gammal - Linux
Overview
Gammal is a command-line utility for interacting with Google Apps Mail (GAM) via the Google Workspace Admin SDK. It provides a flexible and efficient way to manage Google Workspace resources, including user accounts, groups, and email settings.
Syntax
gammal [options] <command> [arguments]
Options/Flags
-h, –help
Display help message and exit.
-v, –verbose
Enable verbose mode.
Credentials
-u, –user=
Specifies the service account email address to use for authentication.
-k, –key-file=
Specifies the path to a service account key file in JSON format.
Scheduling
–retry-interval=
Sets the retry interval for failed API calls. Default: 300 seconds.
–retry-max-attempts=
Sets the maximum number of retry attempts for failed API calls. Default: 10.
Commands
Accounts
check-access
Checks whether or not a user has access to a group.
create
Creates a new user account.
delete
Deletes a user account.
get
Retrieves information about a user account.
update
Updates the properties of a user account.
Groups
create
Creates a new group.
delete
Deletes a group.
get
Retrieves information about a group.
list
Lists all groups matching the provided search criteria.
update
Updates the properties of a group.
attach-label
Attaches a label to a message.
remove-label
Removes a label from a message.
send-message
Sends an email message.
Examples
Create a new user account:
gammal create user username@example.com firstname lastname password
Check if a user has access to a group:
gammal check-access user username@example.com group groupname@example.org
Send an email message:
gammal send-message from username@example.com to recipient@example.org subject "Hello World" body "This is an email sent using gammal."
Common Issues
- Authentication errors: Ensure that the service account credentials used are valid and have the appropriate permissions.
- API limits: Be aware of the Google Workspace API quotas and limits. Adjust the retry settings accordingly to avoid exceeding these limits.
- Syntax errors: Double-check the syntax of the command and the arguments provided. Common errors include missing required arguments or incorrect option values.
Integration
Gammal can be integrated with other Linux commands and tools to perform more complex tasks. For example:
- Create a list of all users in a group:
gammal list groups groupname@example.org show users | tail -n +3
- Send an email to all users in a group:
gammal list groups groupname@example.org show users | tail -n +3 | xargs -I {} bash -c 'gammal send-message from username@example.com to {} subject "Group Announcement" body "This is an announcement for group members."'