awsc.base_control.ListResourceDocumentCreator
- class awsc.base_control.ListResourceDocumentCreator(provider, create_method, create_document_arg, initial_document=None, as_json=True, static_fields=None, message='Create successful')
Class for simplifying generating an editor for resources whose body is a JSON document. This flavour is specifically tuned for create operations.
- Attributes:
- goldenstr
The initial document in string form. Nothing happens if the state of the document when exiting the editor matches the initial document.
- static_fieldsdict
A mapping of field name to field value for keyword arguments that have a static value in the API call.
Methods
display_content
(response)Creates the display format for the resource retrieved from AWS.
edit
([selection])Executes the full editing workflow.
generate_kwargs
(selection, newcontent)Generates the kwargs for updating based on the kwargs settings within the object instance.
hotkey_callback
(control)This function can be passed as a hotkey callback to a ResourceLister.
retrieve_content
(selection)Called when the data for the edited entry is being retrieved.
update_content
(selection, newcontent)Updates the data on AWS with the data edited by the user.
- __init__(provider, create_method, create_document_arg, initial_document=None, as_json=True, static_fields=None, message='Create successful')
Initializes a ListResourceDocumentCreator.
- Parameters:
- providerstr
boto3 client provider name
- create_methodstr
The method name for the provider to call to create the resource
- create_document_argstr
The name of the kwarg for the create_method which receives the updated document. If empty, the root level object is passed as a set of kwargs.
- initial_documentdict
The initial document to present for editing. Consider it a template of fields to be filled. Expected to be a dict or dict-like structure that can translate to a json string via json.dumps.
- as_jsonbool or list, default=True
Whether certain fields need to be passed as json or json string. Unfortunately, this is not uniform across the AWS APIs. The behaviour is that ints, floats, bools and strings are never changed by this controller. Dicts and lists, by default - if this value is True - are dumped as strings. You can disable this behaviour by setting this field to False. You can also selectively choose a set of fields where this behaviour should be enabled, by setting this to a list of field names. And yes, unfortunately this is a valid use case, there are AWS APIs where certain fields are strings of json, while others are json, I’m looking at you, policies.
- static_fieldsdict
A mapping of field name to field value for keyword arguments that have a static value in the API call.
Methods
__init__
(provider, create_method, ...[, ...])Initializes a ListResourceDocumentCreator.
display_content
(response)Creates the display format for the resource retrieved from AWS.
edit
([selection])Executes the full editing workflow.
generate_kwargs
(selection, newcontent)Generates the kwargs for updating based on the kwargs settings within the object instance.
hotkey_callback
(control)This function can be passed as a hotkey callback to a ResourceLister.
retrieve_content
(selection)Called when the data for the edited entry is being retrieved.
update_content
(selection, newcontent)Updates the data on AWS with the data edited by the user.