Inserts a new instance of ``CredentialProvider`` into the chain that will be tried before an existing one. :param name: The short name of the credentials you'd like to insert the new credentials before. (ex. ``env`` or ``config``). Existing names & o
(self, name, credential_provider)
| 2153 | self.providers = providers |
| 2154 | |
| 2155 | def insert_before(self, name, credential_provider): |
| 2156 | """ |
| 2157 | Inserts a new instance of ``CredentialProvider`` into the chain that |
| 2158 | will be tried before an existing one. |
| 2159 | |
| 2160 | :param name: The short name of the credentials you'd like to insert the |
| 2161 | new credentials before. (ex. ``env`` or ``config``). Existing names |
| 2162 | & ordering can be discovered via ``self.available_methods``. |
| 2163 | :type name: string |
| 2164 | |
| 2165 | :param cred_instance: An instance of the new ``Credentials`` object |
| 2166 | you'd like to add to the chain. |
| 2167 | :type cred_instance: A subclass of ``Credentials`` |
| 2168 | """ |
| 2169 | try: |
| 2170 | offset = [p.METHOD for p in self.providers].index(name) |
| 2171 | except ValueError: |
| 2172 | raise UnknownCredentialError(name=name) |
| 2173 | self.providers.insert(offset, credential_provider) |
| 2174 | |
| 2175 | def insert_after(self, name, credential_provider): |
| 2176 | """ |