File
class flow_api.file.File(select=None, cls=None, init=None, by='name', allow_normal=True, allow_deleted=False, commit=False, bundle_id=<class 'flow_api.system.NotSet'>, bundle_name=<class 'flow_api.system.NotSet'>, commit_message=<class 'flow_api.system.NotSet'>, content=<class 'flow_api.system.NotSet'>, description=<class 'flow_api.system.NotSet'>, is_bundle_content=<class 'flow_api.system.NotSet'>, is_readonly=<class 'flow_api.system.NotSet'>, location_inheritance=<class 'flow_api.system.NotSet'>, name=<class 'flow_api.system.NotSet'>, project_id=<class 'flow_api.system.NotSet'>, project_name=<class 'flow_api.system.NotSet'>, track_in_git=<class 'flow_api.system.NotSet'>, debug=False)
Base class: Resource
A file which is stored in Cloudomation Engine.
To store data in a file there are three additional arguments for the save() method available:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# store a text (utf8 string)
system.file('my-file.txt').save_text_content('text content')
# read as base64
assert system.file('my-file.txt').get_base64_content() == 'dGV4dCBjb250ZW50'
# store bytes data
system.file('my-file.dat').save_bytes_content(b'bytes data äöü')
# read as text (utf8 string)
assert system.file('my-file.dat').get_text_content() == 'bytes data äöü'
# store a base64 encoded string
system.file('my-file.ext').save_base64_content('Q2xvdWRvbWF0aW9u')
# read as bytes
assert system.file('my-file.ext').get_bytes_content() == b'Cloudomation'
# list files
for file_ in system.files():
this.log(file_.get('name', 'content_size_bytes'))
# clean up
system.file('my-file.txt').delete()
system.file('my-file.dat').delete()
system.file('my-file.ext').delete()
return this.success('all done')
See the corresponding Resources class at File
Parameters
| Name | Type | Description |
|---|---|---|
| allow_deleted | bool | |
| allow_normal | bool | |
| bundle_id | Union | Reference to the bundle this record is associated with. Allowed for BUNDLE_REPOSITORY, CONNECTOR, CUSTOM_OBJECT, DEVOLUTIONS_CONFIG, EXECUTION, FILE, FLOW, LDAP_CONFIG, MESSAGE, OAUTH, OBJECT_TEMPLATE, PLUGIN, ROLE, SCHEDULE, SCHEDULER, SCHEMA, SETTING, SYNC_CONFIG, TAG, VAULT_CONFIG, WEBHOOK, WRAPPER. Not allowed for BUNDLE, ORGANIZATION, PROCESS, PROJECT, USER, WORKSPACE. Mutually exclusive with project_id |
| bundle_name | Union | The name of the bundle. Will look up the bundle and set bundle_id. |
| by | str | |
| cls | Optional | |
| commit | bool | |
| commit_message | Union | The commit message for this change. |
| content | Union | The binary content of the file. |
| debug | bool | if set, the content of the data being written will be logged. |
| description | Union | A multiline description of what this record is and does. |
| init | Optional | |
| is_bundle_content | Union | A flag to control if the resource is considered bundle content. Changes in bundle content mark the bundle as modified. Updating the bundle will modify the bundle content. |
| is_readonly | Union | A flag to control if the record can be modified. Allowed for BUNDLE, BUNDLE_REPOSITORY, CONNECTOR, CUSTOM_OBJECT, DEVOLUTIONS_CONFIG, FILE, FLOW, OAUTH, OBJECT_TEMPLATE, PLUGIN, PROJECT, ROLE, SCHEDULE, SCHEDULER, SCHEMA, SETTING, SYNC_CONFIG, TAG, VAULT_CONFIG, WEBHOOK, WRAPPER. Not allowed for EXECUTION, LDAP_CONFIG, MESSAGE, ORGANIZATION, PROCESS, USER, WORKSPACE |
| location_inheritance | Union | Controls the project/bundle association of a newly created record when no project_id/project_name/bundle_id/bundle_name is specified in the create request. Depending on the record type different options are available: <table> <thead> <tr> <th>location_inheritance</th> <th>record types</th> <th>description</th> </tr> </thead> <tbody> <tr> <td><code>created_by</code></td> <td>all</td> <td>use the same location as the identity which creates the record</td> </tr> <tr> <td><code>default</code></td> <td>all</td> <td>use the "Default project" where applicable or "Workspace" for record types which cannot be in a project</td> </tr> <tr> <td><code>wrapped_resource</code></td> <td>execution</td> <td>use the same location as the innermost resource which is wrapped</td> </tr> <tr> <td><code>resource</code></td> <td>execution</td> <td>use the same location as the resource on which the execution is based on</td> </tr> </tbody> </table> Notes: <ul> <li>If a <code>project_id</code>/<code>project_name</code>/<code>bundle_id</code>/<code>bundle_name</code> is specified in the request, it always takes precedence.</li> <li>The options <code>wrapped_resource</code> and <code>resource</code> only work with executions which are based on a resource, not with ad-hoc connections or executions of type "SCRIPT". If used with ad-hoc connections or "SCRIPT" it will fall back to <code>default</code>.</li> <li>If the record being created cannot be associated with the specified location, the fallback to <code>default</code> will be used.</li> <li>If <code>location_inheritance</code> is unset, the default value used depends on the type of identity which creates the record as well as the type of record which is created. If an execution is created by any identity which is not an execution, it defaults to <code>wrapped_resource</code>. In all other cases it defaults to <code>created_by</code>.</li> </ul> |
| name | Union | The name of this record. Must be unique across a workspace. |
| project_id | Union | Reference to the project this record is associated with. Allowed for CONNECTOR, CUSTOM_OBJECT, DEVOLUTIONS_CONFIG, EXECUTION, FILE, FLOW, MESSAGE, OAUTH, OBJECT_TEMPLATE, PLUGIN, SCHEDULE, SCHEDULER, SCHEMA, SETTING, SYNC_CONFIG, TAG, VAULT_CONFIG, WEBHOOK, WRAPPER. Not allowed for BUNDLE, BUNDLE_REPOSITORY, LDAP_CONFIG, ORGANIZATION, PROCESS, PROJECT, ROLE, USER, WORKSPACE. Mutually exclusive with bundle_id. |
| project_name | Union | The name of the project. Will look up the project and set project_id. |
| select | Optional | |
| track_in_git | Union | Should new records automatically be tracked in git. |