nyx_client ========== .. py:module:: nyx_client .. autoapi-nested-parse:: NYC client SDK. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/nyx_client/client/index /autoapi/nyx_client/configuration/index /autoapi/nyx_client/data/index Classes ------- .. autoapisummary:: nyx_client.NyxClient nyx_client.BaseNyxConfig nyx_client.ConfigType nyx_client.NyxConfigExtended nyx_client.Data Package Contents ---------------- .. py:class:: NyxClient(config = None) A client for interacting with the Nyx system. This client provides methods for querying and processing data from Nyx. .. attribute:: config Configuration for the Nyx client. .. attribute:: org Your organization name on Nyx. .. attribute:: name Your Nyx Username. .. attribute:: community_mode If you're using community mode. .. py:method:: sparql_query(query, result_type = SparqlResultType.SPARQL_JSON, local_only = False) Execute a SPARQL query and process the results. NOTE: This method is experimental and its definition might change without notice! :param query: A SPARQL 1.1 query string. :param result_type: The result format for the query. :param local_only: Whether to only query the local Nyx instance as opposed to the whole Nyx network. :returns: A string of the result in the specified format :raises requests.HTTPError: If there's an HTTP error during the query execution. .. py:method:: categories() Retrieve all categories from the federated network. :returns: A list of category names. .. py:method:: genres() Retrieve all genres from the federated network. :returns: A list of genre names. .. py:method:: creators() Retrieve all creators from the federated network. :returns: A list of creator names. .. py:method:: content_types() Retrieve all content Types from the federated network. :returns: A list of content types. .. py:method:: licenses() Retrieve all licenses from the federated network. :returns: A list of licenses. .. py:method:: search(*, categories = (), genre = None, creator = None, text = None, license = None, content_type = None, subscription_state = 'all', timeout = 3, local_only = False) Search for new data in the Nyx system. :param categories: Sequence of categories to filter by. :param genre: Genre to filter by. :param creator: Creator to filter by. :param text: Text to search for. :param license: License to filter by. :param content_type: Content type to filter by. :param subscription_state: Subscription state to filter by. :param timeout: Timeout for the search request in seconds. :param local_only: Whether to only search for data defined in the local Nyx instance as opposed to the whole Nyx network. :returns: A list of `Data` instances matching the search criteria. .. py:method:: my_subscriptions(*, categories = (), genre = None, creator = None, license = None, content_type = None) Retrieve only subscribed data from the federated network. :param categories: Sequence of categories to filter by. :param genre: Genre to filter by. :param creator: Creator to filter by. :param license: License to filter by. :param content_type: Content type to filter by. :returns: A list of `Data` instances matching the criteria. .. py:method:: my_data(categories = (), genre = None, license = None, content_type = None) Retrieve data I have created. :param categories: Sequence of categories to filter by. :param genre: Genre to filter by. :param license: License to filter by. :param content_type: Content type to filter by. :returns: A list of `Data` instances matching the criteria. .. py:method:: get_data(*, categories = (), genre = None, creator = None, license = None, content_type = None, subscription_state = 'all', local_only = False) Retrieve data from the federated network. :param categories: Sequence of categories to filter by. :param genre: Genre to filter by. :param creator: Creator to filter by. :param license: License to filter by. :param content_type: Content type to filter by. :param subscription_state: Subscription state to filter by. :param local_only: Whether to only interrogate data defined in the local Nyx instance as opposed to the whole Nyx network. :returns: A list of `Data` instances matching the criteria. .. py:method:: get_my_data_by_name(name) Retrieve your own data based on its unique name. This only works on data you own :param name: The data unique name (unique per organization). :returns: Your `Data` instance identified with the provided name. :raises requests.HTTPError: If the API request fails. .. py:method:: create_data(name, title, description, size, genre, categories, download_url, content_type, lang = 'en', status = 'published', preview = '', price = None, license_url = None) Create new data in the system. :param name: The unique identifier for the data. :param title: The display title of the data. :param description: A detailed description of the data. :param size: The size of the data, typically in bytes. :param genre: The genre or category of the data. :param categories: A list of categories the data belongs to. :param download_url: The URL where the data can be downloaded. :param content_type: The mime type of the data located at download_url. :param lang: The language of the data. :param status: The publication status of the data. :param preview: A preview or sample of the data. :param price: The price of the data in cents. If 0, the data is free. :param license_url: The URL of the license for the data. :returns: A `Data` instance, containing the download URL and title. :raises requests.HTTPError: If the API request fails. .. py:method:: update_data(name, title, description, size, genre, categories, download_url, content_type, lang = 'en', status = 'published', preview = '', price = None, license_url = None) Updates existing data in the system. :param name: The unique identifier for the data. :param title: The display title of the data. :param description: A detailed description of the data. :param size: The size of the data, typically in bytes. :param genre: The genre or category of the data. :param categories: A list of categories the data belongs to. :param download_url: The URL where the data can be downloaded. :param content_type: The mime type of the data located at download_url. :param lang: The language of the data. :param status: The publication status of the data. :param preview: A preview or sample of the data. :param price: The price of the data in cents. If 0, the data is free. :param license_url: The URL of the license for the data. :returns: A `Data` instance, containing the updated information. :raises requests.HTTPError: If the API request fails. .. py:method:: delete_data(data) Delete the provided data from Nyx. :param data: The data to delete. :raises requests.HTTPError: If the API request fails. .. py:method:: delete_data_by_name(name) Delete the data uniquely identified by the provided name from Nyx. :param name: The data unique name. :raises requests.HTTPError: If the API request fails. .. py:method:: subscribe(data) Subscribe to the data. :param data: The data object to subscribe to. :raises requests.HTTPError: If the API request fails. .. py:method:: unsubscribe(data) Unsubscribe from the data. :param data: The data object to unsubscribe from. :raises requests.HTTPError: If the API request fails. .. py:class:: BaseNyxConfig Configuration for the Nyx client. .. attribute:: nyx_url The URL of the Nyx instance. .. attribute:: nyx_username The username of the Nyx user. .. attribute:: nyx_email The email of the Nyx user. .. attribute:: nyx_password The password of the Nyx user. .. py:method:: from_env(env_file = None, override_token = None) :classmethod: Create a BaseNyxConfig instance from environment variables. :param env_file: Path to the environment file. :param override_token: Token to override the default authentication. :returns: A new BaseNyxConfig instance. :raises OSError: If required environment variables are not set. .. py:method:: __str__() Return a string representation of the configuration. :returns: A JSON string of the configuration. .. py:property:: nyx_auth :type: dict Get the authentication credentials. :returns: A dictionary containing email and password for authentication. .. py:class:: ConfigType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Nyx configuration types. .. py:class:: NyxConfigExtended Extended configuration for Nyx client with API integration. .. attribute:: api_key The API key for the selected provider. .. attribute:: provider The type of configuration provider. .. attribute:: base_config The base Nyx configuration. .. py:method:: from_env(provider, env_file = None, override_token = None) :classmethod: Create a NyxConfigExtended instance from environment variables. :param provider: The type of configuration provider. :param env_file: Path to the environment file. :param override_token: Token to override the default authentication. :returns: A new NyxConfigExtended instance. :raises Exception: If an unsupported config type is provided. .. py:class:: Data(name, title, description, org, url, content_type, creator, categories, genre, size = 0) Represents the data in the Nyx system. This class encapsulates the information and functionality related to the data in the Nyx system, including its metadata and content retrieval. .. py:method:: __str__() Return a string representation of the Data instance. .. py:method:: as_string() Download the content of the data as a string. This method attempts to download the content from the data's URL. :returns: The downloaded content as decoded text or None, if the download fails. .. py:method:: as_bytes() Download the content of the data as bytes. This method attempts to download the content from the data's URL. :returns: The downloaded content as bytes or None, if the download fails.