nisystemlink.clients.file
- class nisystemlink.clients.file.FileClient(configuration=None)[source]
- __init__(configuration=None)[source]
Initialize an instance.
- Parameters
configuration (
Optional[nisystemlink.clients.core.HttpConfiguration]) – Defines the web server to connect to and information about how to connect. If not provided, theHttpConfigurationManageris used to obtain the configuration.- Raises
ApiException – if unable to communicate with the File Service.
- api_info()[source]
Get information about available API operations.
- Return type
- Returns
Information about available API operations.
- Raises
ApiException – if unable to communicate with the File Service.
- get_files(skip=0, take=0, order_by=None, order_by_descending=False, ids=None)[source]
Lists available files on the SystemLink File service. Use the skip and take parameters to return paged responses. The orderBy and orderByDescending fields can be used to manage sorting the list by metadata objects.
- Parameters
skip (
int) – How many files to skip in the result when paging. Defaults to 0.take (
int) – How many files to return in the result, or 0 to use a default defined by the service.0. (Defaults to) –
order_by (
Optional[nisystemlink.clients.file.models.FileQueryOrderBy]) – The name of the metadata key to sort by. Defaults to None.order_by_descending (
Optional[bool]) – The elements in the list are sorted ascending if FalseFalse. (and descending if True. Defaults to) –
ids (
Optional[List[str]]) – List of file IDs to search by. Defaults to None.
- Return type
- Returns
File Query Response
- Raises
ApiException – if unable to communicate with the File Service.
- query_files_linq(query)[source]
Queries file using LINQ filters.
- Parameters
query (
nisystemlink.clients.file.models.FileLinqQueryRequest) – The LINQ query request containing the query string and optional parameters.- Return type
- Returns
File Query Response
- Raises
ApiException – if unable to communicate with the File Service.
- delete_file(id)[source]
Deletes the file indicated by the file_id.
- Parameters
id (
str) – The ID of the file.- Raises
ApiException – if unable to communicate with the File Service.
- Return type
None
- delete_files(ids)[source]
Delete multiple files.
- Parameters
ids (
List[str]) – List of unique IDs of Files.- Raises
ApiException – if unable to communicate with the File Service.
- Return type
None
- upload_file(file, metadata=None, id=None, workspace=None)[source]
Uploads a file to the File Service.
- Parameters
file (
BinaryIO) – The file to upload.metadata (
Optional[Dict[str,str]]) – File Metadata as dictionary.id (
Optional[str]) – Specify an unique (among all file) 24-digit Hex string ID of the file once it is uploaded. Defaults to None.workspace (
Optional[str]) – The id of the workspace the file belongs to. Defaults to None.
- Return type
str- Returns
ID of uploaded file.
- Raises
ApiException – if unable to communicate with the File Service.
- download_file(id)[source]
Downloads a file from the SystemLink File service.
- Parameters
id (
str) – The ID of the file.- Yields
A file-like object for reading the exported data.
- Raises
ApiException – if unable to communicate with the File Service.
- Return type
- update_metadata(metadata, id)[source]
Updates an existing file’s metadata with the specified metadata properties.
- Parameters
metadata (
nisystemlink.clients.file.models.UpdateMetadataRequest) – File’s metadata and options for updating it.id (
str) – ID of the file to update Metadata.
- Raises
ApiException – if unable to communicate with the File Service.
- Return type
None
- class nisystemlink.clients.file.models.FileLinqQueryOrderBy(value)[source]
Order Files LINQ Query by Metadata for POST /query-files-linq endpoint.
- pydantic model nisystemlink.clients.file.models.FileLinqQueryRequest[source]
Show JSON schema
{ "title": "FileLinqQueryRequest", "type": "object", "properties": { "filter": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Filter" }, "orderBy": { "anyOf": [ { "$ref": "#/$defs/FileLinqQueryOrderBy" }, { "type": "null" } ], "default": null }, "orderByDescending": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Orderbydescending" }, "take": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Take" } }, "$defs": { "FileLinqQueryOrderBy": { "description": "Order Files LINQ Query by Metadata for POST /query-files-linq endpoint.", "enum": [ "created", "updated", "extension", "size", "workspace" ], "title": "FileLinqQueryOrderBy", "type": "string" } } }
- Fields
-
field filter:
Optional[str] = None The filter criteria for files. Consists of a string of queries composed using AND/OR operators. String values and date strings need to be enclosed in double quotes. Parentheses can be used around filters to better define the order of operations.
Example Filter syntax: ‘[property name][operator][operand] and [property name][operator][operand]’
-
field order_by:
Optional[FileLinqQueryOrderBy] = None The property by which to order the files in the response.
-
field order_by_descending:
Optional[bool] = False If true, the files are ordered in descending order based on the property specified in order_by.
-
field take:
Optional[int] = None The maximum number of files to return in the response. Default value is 1000
- pydantic model nisystemlink.clients.file.models.FileLinqQueryResponse[source]
Show JSON schema
{ "title": "FileLinqQueryResponse", "type": "object", "properties": { "availableFiles": { "items": { "$ref": "#/$defs/LinqQueryFileMetadata" }, "title": "Availablefiles", "type": "array" }, "totalCount": { "$ref": "#/$defs/TotalCount" } }, "$defs": { "LinqQueryFileMetadata": { "description": "Metadata for a file returned by a LINQ query.", "properties": { "created": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created" }, "id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Id" }, "properties": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Properties" }, "serviceGroup": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Servicegroup" }, "size": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size" }, "size64": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size64" }, "workspace": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Workspace" }, "updated": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated" } }, "title": "LinqQueryFileMetadata", "type": "object" }, "TotalCount": { "description": "The total number of files that match the query regardless of skip and take values", "properties": { "relation": { "title": "Relation", "type": "string" }, "value": { "title": "Value", "type": "integer" } }, "required": [ "relation", "value" ], "title": "TotalCount", "type": "object" } }, "required": [ "availableFiles", "totalCount" ] }
- Fields
-
field available_files:
List[LinqQueryFileMetadata] [Required] The list of files returned by the query
- field total_count: TotalCount [Required]
The total number of files that match the query regardless of skip and take values
- pydantic model nisystemlink.clients.file.models.FileMetadata[source]
Show JSON schema
{ "title": "FileMetadata", "type": "object", "properties": { "created": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created" }, "id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Id" }, "properties": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Properties" }, "serviceGroup": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Servicegroup" }, "size": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size" }, "size64": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size64" }, "workspace": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Workspace" }, "_links": { "anyOf": [ { "additionalProperties": { "$ref": "#/$defs/Link" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Links" }, "path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Path" }, "metaDataRevision": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Metadatarevision" }, "lastUpdatedTimestamp": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Lastupdatedtimestamp" } }, "$defs": { "Link": { "properties": { "href": { "examples": [ "/nifile/v1/service-groups" ], "title": "Href", "type": "string" } }, "required": [ "href" ], "title": "Link", "type": "object" } } }
-
field field_links:
Optional[Dict[str,Link]] = None The links to access and manipulate the file: - data: Link to download the file using a GET request - delete: Link to delete the file using a DELETE request - self: Link to the file’s metadata - updateMetadata: Link to update the file’s metadata using a POST request
-
field last_updated_timestamp:
Optional[datetime] = None The date and time the file was last updated in the file service.
example: 2018-05-15T18:54:27.519Z
-
field meta_data_revision:
Optional[int] = None The file’s properties revision number. When a file is uploaded, the revision number starts at 1. Every time metadata is updated, the revision number is incremented by 1.
-
field path:
Optional[str] = None The path to the file on the server. This field is returned only if the user has associated privileges to view file paths.
example: C: empafb2ce3741fe11d88838cc9.txt
-
field field_links:
- class nisystemlink.clients.file.models.FileQueryOrderBy(value)[source]
Order Files Query Response by Metadata for GET /files endpoint.
- pydantic model nisystemlink.clients.file.models.FileQueryResponse[source]
The result of a file query
Show JSON schema
{ "title": "FileQueryResponse", "description": "The result of a file query", "type": "object", "properties": { "_links": { "additionalProperties": { "$ref": "#/$defs/Link" }, "title": "Links", "type": "object" }, "availableFiles": { "items": { "$ref": "#/$defs/FileMetadata" }, "title": "Availablefiles", "type": "array" }, "totalCount": { "title": "Totalcount", "type": "integer" } }, "$defs": { "FileMetadata": { "properties": { "created": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created" }, "id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Id" }, "properties": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Properties" }, "serviceGroup": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Servicegroup" }, "size": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size" }, "size64": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Size64" }, "workspace": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Workspace" }, "_links": { "anyOf": [ { "additionalProperties": { "$ref": "#/$defs/Link" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Links" }, "path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Path" }, "metaDataRevision": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Metadatarevision" }, "lastUpdatedTimestamp": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Lastupdatedtimestamp" } }, "title": "FileMetadata", "type": "object" }, "Link": { "properties": { "href": { "examples": [ "/nifile/v1/service-groups" ], "title": "Href", "type": "string" } }, "required": [ "href" ], "title": "Link", "type": "object" } }, "required": [ "_links", "availableFiles", "totalCount" ] }
- field available_files: List[FileMetadata] [Required]
The list of files returned by the query
- field field_links: Dict[str, Link] [Required]
The links that apply to the collection of files for a service group: - deleteFiles: Link to delete multiple files from the service group using a POST - query: Link to query for available files in the service group using a POST - search: Link to retrieve a filtered list of files in the service group using a GET - self: Link to the current service group - upload: Link to upload files to the service group using a POST
- field total_count: int [Required]
The total number of files that match the query regardless of skip and take values
- pydantic model nisystemlink.clients.file.models.Link[source]
Show JSON schema
{ "title": "Link", "type": "object", "properties": { "href": { "examples": [ "/nifile/v1/service-groups" ], "title": "Href", "type": "string" } }, "required": [ "href" ] }
- Fields
-
field href:
str[Required] URI of the link
- pydantic model nisystemlink.clients.file.models.UpdateMetadataRequest[source]
The file’s metadata and options for updating it.
Show JSON schema
{ "title": "UpdateMetadataRequest", "description": "The file's metadata and options for updating it.", "type": "object", "properties": { "replaceExisting": { "title": "Replaceexisting", "type": "boolean" }, "expectedRevision": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Expectedrevision" }, "properties": { "type": "object", "additionalProperties": { "type": "string" }, "title": "Properties" }, "workspace": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Workspace" } }, "required": [ "replaceExisting", "properties" ] }
-
field expected_revision:
Optional[int] = None When specified, this is an integer that should be set to match the last known revision number of the metadata. If it doesn’t match at the time of execution, the update request will be rejected. This is used to ensure that changes to this file metadata are correctly using the previous state.
-
field properties:
Dict[str,str] [Required] The properties to set. A map of key value properties containing the metadata to be attached.
- Predefined:
Name: This is an optional property for renaming the file. When specified, the file will be renamed.
-
field replace_existing:
bool[Required] Determines whether the current list should be entirely replaced by the specified list or merged with the existing list.
-
field workspace:
Optional[str] = None When specified, the workspace of the metadata will be updated to the new value.
-
field expected_revision:
- pydantic model nisystemlink.clients.file.models.V1Operations[source]
Show JSON schema
{ "title": "V1Operations", "type": "object", "properties": { "operations": { "anyOf": [ { "$ref": "#/$defs/Operations" }, { "type": "null" } ], "default": null } }, "$defs": { "Operation": { "description": "Represents an operation that can be performed on a data frame.", "properties": { "available": { "title": "Available", "type": "boolean" }, "version": { "title": "Version", "type": "integer" } }, "required": [ "available", "version" ], "title": "Operation", "type": "object" }, "Operations": { "properties": { "deleteFiles": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null }, "downloadData": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null }, "listFiles": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null }, "queryFiles": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null }, "updateMetadata": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null }, "uploadFiles": { "anyOf": [ { "$ref": "#/$defs/Operation" }, { "type": "null" } ], "default": null } }, "title": "Operations", "type": "object" } } }
- Fields
-
field operations:
Optional[Operations] = None Available operations in the v1 version of the API: - deleteFiles: The ability to delete uploaded files - downloadData: The ability to download file data - listFiles: The ability to list available files and service groups - queryFiles: The ability to query available files and service groups - updateMetadata: The ability to update file metadata properties - uploadFiles: The ability to upload files