### Install Khoros SDK from Source Source: https://khoros.readthedocs.io/en/latest/_sources/introduction.rst.txt Install the Khoros SDK from its source repository. This involves cloning the repository and running the setup script. ```shell git clone git://github.com/jeffshurtliff/khoros.git cd khoros/ python3 setup.py install ``` -------------------------------- ### Example Usage: Create User Source: https://khoros.readthedocs.io/en/latest/primary-modules.html A basic example demonstrating how to call the `create` function from the `khoros.users` module with minimal required parameters. ```python from khoros.objects import users khoros.users.create(username='john_doe', email='john.doe@example.com') ``` -------------------------------- ### Khoros Configuration File Example Source: https://khoros.readthedocs.io/en/latest/_sources/introduction.rst.txt Example of a YAML configuration file for initializing the Khoros object. It includes connection details and authentication settings. ```yaml # Helper configuration file for the khoros package # Define how to obtain the connection information connection: community_url: https://community.example.com/ tenant_id: example12345 # Define the default authentication type to use default_auth_type: session_auth # Define the OAuth 2.0 credentials oauth2: client_id: FLFeNYob7XXXXXXXXXXXXXXXXXXXXZcWQEQHR5T6bo= client_secret: 1n0AIXXXXXXXXXXXXXXXXXXXX1udOtNaYnfJCeOszYw= redirect_url: http://redirect.community.example.com/getAccessToken # Define the session key authorization information session_auth: username: serviceaccount password: Ch@ng3ME! # Bulk Data API connection information bulk_data: community_id: example.prod client_id: ay0CXXXXXXXXXX/XXXX+XXXXXXXXXXXXX/XXXXX4KhQ= token: 2f25XXXXXXXXXXXXXXXXXXXXXXXXXa10dec04068 europe: no # Define the preferred format for API responses prefer_json: yes ``` -------------------------------- ### Install Khoros SDK Source: https://khoros.readthedocs.io/en/latest/_sources/introduction.rst.txt Install the Khoros SDK package using pip. It is recommended to upgrade to the latest version. ```shell pip install khoros --upgrade ``` -------------------------------- ### Khoros Example File Updates Source: https://khoros.readthedocs.io/en/latest/changelog.html Details updates to example files within the Khoros repository. ```APIDOC ## Khoros Example File Updates ### Description Updates made to example files in the Khoros repository. ### Updates - `examples/helper.yml`: Added the `helper.yml` file using the syntax from the Introduction page. - `discussion_styles` list: Added to the `examples/helper.yml` file. ``` -------------------------------- ### Custom environment variables YAML example Source: https://khoros.readthedocs.io/en/latest/changelogs/changelog-1.1.0-thru-2.5.2.html Example file demonstrating the use of custom environment variables in YAML format. ```yaml custom_env_variables.yml ``` -------------------------------- ### Custom environment variables JSON example Source: https://khoros.readthedocs.io/en/latest/changelogs/changelog-1.1.0-thru-2.5.2.html Example file demonstrating the use of custom environment variables in JSON format. ```json custom_env_variables.json ``` -------------------------------- ### Check Lithium SDK Installation Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/studio/base.html Verifies if the Lithium SDK is installed by attempting to run the 'li' command. ```python def sdk_installed(): """This function checks to see if the Lithium SDK is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether the Lithium SDK is installed """ try: output = core_utils.run_cmd('li') is_installed = True if output['return_code'] == 0 else False except FileNotFoundError: is_installed = False return is_installed ``` -------------------------------- ### Get Total Node Count Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Retrieves the total count of nodes within the Khoros object. No specific setup is required beyond having a valid Khoros object. ```python structures_module.nodes.get_total_node_count(self.khoros_object) ``` -------------------------------- ### Get OAuth Callback URL from User Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/auth.html Instructs the user to visit an authorization URL and then prompts them to enter the full callback URL received. Includes validation to ensure the callback URL starts with 'http'. ```python authorization_url = get_oauth_authorization_url(khoros_object) print("Please visit this URL to authorize access: ", authorization_url) callback_url = input("Enter the full URL in the address bar after visiting the URL above: ") if not callback_url.startswith('http'): raise errors.exceptions.InvalidCallbackURLError(val=callback_url) return callback_url ``` -------------------------------- ### Initialize Khoros Client Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Instantiate the Khoros client using a helper configuration file. ```python khoros = Khoros(helper='helper.yml') ``` -------------------------------- ### Get User Counts with Khoros API Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/utils/tests/test_users.html Instantiate the Khoros core object and retrieve various user-related counts. Asserts verify the response types and values. Note the commented-out example for replies_count due to a TypeError. ```python # Instantiate the core object khoros_object = resources.get_core_object() # Test retrieving the album count and verifying the response album_count = khoros_object.users.get_album_count(user_id=USER_ID) assert isinstance(album_count, int) and album_count >= 0 # Test retrieving the follower count and verifying the response followers_count = khoros_object.users.get_followers_count(user_id=USER_ID) assert isinstance(followers_count, int) and followers_count >= 0 # Test retrieving the following count and verifying the response following_count = khoros_object.users.get_following_count(user_id=USER_ID) assert isinstance(following_count, int) and following_count >= 0 # Test retrieving the images count and verifying the response image_count = khoros_object.users.get_images_count(user_id=USER_ID) assert isinstance(image_count, int) and image_count >= 0 image_count = khoros_object.users.get_public_images_count(user_id=USER_ID) assert isinstance(image_count, int) and image_count >= 0 # Test retrieving the messages count and verifying the response msg_count = khoros_object.users.get_messages_count(user_id=USER_ID) assert isinstance(msg_count, int) and msg_count >= 0 # Test retrieving the roles count and verifying the response roles_count = khoros_object.users.get_roles_count(user_id=USER_ID) assert isinstance(roles_count, int) and roles_count >= 0 # Test retrieving the authored solutions count and verifying the response solutions_count = khoros_object.users.get_solutions_authored_count(user_id=USER_ID) assert isinstance(solutions_count, int) and solutions_count >= 0 # Test retrieving the posted topics count and verifying the response topics_count = khoros_object.users.get_topics_count(user_id=USER_ID) assert isinstance(topics_count, int) and topics_count >= 0 # Test retrieving the posted replies count and verifying the response # TODO: Troubleshoot why the response below returns TypeError: list indices must be integers or slices, not str # replies_count = khoros_object.users.get_replies_count(user_id=USER_ID) # assert isinstance(replies_count, int) and replies_count >= 0 # Test retrieving the posted videos count and verifying the response videos_count = khoros_object.users.get_videos_count(user_id=USER_ID) assert isinstance(videos_count, int) and videos_count >= 0 # Test retrieving the kudos given count and verifying the response kudos_given_count = khoros_object.users.get_kudos_given_count(user_id=USER_ID) assert isinstance(kudos_given_count, int) and kudos_given_count >= 0 # Test retrieving the kudos given count and verifying the response kudos_received_count = khoros_object.users.get_kudos_received_count(user_id=USER_ID) assert isinstance(kudos_received_count, int) and kudos_received_count >= 0 # Test retrieving the online users count online_users_count = khoros_object.users.get_online_user_count() assert isinstance(online_users_count, int) # Test the variations of the get_users_count() method users_count = khoros_object.users.get_users_count() registered_users_count = khoros_object.users.get_users_count(registered=True) online_users_count = khoros_object.users.get_users_count(online=True) assert isinstance(users_count, int) assert isinstance(registered_users_count, int) assert isinstance(online_users_count, int) with pytest.raises(exceptions.InvalidParameterError): khoros_object.users.get_users_count(registered=True, online=True) ``` -------------------------------- ### GET get_roles_count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of roles applied to the user. ```APIDOC ## GET get_roles_count ### Description This method gets the count of roles applied to the user. ### Parameters #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (int) - The number of roles applied to the user ``` -------------------------------- ### Studio Class Initialization and Dependency Checks Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Methods to verify the installation and versioning of the Lithium SDK, Node.js, and npm. ```python class Studio(object): """This class includes methods relating to the Lithium SDK and Studio Plugin.""" def __init__(self, khoros_object): """This method initializes the :py:class:`khoros.core.Khoros.Studio` inner class object. :param khoros_object: The core :py:class:`khoros.Khoros` object :type khoros_object: class[khoros.Khoros] """ self.khoros_object = khoros_object @staticmethod def sdk_installed(): """This method checks to see if the Lithium SDK is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether the Lithium SDK is installed """ return studio_module.base.sdk_installed() @staticmethod def get_sdk_version(): """This method identifies the currently installed version of the Lithium SDK. .. versionadded:: 2.5.1 :returns: The SDK version in string format or ``None`` if not installed """ return studio_module.base.get_sdk_version() @staticmethod def node_installed(): """This method checks whether Node.js is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether Node.js is installed """ return studio_module.base.node_installed() @staticmethod def get_node_version(): """This method identifies and returns the installed Node.js version. .. versionadded:: 2.5.1 :returns: The version as a string or ``None`` if not installed """ return studio_module.base.get_node_version() @staticmethod def npm_installed(): """This method checks whether npm is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether npm is installed """ return studio_module.base.npm_installed() @staticmethod def get_npm_version(): """This method identifies and returns the installed npm version. .. versionadded:: 2.5.1 :returns: The version as a string or ``None`` if not installed """ return studio_module.base.get_npm_version() ``` -------------------------------- ### GET get_replies_count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of replies posted by the user. ```APIDOC ## GET get_replies_count ### Description This method gets the count of replies posted by the user. ### Parameters #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (int) - The number of replies posted by the user ``` -------------------------------- ### Initialize Khoros SDK Configuration Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Handles the setup of bulk data settings, authentication types, and system versioning during object instantiation. ```python for bulk_data_field in ['community_id', 'client_id', 'token', 'europe', 'base_url', 'export_type']: if bulk_data_field not in self.bulk_data_settings: self.bulk_data_settings[bulk_data_field] = None # Add the authentication status if 'active' not in self.auth: self.auth['active'] = False # Update the default authentication type if necessary self.auth['type'] = self.core_settings.get('auth_type') if auth_type is not None: accepted_auth_types = ['session_auth', 'oauth2', 'sso'] auth_map = { 'session_auth': session_auth, 'oauth2': oauth2, 'sso': sso } if str(auth_type) in accepted_auth_types: self.core_settings['auth_type'] = auth_type self.auth['type'] = auth_type if auth_map.get(auth_type) is None and auth_type not in self._helper_settings.get('connection'): error_msg = f"The '{auth_type}' authentication type was specified but no associated data was found." logger.error(error_msg) raise errors.exceptions.MissingAuthDataError(error_msg) else: error_msg = f"'{auth_type}' is an invalid authentication type. Reverting to default. ('session_auth')" logger.warn(error_msg) errors.handlers.eprint(error_msg) self.core_settings.update(Khoros.DEFAULT_AUTH) self.auth['type'] = self.core_settings.get('auth_type') elif sso is not None: self.core_settings['auth_type'] = 'sso' self.auth['type'] = self.core_settings.get('auth_type') elif oauth2 is not None: self.core_settings['auth_type'] = 'oauth2' self.auth['type'] = self.core_settings.get('auth_type') else: if empty: self._populate_empty_object() if session_auth is not None or empty: # Session authentication is selected as the auth type when instantiating an empty object self.core_settings['auth_type'] = 'session_auth' elif self._session_auth_credentials_defined(): self.core_settings['auth_type'] = 'session_auth' elif 'session_auth' not in self._helper_settings.get('connection'): error_msg = f"No data was found for the default '{auth_type}' authentication type." logger.error(error_msg) raise errors.exceptions.MissingAuthDataError(error_msg) # Capture the version information self.sys_version_info = tuple([i for i in sys.version_info]) # Validate the settings self._validate_base_url() self._define_url_settings() # Populate the khoros.core dictionary with core settings self._populate_core_settings() # Populate the khoros.auth dictionary with authentication settings if not empty: self._populate_auth_settings() # Populate the khoros.construct dictionary with query and syntax constructors self._populate_construct_settings() # Auto-connect to the environment if specified (default) if self.core_settings.get('auto_connect'): if self.core_settings.get('auth_type') in ['sso', 'session_auth']: self.connect(self.core_settings.get('auth_type')) else: error_msg = f"Unable to auto-connect to the instance with the given " \ f"'{self.core_settings.get('auth_type')}' authentication type." logger.error(error_msg) errors.handlers.eprint(error_msg) # Import inner object classes so their methods can be called from the primary object self.v1 = self._import_v1_class() self.v2 = self._import_v2_class() self.albums = self._import_album_class() self.archives = self._import_archives_class() self.boards = self._import_board_class() self.bulk_data = self._import_bulk_data_class() self.categories = self._import_category_class() self.communities = self._import_community_class() self.grouphubs = self._import_grouphub_class() self.labels = self._import_label_class() self.messages = self._import_message_class() self.nodes = self._import_node_class() self.roles = self._import_role_class() self.saml = self._import_saml_class() self.settings = self._import_settings_class() self.studio = self._import_studio_class() self.subscriptions = self._import_subscription_class() self.tags = self._import_tag_class() self.users = self._import_user_class() ``` -------------------------------- ### Example Helper YAML Source: https://khoros.readthedocs.io/en/latest/changelog.html Adds the helper.yml file to the examples/ directory, including the discussion_styles list. ```yaml discussion_styles: - name: "Default" id: "default" - name: "Board" id: "board" - name: "Discussion" id: "discussion" - name: "Group Hub" id: "grouphub" ``` -------------------------------- ### GET khoros.objects.users.get_images_count Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Gets the count of images uploaded by the user. ```APIDOC ## GET khoros.objects.users.get_images_count ### Description This function gets the count of images uploaded by the user. ### Parameters #### Path Parameters - **khoros_object** (class) - Required - The core khoros.Khoros object - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response - **Returns** (int) - The number of images uploaded by the user ``` -------------------------------- ### Initialize Helper Settings Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/utils/helper.html Populates the helper_settings dictionary with discussion styles, SSL verification, and error translation settings. ```python helper_settings['discussion_styles'] = _get_discussion_styles(helper_cfg) # Populate the SSL certificate verification setting in the helper dictionary if 'ssl_verify' not in defined_settings: helper_settings.update(_collect_values('ssl_verify', helper_cfg)) # Populate the error translation setting in the helper dictionary helper_settings.update(_collect_values('translate_errors', helper_cfg, _ignore_missing=True)) # Return the helper_settings dictionary return helper_settings ``` -------------------------------- ### GET /v1/endpoint Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Performs a Community API v1 GET request. ```APIDOC ## GET /v1/endpoint ### Description This method makes a Community API v1 GET request. ### Method GET ### Parameters #### Query Parameters - **endpoint** (str) - Required - The API endpoint to be queried - **query_params** (dict) - Optional - The field and associated values to be leveraged in the query string - **return_json** (bool) - Optional - Determines if the response should be returned in JSON format - **proxy_user_object** (ImpersonatedUser) - Optional - Instantiated object to perform the request on behalf of a secondary user ### Response - **response** (any) - The API response ``` -------------------------------- ### Create Board and Return URL (Python) Source: https://khoros.readthedocs.io/en/latest/_sources/boards.rst.txt Demonstrates how to obtain the URL of a newly created board by setting `return_url=True`. This is a common option for direct user access to the created content. ```python >>> khoros.boards.create('python-lovers', 'The Python Lovers Blog', \ ... 'blog', return_url=True) ... ``` ```python 'https://stage.example.com/t5/The-Python-Lovers-Blog/bg-p/python-lovers' ``` -------------------------------- ### GET /users/videos/count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of videos uploaded by a specific user. ```APIDOC ## GET /users/videos/count ### Description This method gets the count of videos uploaded by the user. ### Method GET ### Endpoint /users/videos/count ### Parameters #### Query Parameters - **user_settings** (dict | None) - Optional - A dictionary containing all relevant user settings supplied in the parent function - **user_id** (int | str | None) - Optional - The User ID associated with the user - **login** (str | None) - Optional - The username of the user - **email** (str | None) - Optional - The email address of the user ### Response #### Success Response (200) - **video_count** (int) - The number of videos uploaded by the user in integer format #### Response Example { "video_count": 50 } ### Errors - `khoros.errors.exceptions.GETRequestError` ``` -------------------------------- ### GET /v1/request Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Performs a Community API v1 GET request. ```APIDOC ## GET /v1/request ### Description This method makes a Community API v1 GET request. ### Method GET ### Parameters #### Request Body - **endpoint** (str) - Required - The API endpoint to be queried - **query_params** (dict) - Optional - The field and associated values to be leveraged in the query string - **return_json** (bool) - Optional - Determines if the response should be returned in JSON format - **proxy_user_object** (class[khoros.objects.users.ImpersonatedUser]) - Optional - Object to perform the API request on behalf of a secondary user. ``` -------------------------------- ### Creating a New Board with Description Source: https://khoros.readthedocs.io/en/latest/boards.html Demonstrates how to create a new board and include an SEO-friendly description. ```APIDOC ## POST /api/boards ### Description Creates a new board within the Khoros community environment, optionally including a description for SEO purposes. ### Method POST ### Endpoint /api/boards ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The unique identifier for the board. - **title** (string) - Required - The display name of the board. - **board_type** (string) - Required - The type of board (e.g., 'blog', 'forum', 'tkb'). - **description** (string) - Optional - A description for the board, recommended for SEO. ### Request Example ```json { "name": "upcoming-events", "title": "Upcoming Events", "board_type": "blog", "description": "Get the details on our upcoming events and product releases." } ``` ### Response #### Success Response (200) - **success** (boolean) - True if the board was created successfully. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Instantiate the Khoros Object Source: https://khoros.readthedocs.io/en/latest/community-api-calls.html Initialize the Khoros client using a configuration file. ```python >>> from khoros import Khoros >>> khoros = Khoros(helper='helper.yml') ``` -------------------------------- ### Get Roles Count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of roles applied to a specific user. ```APIDOC ## GET /api/users/roles/count ### Description This method gets the count of roles applied to the user. ### Method GET ### Endpoint /api/users/roles/count ### Query Parameters - **user_id** (int | str | None) - Optional - The User ID associated with the user - **login** (str | None) - Optional - The username of the user - **email** (str | None) - Optional - The email address of the user ### Request Body - **user_settings** (dict | None) - Optional - A dictionary containing all relevant user settings supplied in the parent function ### Returns The number of roles applied to the user in integer format. ### Raises `khoros.errors.exceptions.GETRequestError` ``` -------------------------------- ### Get Replies Count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of replies posted by a specific user. ```APIDOC ## GET /api/users/replies/count ### Description This method gets the count of replies posted by the user. ### Method GET ### Endpoint /api/users/replies/count ### Query Parameters - **user_id** (int | str | None) - Optional - The User ID associated with the user - **login** (str | None) - Optional - The username of the user - **email** (str | None) - Optional - The email address of the user ### Request Body - **user_settings** (dict | None) - Optional - A dictionary containing all relevant user settings supplied in the parent function ### Returns The number of replies posted by the user in integer format. ### Raises `khoros.errors.exceptions.GETRequestError` ``` -------------------------------- ### Initialize Khoros Library Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Import the Khoros class and instantiate the core object with community URL and helper file path. ```python from khoros import Khoros ``` ```python khoros = Khoros(community_url='https://community.example.com', helper='path/to/helper_file.yml') ``` -------------------------------- ### GET /users/following-count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of community members the user has added as a friend. ```APIDOC ## GET /users/following-count ### Description This method gets the count of community members the user has added as a friend in the community. ### Method GET ### Parameters #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int, str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (int) - The number of community members the user has added as a friend ``` -------------------------------- ### Import and Use Helper Module Source: https://khoros.readthedocs.io/en/latest/supporting-modules.html Import the helper module and retrieve settings from a configuration file. ```python from khoros.utils import helper ``` ```python helper_settings = helper.get_settings('/tmp/helper.yml', 'yaml') ``` -------------------------------- ### Initialize Logger Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/objects/albums.html Sets up the logging utility for the current module. ```python logger = log_utils.initialize_logging(__name__) ``` -------------------------------- ### GET /users/followers-count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of community members who have added the user as a friend. ```APIDOC ## GET /users/followers-count ### Description This method gets the count of community members who have added the user as a friend in the community. ### Method GET ### Parameters #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int, str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (int) - The number of community members who have added the user as a friend ``` -------------------------------- ### Define a helper configuration file Source: https://khoros.readthedocs.io/en/latest/introduction.html Example structure for a YAML configuration file used to manage connection settings. ```yaml # Helper configuration file for the khoros package # Define how to obtain the connection information connection: community_url: https://community.example.com/ tenant_id: example12345 # Define the default authentication type to use default_auth_type: session_auth # Define the OAuth 2.0 credentials oauth2: client_id: FLFeNYob7XXXXXXXXXXXXXXXXXXXXZcWQEQHR5T6bo= client_secret: 1n0AIXXXXXXXXXXXXXXXXXXXX1udOtNaYnfJCeOszYw= redirect_url: http://redirect.community.example.com/getAccessToken # Define the session key authorization information session_auth: username: serviceaccount password: Ch@ng3ME! # Bulk Data API connection information bulk_data: community_id: example.prod client_id: ay0CXXXXXXXXXX/XXXX+XXXXXXXXXXXXX/XXXXX4KhQ= token: 2f25XXXXXXXXXXXXXXXXXXXXXXXXXa10dec04068 europe: no # Define the preferred format for API responses prefer_json: yes # List the enabled discussion styles in the environment (blog, contest, forum, idea, qanda, tkb) discussion_styles: - blog - contest - forum - idea - qanda - tkb ``` -------------------------------- ### Get Videos Count Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Gets the count of videos uploaded by a specific user. ```APIDOC ## GET /api/users/{user_id}/videos/count ### Description This function gets the count of videos uploaded by the user. ### Method GET ### Endpoint /api/users/{user_id}/videos/count ### Parameters #### Path Parameters - **user_id** (integer or string) - Required - The User ID associated with the user #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings supplied in the parent function - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **video_count** (integer) - The number of videos uploaded by the user in integer format #### Response Example { "video_count": 75 } ``` -------------------------------- ### Initialize Khoros SDK with Logging Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Initializes the Khoros SDK, setting the logging level based on the provided string. Supports DEBUG, INFO, WARNING, ERROR, and CRITICAL levels. ```python self.version = version.get_full_version() # Establish logging self.logging = logging if logging_level: logging_levels = { 'DEBUG': logging.DEBUG, 'INFO': logging.INFO, 'WARNING': logging.WARNING, 'ERROR': logging.ERROR, 'CRITICAL': logging.CRITICAL, } if logging_level.upper() in logging_levels: self.logging.basicConfig(level=logging_levels.get(logging_level)) logger.info(f'The {logging_level.upper()} logging level has been enabled.') ``` -------------------------------- ### GET khoros.objects.users.get_following_count Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Gets the count of community members the user has added as a friend. ```APIDOC ## GET khoros.objects.users.get_following_count ### Description This function gets the count of community members the user has added as a friend in the community. ### Parameters #### Path Parameters - **khoros_object** (class) - Required - The core khoros.Khoros object - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response - **Returns** (int) - The number of community members the user has added as a friend ``` -------------------------------- ### GET khoros.objects.users.get_followers_count Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Gets the count of community members who have added the user as a friend. ```APIDOC ## GET khoros.objects.users.get_followers_count ### Description This function gets the count of community members who have added the user as a friend in the community. ### Parameters #### Path Parameters - **khoros_object** (class) - Required - The core khoros.Khoros object - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response - **Returns** (int) - The number of community members who have added the user as a friend ``` -------------------------------- ### Initialize Khoros with a Helper File Source: https://khoros.readthedocs.io/en/latest/_sources/introduction.rst.txt Use a YAML helper file to initialize the Khoros object instance. ```yaml discussion_styles: - blog - contest - forum - idea - qanda - tkb ``` ```python HELPER_FILE = "/path/to/helper.yml" khoros = Khoros(helper=HELPER_FILE) ``` -------------------------------- ### Create Boards and Return IDs (Python) Source: https://khoros.readthedocs.io/en/latest/_sources/boards.rst.txt Illustrates how to create multiple boards and return their respective IDs by setting `return_id=True`. This is useful when you need to reference the created boards by their unique identifiers. ```python >>> forums_to_create = [('first-board', 'My First Board'), ('second-board', 'My Second Board')] >>> for forum in forums_to_create: ... board_id, board_title = forum ... forum_id = khoros.boards.create(board_id, board_title, 'forum', return_id=True) ... print("Forum Created:", forum_id) ... ``` ```python 'Forum Created: first-board' 'Forum Created: second-board' ``` -------------------------------- ### GET /get Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Performs a GET request leveraging Khoros authorization headers. ```APIDOC ## GET /get ### Description Performs a simple GET request that leverages the Khoros authorization headers. ### Method GET ### Parameters #### Query Parameters - **query_url** (str) - Required - The relative or fully-qualified URL for the API call. - **relative_url** (bool) - Optional - Determines if the URL should be appended to the community domain (default: True). - **return_json** (bool) - Optional - Determines if the API response should be converted into JSON format (default: True). - **headers** (dict) - Optional - Allows the API call headers to be manually defined. - **proxy_user_object** (object) - Optional - ImpersonatedUser object to perform the request on behalf of another user. ``` -------------------------------- ### GET /users/{user_id}/videos/count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of videos uploaded by a specific user. ```APIDOC ## GET /users/{user_id}/videos/count ### Description Gets the count of videos uploaded by the user. ### Method GET ### Endpoint /users/{user_id}/videos/count ### Parameters #### Path Parameters - **user_id** (int | str | None) - Required - The User ID associated with the user #### Query Parameters - **user_settings** (dict | None) - Optional - A dictionary containing all relevant user settings supplied in the parent function - **login** (str | None) - Optional - The username of the user - **email** (str | None) - Optional - The email address of the user ### Response #### Success Response (200) - **video_count** (int) - The number of videos uploaded by the user in integer format #### Response Example { "video_count": 50 } ### Errors - `khoros.errors.exceptions.GETRequestError` ``` -------------------------------- ### GET get_solutions_authored_count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of messages created by the user that are marked as accepted solutions. ```APIDOC ## GET get_solutions_authored_count ### Description This method gets the count of messages created by the user that are marked as accepted solutions. ### Parameters #### Query Parameters - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int/str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (int) - The number of messages marked as accepted solutions ``` -------------------------------- ### Initialize Khoros Modules and Object Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/utils/tests/test_board_creation.html Imports necessary board and exception modules and initializes the core Khoros object. ```python # Import modules and initialize the core object boards, exceptions = resources.import_modules('khoros.structures.boards', 'khoros.errors.exceptions') khoros = resources.initialize_khoros_object() ``` -------------------------------- ### Check npm Installation Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/studio/base.html Determines if npm is installed by checking for a valid version string. ```python def npm_installed(): """This function checks whether npm is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether npm is installed """ npm_version = get_npm_version() return True if npm_version else False ``` -------------------------------- ### Studio Module Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Utility methods for checking environment versions and installation status for Khoros Studio. ```APIDOC ## Studio Module (khoros.studio) ### Description Checks the status and versions of installed dependencies for the Khoros Studio environment. ### Methods - get_node_version() - get_npm_version() - get_sdk_version() - node_installed() - npm_installed() - sdk_installed() ``` -------------------------------- ### Initialize KhorosError with Custom Message Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/errors/exceptions.html Illustrates how to initialize the base KhorosError with a default or custom message, potentially including specific parameters. ```python args = (init_msg,) elif 'param' in kwargs: args = (param_msg.replace('PARAMETER_NAME', kwargs['param']),) else: args = (default_msg,) super().__init__(*args) ``` -------------------------------- ### Check Node.js Installation Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/studio/base.html Determines if Node.js is installed by checking for a valid version string. ```python def node_installed(): """This function checks whether Node.js is installed. .. versionadded:: 2.5.1 :returns: Boolean value indicating whether Node.js is installed """ node_version = get_node_version() return True if node_version else False ``` -------------------------------- ### Initialize Logging Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/utils/log_utils.html Configures and returns a logger instance using default or custom settings. ```python def initialize_logging(logger_name=None, log_level=None, formatter=None, debug=None, no_output=None, file_output=None, file_log_level=None, log_file=None, overwrite_log_files=None, console_output=None, console_log_level=None, syslog_output=None, syslog_log_level=None, syslog_address=None, syslog_port=None): """This function initializes logging for the khoros library.""" # TODO: Complete the docstring above with parameters logger_name, log_levels, formatter = _apply_defaults(logger_name, formatter, debug, log_level, file_log_level, console_log_level, syslog_log_level) log_level, file_log_level, console_log_level, syslog_log_level = _get_log_levels_from_dict(log_levels) logger = logging.getLogger(logger_name) logger = _set_logging_level(logger, log_level) logger = _add_handlers(logger, formatter, no_output, file_output, file_log_level, log_file, overwrite_log_files, console_output, console_log_level, syslog_output, syslog_log_level, syslog_address, syslog_port) return logger ``` -------------------------------- ### GET / (Generic Request) Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Performs a simple GET request leveraging Khoros authorization headers. ```APIDOC ## GET / (Generic Request) ### Description Performs a simple GET request that leverages the Khoros authorization headers. ### Method GET ### Parameters #### Query Parameters - **query_url** (str) - Required - The relative or fully-qualified URL for the API call - **relative_url** (bool) - Optional - Determines if the URL should be appended to the community domain (default: True) - **return_json** (bool) - Optional - Determines if the API response should be converted into JSON format (default: True) - **headers** (dict) - Optional - Allows the API call headers to be manually defined - **proxy_user_object** (class) - Optional - Instantiated khoros.objects.users.ImpersonatedUser object to perform the request on behalf of another user ### Response - **response** (any) - The API response from the GET request ``` -------------------------------- ### Internal Instantiation Methods Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/utils/tests/resources.html Methods for initializing the Khoros core object for different environments. ```APIDOC ## instantiate_with_local_helper(production) ### Description Instantiates a Khoros object using a local helper file for unit testing. ### Parameters #### Request Body - **production** (bool, None) - Optional - Defines whether the helper file is associated with a Production environment ### Response - **returns** (khoros.core.Khoros) - The instantiated Khoros object - **raises** (FileNotFoundError) - Raised if the local helper file is not found --- ## instantiate_with_secrets_helper() ### Description Instantiates a Khoros object using the unencrypted helper file intended for GitHub Workflows. ### Response - **returns** (khoros.core.Khoros) - The instantiated Khoros object - **raises** (FileNotFoundError) - Raised if the unencrypted GitHub Workflows helper file is not found --- ## instantiate_with_placeholder() ### Description Instantiates a Khoros object with placeholder data. ### Response - **returns** (khoros.core.Khoros) - The instantiated Khoros object ``` -------------------------------- ### Get Solutions Authored Count Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Gets the count of messages authored by the user that are marked as accepted solutions. ```APIDOC ## GET /api/users/solutions/authored/count ### Description This method gets the count of messages created by the user that are marked as accepted solutions. ### Method GET ### Endpoint /api/users/solutions/authored/count ### Query Parameters - **user_id** (int | str | None) - Optional - The User ID associated with the user - **login** (str | None) - Optional - The username of the user - **email** (str | None) - Optional - The email address of the user ### Request Body - **user_settings** (dict | None) - Optional - A dictionary containing all relevant user settings supplied in the parent function ### Returns The number of messages created by the user that are marked as accepted solutions in integer format. ### Raises `khoros.errors.exceptions.GETRequestError` ``` -------------------------------- ### Create Board and Return API URL (Python) Source: https://khoros.readthedocs.io/en/latest/_sources/boards.rst.txt Shows how to get the API URL (URI) of a new board by setting `return_api_url=True`. This is useful for subsequent API interactions with the created board. ```python >>> khoros.boards.create('python-lovers', 'The Python Lovers Blog', \ ... 'blog', return_api_url=True) ... ``` ```python '/boards/python-lovers' ``` -------------------------------- ### Get User Public Images Uploaded Count Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Gets the count of public images uploaded by the user. ```APIDOC ## GET /api/users/public_images_uploaded_count ### Description This function gets the count of public images uploaded by the user. ### Method GET ### Endpoint /api/users/public_images_uploaded_count ### Parameters #### Query Parameters - **khoros_object** (class) - Required - The core `khoros.Khoros` object - **user_settings** (dict) - Optional - A dictionary containing all relevant user settings - **user_id** (int | str) - Optional - The User ID associated with the user - **login** (str) - Optional - The username of the user - **email** (str) - Optional - The email address of the user ### Response #### Success Response (200) - **count** (integer) - The number of public images uploaded by the user #### Response Example ```json { "count": 25 } ``` ``` -------------------------------- ### Create a Group Hub Source: https://khoros.readthedocs.io/en/latest/primary-modules.html Example usage of the create function to initialize a new group hub and return its URL. ```python group_hub_url = grouphubs.create(khoros_object, gh_id, gh_title, disc_styles, return_url=True) ``` -------------------------------- ### GET /v2/{endpoint} Source: https://khoros.readthedocs.io/en/latest/_modules/khoros/core.html Performs a Community API v2 GET request using Khoros authorization headers. ```APIDOC ## GET /v2/{endpoint} ### Description This method performs a Community API v2 GET request that leverages the Khoros authorization headers. ### Parameters #### Path Parameters - **endpoint** (str) - Required - The API v2 endpoint against which to query #### Query Parameters - **return_json** (bool) - Optional - Determines if the API response should be converted into JSON format (True by default) - **headers** (dict) - Optional - Allows the API call headers to be manually defined - **proxy_user_object** (class) - Optional - ImpersonatedUser object to perform the API request on behalf of a secondary user. ``` -------------------------------- ### Instantiate Khoros Object with Helper Source: https://khoros.readthedocs.io/en/latest/bulk-data-api.html Instantiates the Khoros object using a helper YAML file for configuration. Ensure the helper file is correctly set up. ```python from khoros import Khoros khoros = Khoros(helper='helper.yml') ``` -------------------------------- ### Studio Environment Methods Source: https://khoros.readthedocs.io/en/latest/core-object-methods.html Methods to identify and verify installed versions of Node.js, npm, and the Lithium SDK. ```APIDOC ## Studio Environment Methods ### Description Static methods to check the installation status and versioning of development tools. ### Methods - **get_node_version()**: Returns the installed Node.js version string or None. - **get_npm_version()**: Returns the installed npm version string or None. - **get_sdk_version()**: Returns the installed Lithium SDK version string or None. - **node_installed()**: Returns a boolean indicating if Node.js is installed. - **npm_installed()**: Returns a boolean indicating if npm is installed. - **sdk_installed()**: Returns a boolean indicating if the Lithium SDK is installed. ``` -------------------------------- ### Generic GET Request Source: https://khoros.readthedocs.io/en/latest/community-api-calls.html Perform generic GET requests to custom endpoints while automatically including authorization headers. ```APIDOC ## Method: khoros.core.Khoros.get() ### Description Executes a generic GET request to a specified URI. Supports both absolute and relative URIs. ### Parameters #### Path Parameters - **uri** (str) - Required - The endpoint URI. #### Query Parameters - **relative_url** (bool) - Optional - Set to False to use an absolute URI. - **return_json** (bool) - Optional - Set to False to return a requests.models.Response object. ### Request Example ```python khoros.get('/plugins/custom/example/example/hello_world') ``` ### Response #### Success Response (200) - **response** (dict/str) - The response body from the custom endpoint. ``` -------------------------------- ### Initialize Khoros Object with Options Dictionary Source: https://khoros.readthedocs.io/en/latest/_sources/introduction.rst.txt Initialize a Khoros object instance by passing a dictionary of settings, including community URL and authentication details. ```python my_settings = { 'community_url': 'https://community.example.com', 'community_name': 'mycommunity', 'auth_type': 'session_auth', 'session_auth': { 'username': USERNAME, 'password': PASSWD } } ```