Documentation ¶
Index ¶
- Constants
- func GetDomain() string
- func GetImpersonation() string
- func IsSupportedColor(color string) bool
- func LoadConfig(b []byte) error
- func NewClient(ctx context.Context, scopes []string) (option.ClientOption, error)
- func NewClientWithSubject(ctx context.Context, subject string, scopes []string) (option.ClientOption, error)
- func NewDefaultCredentialsClient(ctx context.Context, scopes ...string) (option.ClientOption, error)
- func NewGmailFilter() *gmail.Filter
- func SetServiceAccountFile(f string) error
- type AdminService
- type Config
- type ConfigFilter
- type ConfigFilters
- type ErrFetchingFiltersForUser
- type ErrFetchingLabelsForUser
- type ErrFilterMismatch
- type ErrFilterNotFound
- type ErrInvalidServiceAccountFile
- type ErrLabelMismatch
- type ErrLabelNotFound
- type ErrMissingConfig
- type ErrMissingServiceAccountFile
- type Filter
- type FilterQuery
- type GmailService
- func (s *GmailService) CompareFilters(upstream, local *Filter, labelId string) error
- func (s *GmailService) CompareLabels(upstream, local *Label) error
- func (s *GmailService) CreateFilterForUser(f *gmail.Filter, user *User) error
- func (s *GmailService) CreateLabelForUser(label *Label, user *User) error
- func (s *GmailService) DeleteFilterForUser(f *gmail.Filter, user *User) error
- func (s *GmailService) GetFilterForUser(filterKey string, user *User) (*Filter, error)
- func (s GmailService) GetFiltersForUser(user *User) ([]*Filter, error)
- func (s *GmailService) GetLabelForUser(name string, user *User) (*Label, error)
- func (s *GmailService) GetLabelsForUser(user *User) ([]*Label, error)
- func (s *GmailService) UpdateLabelForUser(label *Label, user *User) error
- type Label
- type Labels
- type User
Constants ¶
const ( ScopeGmailLabels = gmail.GmailLabelsScope ScopeGmailSettings = gmail.GmailSettingsBasicScope )
const ( ScopeAdminUserReadOnly = admin.AdminDirectoryUserReadonlyScope ScopeAdminUser = admin.AdminDirectoryUserScope )
Variables ¶
This section is empty.
Functions ¶
func GetImpersonation ¶
func GetImpersonation() string
GetImpersonation returns a string of the user to impersonate.
func IsSupportedColor ¶
func NewClient ¶
NewClient will use FindDefaultCredentials to generate a new client for checking default application credentials or using a configJSON.
func NewClientWithSubject ¶
func NewClientWithSubject(ctx context.Context, subject string, scopes []string) (option.ClientOption, error)
NewClientWithSubject will impersonate a users' email and create a service to query the AdminSDK API.
func NewDefaultCredentialsClient ¶
func NewDefaultCredentialsClient(ctx context.Context, scopes ...string) (option.ClientOption, error)
NewDefaultCredentialsClient will use FindDefaultCredentials to generate a new client for checking default application credentials or using a configJSON.
func NewGmailFilter ¶
func NewGmailFilter() *gmail.Filter
NewGmailFilter creates a new Gmail filter.
func SetServiceAccountFile ¶
SetServiceAccountFile sets the service account file.
Types ¶
type AdminService ¶
AdminService is a wrapper for admin.Service
func NewAdminService ¶
func NewAdminService(ctx context.Context, options ...option.ClientOption) (*AdminService, error)
NewAdminService creates a new AdminService instance.
func (*AdminService) ListUsers ¶
func (s *AdminService) ListUsers() ([]*User, error)
ListUsers will read from the users api.
type Config ¶
type Config struct { Labels Labels `yaml:"labels"` Filters ConfigFilters `yaml:"filters"` Domain string `yaml:"domain"` Impersonate string `yaml:"impersonate"` }
Config is a standard config struct.
type ConfigFilter ¶
type ConfigFilter struct { Action string `yaml:"action"` Label string `yaml:"label"` Query *FilterQuery `yaml:"query,omitempty"` }
ConfigFilter represents a gmail filter.
type ConfigFilters ¶
type ConfigFilters []ConfigFilter
LocalFilters is a collection of Filter.
func GetFilters ¶
func GetFilters() ConfigFilters
GetFilters returns a collection of filters to configure.
type ErrFetchingFiltersForUser ¶
type ErrFetchingFiltersForUser struct {
User string
}
ErrFetchingFiltersForUser
type ErrFetchingLabelsForUser ¶
type ErrFetchingLabelsForUser struct {
User string
}
ErrFetchingLabelsForUser
type ErrFilterNotFound ¶
ErrFilterNotFound
type ErrInvalidServiceAccountFile ¶
type ErrInvalidServiceAccountFile struct {
File string
}
ErrInvalidServiceAccountFile
func (ErrInvalidServiceAccountFile) Error ¶
func (e ErrInvalidServiceAccountFile) Error() string
Error
type ErrLabelNotFound ¶
ErrLabelNotFound
type ErrMissingServiceAccountFile ¶
type ErrMissingServiceAccountFile struct{}
ErrMissingServiceAccountFile
func (ErrMissingServiceAccountFile) Error ¶
func (e ErrMissingServiceAccountFile) Error() string
Error
type Filter ¶
type Filter gmail.Filter
Filter is a custom gmail.Filter type.
type FilterQuery ¶
type FilterQuery struct { From *[]string `yaml:"from,omitempty"` NotFrom *[]string `yaml:"not_from,omitempty"` To *[]string `yaml:"to,omitempty"` NotTo *[]string `yaml:"not_to,omitempty"` }
FilterQuery is a query object for filters.
func (*FilterQuery) ToString ¶
func (f *FilterQuery) ToString() string
ToString will convert a query string to a compatible filter.
type GmailService ¶
type GmailService struct { Svc *gmail.Service UsersSvc *gmail.UsersService SettingsSvc *gmail.UsersSettingsService }
func NewGmailService ¶
func NewGmailService(ctx context.Context, options ...option.ClientOption) (*GmailService, error)
NewGmailService creates a new collection of required gmail services.
func (*GmailService) CompareFilters ¶
func (s *GmailService) CompareFilters(upstream, local *Filter, labelId string) error
CompareFilters compares an upstream and local filters.
func (*GmailService) CompareLabels ¶
func (s *GmailService) CompareLabels(upstream, local *Label) error
CompareLabels compares an upstream and local label.
func (*GmailService) CreateFilterForUser ¶
func (s *GmailService) CreateFilterForUser(f *gmail.Filter, user *User) error
CreateFilterForUser creates a filter for the user.
func (*GmailService) CreateLabelForUser ¶
func (s *GmailService) CreateLabelForUser(label *Label, user *User) error
CreateLabelForUser will create a new user label.
func (*GmailService) DeleteFilterForUser ¶
func (s *GmailService) DeleteFilterForUser(f *gmail.Filter, user *User) error
DeleteFilterForUser deletes a filter for the user.
func (*GmailService) GetFilterForUser ¶
func (s *GmailService) GetFilterForUser(filterKey string, user *User) (*Filter, error)
GetLabelForUser gets a specific label for the provided user.
func (GmailService) GetFiltersForUser ¶
func (s GmailService) GetFiltersForUser(user *User) ([]*Filter, error)
GetFiltersForUser will return filters for the user.
func (*GmailService) GetLabelForUser ¶
func (s *GmailService) GetLabelForUser(name string, user *User) (*Label, error)
GetLabelForUser gets a specific label for the provided user.
func (*GmailService) GetLabelsForUser ¶
func (s *GmailService) GetLabelsForUser(user *User) ([]*Label, error)
GetLabelsForUser will return a list of labels for the specified user
func (*GmailService) UpdateLabelForUser ¶
func (s *GmailService) UpdateLabelForUser(label *Label, user *User) error
UpdateLabelForUser will perform a patch label.
type Label ¶
type Label gmail.Label
Label is a custom gmail.Label type.