:orphan: :py:mod:`thanosql.resources._file` ================================== .. py:module:: thanosql.resources._file Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: thanosql.resources._file.ContentInfo thanosql.resources._file.Content thanosql.resources._file.Size thanosql.resources._file.FileService .. py:class:: ContentInfo(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: str .. py:attribute:: format :type: Optional[str] .. py:attribute:: path :type: str .. py:attribute:: type :type: str .. py:attribute:: size :type: Optional[int] .. py:attribute:: writable :type: bool .. py:attribute:: content :type: Any .. py:attribute:: created_at :type: datetime.datetime .. py:attribute:: updated_at :type: datetime.datetime .. py:class:: Content(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: content_info :type: ContentInfo .. py:attribute:: root :type: str .. py:class:: Size(/, **data: Any) Bases: :py:obj:`thanosql.resources._model.BaseModel` Usage docs: https://docs.pydantic.dev/2.9/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: max_size :type: int .. py:attribute:: used_size :type: int .. py:attribute:: avail_size :type: int .. py:class:: FileService(client: thanosql._client.ThanoSQL) Bases: :py:obj:`thanosql._service.ThanoSQLService` Service layer for file methods. .. attribute:: client The ThanoSQL client used to make requests to the engine. :type: ThanoSQL .. py:method:: get(path: Optional[Union[str, os.PathLike]] = None, option: Optional[str] = None) -> Optional[Content] Details the information of a file or directory in the specified path. :param path: The path to the file/directory relative to the user data root (default value is "/", the user data root directory itself) :type path: str or path_like :param option: - default (None): retrieves file/directory information - download: downloads a file (directory download is not possible) :type option: controls the behavior of the API :returns: Depending on option: - default (None): Returns a Content Pydantic object containing information on the target path - download: Downloads the requested file and returns nothing :rtype: Content | None :raises ThanoSQLValueError: If user attempts to download a directory (when option="download") .. py:method:: create(path: Optional[Union[str, os.PathLike]] = None, file: Optional[Union[str, os.PathLike]] = None) -> Content Uploads a file to the workspace or creates an empty folder. :param path: The destination path of the upload/folder creation relative to the user data root. Should point to a (would-be) directory (default value is "/", the user data root directory itself) :type path: str or path_like :param file: The file to be uploaded. If left empty, creates an empty folder in the given path. :type file: str or PathLike, optional :rtype: A Content Pydantic object containing information on the created file/folder. :raises ThanoSQLValueError: If path does not point to a (would-be) directory .. py:method:: delete(path: Union[str, os.PathLike]) -> None Deletes the specified file or directory permanently from the workspace. :param path: The path to the file or directory to be removed from the workspace. Relative to the user data root, no default value. :type path: str or path_like :rtype: No content