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, theHttpConfigurationManager
is 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.
- 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
- pydantic model nisystemlink.clients.file.models.FileMetadata[source]
Show JSON schema
{ "title": "FileMetadata", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "_links": { "title": " Links", "type": "object", "additionalProperties": { "$ref": "#/definitions/Link" } }, "created": { "title": "Created", "type": "string", "format": "date-time" }, "id": { "title": "Id", "type": "string" }, "path": { "title": "Path", "type": "string" }, "properties": { "title": "Properties", "type": "object", "additionalProperties": { "type": "string" } }, "metaDataRevision": { "title": "Metadatarevision", "type": "integer" }, "serviceGroup": { "title": "Servicegroup", "type": "string" }, "size": { "title": "Size", "type": "integer" }, "size64": { "title": "Size64", "type": "integer" }, "workspace": { "title": "Workspace", "type": "string" }, "lastUpdatedTimestamp": { "title": "Lastupdatedtimestamp", "type": "string", "format": "date-time" } }, "definitions": { "Link": { "title": "Link", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "href": { "title": "Href", "example": "/nifile/v1/service-groups", "type": "string" } }, "required": [ "href" ] } } }
- Fields
-
field created:
Optional
[datetime
] = None The date and time the file was created in the file service.
example :2018-05-15T18:54:27.519Z
-
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 id:
Optional
[str
] = None The file’s ID within the service group.
example: “5afb2ce3741fe11d88838cc9”
-
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 properties:
Optional
[Dict
[str
,str
]] = None The file’s properties Example - {“Name”: “myfile.txt”, “MyProperty”: “Value”}
-
field service_group:
Optional
[str
] = None The service group that owns the file
-
field size:
Optional
[int
] = None The 32-bit file size in bytes. If the value is larger than a 32-bit integer, this value is -1 and the size64 parameter contains the correct value.
-
field size64:
Optional
[int
] = None The 64-bit file size in bytes
-
field workspace:
Optional
[str
] = None The workspace the file belongs to
- class nisystemlink.clients.file.models.FileQueryOrderBy(value)[source]
Order Files Query Response by Metadata.
- 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": { "title": " Links", "type": "object", "additionalProperties": { "$ref": "#/definitions/Link" } }, "availableFiles": { "title": "Availablefiles", "type": "array", "items": { "$ref": "#/definitions/FileMetadata" } }, "totalCount": { "title": "Totalcount", "type": "integer" } }, "required": [ "_links", "availableFiles", "totalCount" ], "definitions": { "Link": { "title": "Link", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "href": { "title": "Href", "example": "/nifile/v1/service-groups", "type": "string" } }, "required": [ "href" ] }, "FileMetadata": { "title": "FileMetadata", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "_links": { "title": " Links", "type": "object", "additionalProperties": { "$ref": "#/definitions/Link" } }, "created": { "title": "Created", "type": "string", "format": "date-time" }, "id": { "title": "Id", "type": "string" }, "path": { "title": "Path", "type": "string" }, "properties": { "title": "Properties", "type": "object", "additionalProperties": { "type": "string" } }, "metaDataRevision": { "title": "Metadatarevision", "type": "integer" }, "serviceGroup": { "title": "Servicegroup", "type": "string" }, "size": { "title": "Size", "type": "integer" }, "size64": { "title": "Size64", "type": "integer" }, "workspace": { "title": "Workspace", "type": "string" }, "lastUpdatedTimestamp": { "title": "Lastupdatedtimestamp", "type": "string", "format": "date-time" } } } } }
-
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
-
field available_files:
- pydantic model nisystemlink.clients.file.models.Link[source]
Show JSON schema
{ "title": "Link", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "href": { "title": "Href", "example": "/nifile/v1/service-groups", "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": { "title": "Expectedrevision", "type": "integer" }, "properties": { "title": "Properties", "type": "object", "additionalProperties": { "type": "string" } }, "workspace": { "title": "Workspace", "type": "string" } }, "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", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "operations": { "$ref": "#/definitions/Operations" } }, "definitions": { "Operation": { "title": "Operation", "description": "Represents an operation that can be performed on a data frame.", "type": "object", "properties": { "available": { "title": "Available", "type": "boolean" }, "version": { "title": "Version", "type": "integer" } }, "required": [ "available", "version" ] }, "Operations": { "title": "Operations", "description": "Base class for models that are serialized to and from JSON.", "type": "object", "properties": { "deleteFiles": { "$ref": "#/definitions/Operation" }, "downloadData": { "$ref": "#/definitions/Operation" }, "listFiles": { "$ref": "#/definitions/Operation" }, "queryFiles": { "$ref": "#/definitions/Operation" }, "updateMetadata": { "$ref": "#/definitions/Operation" }, "uploadFiles": { "$ref": "#/definitions/Operation" } } } } }
- 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