Decodes an opaque string to a dictionary. :type token: str :param token: A token string given by the botocore pagination interface. :rtype: dict :returns: A dictionary containing pagination information, particularly the service pagination tok
(self, token)
| 113 | """ |
| 114 | |
| 115 | def decode(self, token): |
| 116 | """Decodes an opaque string to a dictionary. |
| 117 | |
| 118 | :type token: str |
| 119 | :param token: A token string given by the botocore pagination |
| 120 | interface. |
| 121 | |
| 122 | :rtype: dict |
| 123 | :returns: A dictionary containing pagination information, |
| 124 | particularly the service pagination token(s) but also other boto |
| 125 | metadata. |
| 126 | """ |
| 127 | json_string = base64.b64decode(token.encode('utf-8')).decode('utf-8') |
| 128 | decoded_token = json.loads(json_string) |
| 129 | |
| 130 | # Remove the encoding metadata as it is read since it will no longer |
| 131 | # be needed. |
| 132 | encoded_keys = decoded_token.pop('boto_encoded_keys', None) |
| 133 | if encoded_keys is None: |
| 134 | return decoded_token |
| 135 | else: |
| 136 | return self._decode(decoded_token, encoded_keys) |
| 137 | |
| 138 | def _decode(self, token, encoded_keys): |
| 139 | """Find each encoded value and decode it.""" |