launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/state/api/state.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package api 5 6 import ( 7 "launchpad.net/juju-core/state/api/agent" 8 "launchpad.net/juju-core/state/api/charmrevisionupdater" 9 "launchpad.net/juju-core/state/api/deployer" 10 "launchpad.net/juju-core/state/api/environment" 11 "launchpad.net/juju-core/state/api/firewaller" 12 "launchpad.net/juju-core/state/api/keyupdater" 13 "launchpad.net/juju-core/state/api/logger" 14 "launchpad.net/juju-core/state/api/machiner" 15 "launchpad.net/juju-core/state/api/params" 16 "launchpad.net/juju-core/state/api/provisioner" 17 "launchpad.net/juju-core/state/api/uniter" 18 "launchpad.net/juju-core/state/api/upgrader" 19 ) 20 21 // Login authenticates as the entity with the given name and password. 22 // Subsequent requests on the state will act as that entity. This 23 // method is usually called automatically by Open. The machine nonce 24 // should be empty unless logging in as a machine agent. 25 func (st *State) Login(tag, password, nonce string) error { 26 err := st.Call("Admin", "", "Login", ¶ms.Creds{ 27 AuthTag: tag, 28 Password: password, 29 Nonce: nonce, 30 }, nil) 31 if err == nil { 32 st.authTag = tag 33 } 34 return err 35 } 36 37 // Client returns an object that can be used 38 // to access client-specific functionality. 39 func (st *State) Client() *Client { 40 return &Client{st} 41 } 42 43 // Machiner returns a version of the state that provides functionality 44 // required by the machiner worker. 45 func (st *State) Machiner() *machiner.State { 46 return machiner.NewState(st) 47 } 48 49 // Provisioner returns a version of the state that provides functionality 50 // required by the provisioner worker. 51 func (st *State) Provisioner() *provisioner.State { 52 return provisioner.NewState(st) 53 } 54 55 // Uniter returns a version of the state that provides functionality 56 // required by the uniter worker. 57 func (st *State) Uniter() *uniter.State { 58 return uniter.NewState(st, st.authTag) 59 } 60 61 // Firewaller returns a version of the state that provides functionality 62 // required by the firewaller worker. 63 func (st *State) Firewaller() *firewaller.State { 64 return firewaller.NewState(st) 65 } 66 67 // Agent returns a version of the state that provides 68 // functionality required by the agent code. 69 func (st *State) Agent() *agent.State { 70 return agent.NewState(st) 71 } 72 73 // Upgrader returns access to the Upgrader API 74 func (st *State) Upgrader() *upgrader.State { 75 return upgrader.NewState(st) 76 } 77 78 // Deployer returns access to the Deployer API 79 func (st *State) Deployer() *deployer.State { 80 return deployer.NewState(st) 81 } 82 83 // Environment returns access to the Environment API 84 func (st *State) Environment() *environment.Facade { 85 return environment.NewFacade(st) 86 } 87 88 // Logger returns access to the Logger API 89 func (st *State) Logger() *logger.State { 90 return logger.NewState(st) 91 } 92 93 // KeyUpdater returns access to the KeyUpdater API 94 func (st *State) KeyUpdater() *keyupdater.State { 95 return keyupdater.NewState(st) 96 } 97 98 // CharmRevisionUpdater returns access to the CharmRevisionUpdater API 99 func (st *State) CharmRevisionUpdater() *charmrevisionupdater.State { 100 return charmrevisionupdater.NewState(st) 101 }