|
12 | 12 | # language governing permissions and limitations under the License. |
13 | 13 | import inspect |
14 | 14 |
|
| 15 | +from botocore import xform_name |
15 | 16 | from botocore.compat import OrderedDict |
16 | 17 | from botocore.docs.example import ResponseExampleDocumenter |
17 | 18 | from botocore.docs.method import ( |
@@ -308,3 +309,56 @@ def _add_response_params(self, section, shape): |
308 | 309 | shape, |
309 | 310 | include=[self._GENERIC_ERROR_SHAPE], |
310 | 311 | ) |
| 312 | + |
| 313 | + |
| 314 | +class ClientContextParamsDocumenter: |
| 315 | + _CONFIG_GUIDE_LINK = ( |
| 316 | + 'https://boto3.amazonaws.com/' |
| 317 | + 'v1/documentation/api/latest/guide/configuration.html' |
| 318 | + ) |
| 319 | + |
| 320 | + OMITTED_CONTEXT_PARAMS = { |
| 321 | + 's3': ( |
| 322 | + 'Accelerate', |
| 323 | + 'DisableMultiRegionAccessPoints', |
| 324 | + 'ForcePathStyle', |
| 325 | + 'UseArnRegion', |
| 326 | + ), |
| 327 | + 's3control': ('UseArnRegion',), |
| 328 | + } |
| 329 | + |
| 330 | + def __init__(self, service_name, context_params): |
| 331 | + self._service_name = service_name |
| 332 | + self._context_params = context_params |
| 333 | + |
| 334 | + def document_context_params(self, section): |
| 335 | + self._add_title(section) |
| 336 | + self._add_overview(section) |
| 337 | + self._add_context_params_list(section) |
| 338 | + |
| 339 | + def _add_title(self, section): |
| 340 | + section.style.h2('Client Context Parameters') |
| 341 | + |
| 342 | + def _add_overview(self, section): |
| 343 | + section.style.new_line() |
| 344 | + section.write( |
| 345 | + 'Client context parameters are configurable on a client ' |
| 346 | + 'instance via the ``client_context_params`` parameter in the ' |
| 347 | + '``Config`` object. For more detailed instructions and examples ' |
| 348 | + 'on the exact usage of context params see the ' |
| 349 | + ) |
| 350 | + section.style.external_link( |
| 351 | + title='configuration guide', |
| 352 | + link=self._CONFIG_GUIDE_LINK, |
| 353 | + ) |
| 354 | + section.write('.') |
| 355 | + section.style.new_line() |
| 356 | + |
| 357 | + def _add_context_params_list(self, section): |
| 358 | + section.style.new_line() |
| 359 | + sn = f'``{self._service_name}``' |
| 360 | + section.writeln(f'The available {sn} client context params are:') |
| 361 | + for param in self._context_params: |
| 362 | + section.style.new_line() |
| 363 | + name = f'``{xform_name(param.name)}``' |
| 364 | + section.write(f'* {name} ({param.type}) - {param.documentation}') |
0 commit comments