// NewRsyslogAPI creates a new instance of the Rsyslog API. func NewRsyslogAPI(st *state.State, resources *common.Resources, authorizer common.Authorizer) (*RsyslogAPI, error) { if !authorizer.AuthMachineAgent() && !authorizer.AuthUnitAgent() { return nil, common.ErrPerm } // Can always watch for environ changes. getCanWatch := common.AuthAlways(true) // Does not get the secrets. getCanReadSecrets := common.AuthAlways(false) return &RsyslogAPI{ EnvironWatcher: common.NewEnvironWatcher(st, resources, getCanWatch, getCanReadSecrets), st: st, authorizer: authorizer, resources: resources, canModify: authorizer.AuthEnvironManager(), StateAddresser: common.NewStateAddresser(st), }, nil }
// NewAPI creates a new instance of the Client API. func NewAPI(st *state.State, resources *common.Resources, authorizer common.Authorizer) *API { r := &API{ state: st, auth: authorizer, resources: resources, statusSetter: common.NewStatusSetter(st, common.AuthAlways(true)), } r.client = &Client{ api: r, } return r }
func NewUserManagerAPI( st *state.State, authorizer common.Authorizer, ) (*UserManagerAPI, error) { if !authorizer.AuthClient() { return nil, common.ErrPerm } // TODO(mattyw) - replace stub with real canWrite function getCanWrite := common.AuthAlways(true) return &UserManagerAPI{ state: st, authorizer: authorizer, getCanWrite: getCanWrite}, nil }