nyx_client.client ================= .. py:module:: nyx_client.client .. autoapi-nested-parse:: Module for managing connection to Nyx. Classes ------- .. autoapisummary:: nyx_client.client.SparqlResultType nyx_client.client.NyxClient Module Contents --------------- .. py:class:: SparqlResultType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Available query result (response) types for SPARQL query. .. py:method:: __str__() Return str(self). .. py:class:: NyxClient(config = None) A client for interacting with the Nyx system. This client provides methods for querying and processing data from Nyx. .. py:attribute:: config :type: nyx_client.configuration.BaseNyxConfig Configuration for the Nyx client. .. py:attribute:: org :type: str Your organization name on Nyx. .. py:attribute:: name :type: str Your Nyx Username. .. py:attribute:: community_mode :type: bool 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, genre, categories, content_type, lang = 'en', status = 'published', preview = '', size = None, price = None, license_url = None, download_url = None, file = None, access_control = None, circles = ()) 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: Approximate size of the data, if a file is provided the size will be calculated :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 file: the file like object (RawIOBase) that you wish to upload :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. :param access_control: Either allow all, or allow none :param circles: a list of circles to add share the data with :returns: A `Data` instance, containing the download URL and title. :raises requests.HTTPError: If the API request fails. :raises ValueError: When download_url and file are both provided or both missing .. py:method:: update_data(name, title, description, genre, categories, content_type, lang = 'en', status = 'published', preview = '', size = None, price = None, license_url = None, download_url = None, file = None, access_control = None, circles = ()) 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 file: the file like object (RawIOBase) that you wish to upload :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. :param access_control: Either allow all, or allow none :param circles: a list of circles to add share the data with :returns: A `Data` instance, containing the updated information. :raises requests.HTTPError: If the API request fails. :raises ValueError: When download_url and file are both provided or both missing .. 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:method:: organizations() Get a list of all organizations in the federated network. :returns: A list of `RemoteHost` objects :raises requests.HTTPError: if the API request fails. .. py:method:: get_circles() Get a list of circles. :returns: A list of `Circle` objects :raises requests.HTTPError: if the API request fails. .. py:method:: get_circle_by_name(circle_name) Get a list of circles. :param circle_name: The name of the circle to get. :returns: A `Circle` object :raises requests.HTTPError: if the API request fails. .. py:method:: create_circle(circle) Create a circle. :param circle: The circle to be created. :returns: An updated `Circle` object :raises requests.HTTPError: If the API request fails. .. py:method:: update_circle(circle) Updates a circle, based on the cirle's name. :param circle: The circle to be updated. :raises requests.HTTPError: If the API request fails. .. py:method:: delete_circle_by_name(circle_name) Deletes a circle. :param circle_name: The name of the circle to be deleted. :raises requests.HTTPError: If the API request fails. .. py:method:: delete_circle(circle) Deletes a circle. :param circle: The circle to be deleted. :raises requests.HTTPError: If the API request fails.