File
class resources.file.File
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 Flow Api class at File
Property | Description | Type | Import/Export | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bundle_id | 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 | UUID(as_uuid=False) | both | |||||||||||||||
bundle_name | The name of the bundle. Will look up the bundle and set bundle_id. | String(length=128) | neither | |||||||||||||||
commit_message | The commit message for this change. | Text() | import only | |||||||||||||||
content | The binary content of the file. | BYTEA() | both | |||||||||||||||
content_size_bytes | The size of the content in bytes. | BigInteger() | export only | |||||||||||||||
created_at | DateTime(timezone=True) | export only | ||||||||||||||||
created_by | UUID(as_uuid=False) | export only | ||||||||||||||||
deleted_at | DateTime(timezone=True) | export only | ||||||||||||||||
deleted_by | UUID(as_uuid=False) | export only | ||||||||||||||||
description | A multiline description of what this record is and does. | Text() | both | |||||||||||||||
has_deprecation | Boolean() | export only | ||||||||||||||||
has_syntax_error | Boolean() | export only | ||||||||||||||||
id | UUID(as_uuid=False) | neither | ||||||||||||||||
is_bundle_content | 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. | Boolean() | both | |||||||||||||||
is_bundle_readonly | Boolean() | neither | ||||||||||||||||
is_deleted | Boolean() | export only | ||||||||||||||||
is_project_readonly | Boolean() | neither | ||||||||||||||||
is_readonly | 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 | Boolean() | both | |||||||||||||||
location_inheritance | 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:
| String(length=128) | neither | |||||||||||||||
modified_at | DateTime(timezone=True) | export only | ||||||||||||||||
modified_by | UUID(as_uuid=False) | export only | ||||||||||||||||
name | The name of this record. Must be unique across a workspace. | String(length=128) | both | |||||||||||||||
organization_id | UUID(as_uuid=False) | export only | ||||||||||||||||
project_id | 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. | UUID(as_uuid=False) | both | |||||||||||||||
project_name | The name of the project. Will look up the project and set project_id. | String(length=128) | neither | |||||||||||||||
record_type | Enum('BUNDLE', 'BUNDLE_REPOSITORY', 'CONNECTOR', 'CUSTOM_OBJECT', 'DEVOLUTIONS_CONFIG', 'EXECUTION', 'FILE', 'FLOW', 'LDAP_CONFIG', 'MESSAGE', 'OAUTH', 'OBJECT_TEMPLATE', 'ORGANIZATION', 'PLUGIN', 'PROCESS', 'PROJECT', 'ROLE', 'SCHEDULE', 'SCHEDULER', 'SCHEMA', 'SETTING', 'SYNC_CONFIG', 'TAG', 'USER', 'VAULT_CONFIG', 'WEBHOOK', 'WORKSPACE', 'WRAPPER', name='recordtype') | neither | ||||||||||||||||
repository_path | The path to the storing repository, relative to GIT_REPOSITORY_SAVE_PATH | String(length=256) | neither | |||||||||||||||
resource_type | Enum('BUNDLE', 'BUNDLE_REPOSITORY', 'CONNECTOR', 'CUSTOM_OBJECT', 'DEVOLUTIONS_CONFIG', 'FILE', 'FLOW', 'LDAP_CONFIG', 'OAUTH', 'OBJECT_TEMPLATE', 'ORGANIZATION', 'PLUGIN', 'PROJECT', 'ROLE', 'SCHEDULE', 'SCHEDULER', 'SCHEMA', 'SETTING', 'SYNC_CONFIG', 'TAG', 'USER', 'VAULT_CONFIG', 'WEBHOOK', 'WORKSPACE', 'WRAPPER', name='resourcetype') | neither | ||||||||||||||||
schema_version | String(length=128) | both | ||||||||||||||||
workspace_id | UUID(as_uuid=False) | export only |