Create a paginator for an operation. :type operation_name: string :param operation_name: The operation name. This is the same name as the method name on the client. For example, if the method name is ``create_foo``, and you'd normally invoke the
(self, operation_name)
| 1053 | return endpoint_url, additional_headers, endpoint_properties |
| 1054 | |
| 1055 | def get_paginator(self, operation_name): |
| 1056 | """Create a paginator for an operation. |
| 1057 | |
| 1058 | :type operation_name: string |
| 1059 | :param operation_name: The operation name. This is the same name |
| 1060 | as the method name on the client. For example, if the |
| 1061 | method name is ``create_foo``, and you'd normally invoke the |
| 1062 | operation as ``client.create_foo(**kwargs)``, if the |
| 1063 | ``create_foo`` operation can be paginated, you can use the |
| 1064 | call ``client.get_paginator("create_foo")``. |
| 1065 | |
| 1066 | :raise OperationNotPageableError: Raised if the operation is not |
| 1067 | pageable. You can use the ``client.can_paginate`` method to |
| 1068 | check if an operation is pageable. |
| 1069 | |
| 1070 | :rtype: L{botocore.paginate.Paginator} |
| 1071 | :return: A paginator object. |
| 1072 | |
| 1073 | """ |
| 1074 | if not self.can_paginate(operation_name): |
| 1075 | raise OperationNotPageableError(operation_name=operation_name) |
| 1076 | else: |
| 1077 | actual_operation_name = self._PY_TO_OP_NAME[operation_name] |
| 1078 | |
| 1079 | # Create a new paginate method that will serve as a proxy to |
| 1080 | # the underlying Paginator.paginate method. This is needed to |
| 1081 | # attach a docstring to the method. |
| 1082 | def paginate(self, **kwargs): |
| 1083 | return Paginator.paginate(self, **kwargs) |
| 1084 | |
| 1085 | paginator_config = self._cache['page_config'][ |
| 1086 | actual_operation_name |
| 1087 | ] |
| 1088 | # Add the docstring for the paginate method. |
| 1089 | paginate.__doc__ = PaginatorDocstring( |
| 1090 | paginator_name=actual_operation_name, |
| 1091 | event_emitter=self.meta.events, |
| 1092 | service_model=self.meta.service_model, |
| 1093 | paginator_config=paginator_config, |
| 1094 | include_signature=False, |
| 1095 | ) |
| 1096 | |
| 1097 | # Rename the paginator class based on the type of paginator. |
| 1098 | paginator_class_name = str( |
| 1099 | f'{get_service_module_name(self.meta.service_model)}.Paginator.{actual_operation_name}' |
| 1100 | ) |
| 1101 | |
| 1102 | # Create the new paginator class |
| 1103 | documented_paginator_cls = type( |
| 1104 | paginator_class_name, (Paginator,), {'paginate': paginate} |
| 1105 | ) |
| 1106 | |
| 1107 | operation_model = self._service_model.operation_model( |
| 1108 | actual_operation_name |
| 1109 | ) |
| 1110 | paginator = documented_paginator_cls( |
| 1111 | getattr(self, operation_name), |
| 1112 | paginator_config, |