The Session object collects together useful functionality from `botocore` as well as important data such as configuration information and credentials into a single, easy-to-use object. :ivar available_profiles: A list of profiles defined in the config file associated with t
| 64 | |
| 65 | |
| 66 | class Session: |
| 67 | """ |
| 68 | The Session object collects together useful functionality |
| 69 | from `botocore` as well as important data such as configuration |
| 70 | information and credentials into a single, easy-to-use object. |
| 71 | |
| 72 | :ivar available_profiles: A list of profiles defined in the config |
| 73 | file associated with this session. |
| 74 | :ivar profile: The current profile. |
| 75 | """ |
| 76 | |
| 77 | SESSION_VARIABLES = copy.copy(BOTOCORE_DEFAUT_SESSION_VARIABLES) |
| 78 | |
| 79 | #: The default format string to use when configuring the botocore logger. |
| 80 | LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' |
| 81 | |
| 82 | def __init__( |
| 83 | self, |
| 84 | session_vars=None, |
| 85 | event_hooks=None, |
| 86 | include_builtin_handlers=True, |
| 87 | profile=None, |
| 88 | ): |
| 89 | """ |
| 90 | Create a new Session object. |
| 91 | |
| 92 | :type session_vars: dict |
| 93 | :param session_vars: A dictionary that is used to override some or all |
| 94 | of the environment variables associated with this session. The |
| 95 | key/value pairs defined in this dictionary will override the |
| 96 | corresponding variables defined in ``SESSION_VARIABLES``. |
| 97 | |
| 98 | :type event_hooks: BaseEventHooks |
| 99 | :param event_hooks: The event hooks object to use. If one is not |
| 100 | provided, an event hooks object will be automatically created |
| 101 | for you. |
| 102 | |
| 103 | :type include_builtin_handlers: bool |
| 104 | :param include_builtin_handlers: Indicates whether or not to |
| 105 | automatically register builtin handlers. |
| 106 | |
| 107 | :type profile: str |
| 108 | :param profile: The name of the profile to use for this |
| 109 | session. Note that the profile can only be set when |
| 110 | the session is created. |
| 111 | |
| 112 | """ |
| 113 | if event_hooks is None: |
| 114 | self._events = HierarchicalEmitter() |
| 115 | else: |
| 116 | self._events = event_hooks |
| 117 | if include_builtin_handlers: |
| 118 | self._register_builtin_handlers(self._events) |
| 119 | self.user_agent_name = 'Botocore' |
| 120 | self.user_agent_version = __version__ |
| 121 | self.user_agent_extra = '' |
| 122 | # The _profile attribute is just used to cache the value |
| 123 | # of the current profile to avoid going through the normal |