jiveapi.api module

class jiveapi.api.JiveApi(base_url, username, password)[source]

Bases: object

Low-level client for the Jive API, with methods mapping directly to the Jive API endpoints.

Parameters:
  • base_url (str) – Base URL to the Jive API. This should be the scheme, hostname, and optional port ending with a path of /api/ (i.e. https://sandbox.jiveon.com/api/).
  • username (str) – Jive API username
  • password (str) – Jive API password
_get(path, autopaginate=True)[source]

Execute a GET request against the Jive API, handling pagination.

Parameters:
  • path (str) – path or full URL to GET
  • autopaginate (bool) – If True, automatically paginate multi-page responses and return a list of the combined results. Otherwise, return the unaltered JSON response.
Returns:

deserialized response JSON. Usually dict or list.

_get_content_id_by_html_url(path)[source]

Return contentID from given html/url contentID is unique identifier which is associated with majority type of contents in Jive Api for example you can look here https://developers.jivesoftware.com/api/v3/cloud/rest/DocumentEntity.html :param path: html or full URL to GET :type path: str :return: contentID from given url :rtype: str :variable aux: stored _get response

_post_json(path, data)[source]

Execute a POST request against the Jive API, sending JSON.

Parameters:
  • path (str) – path or full URL to POST to
  • data (dict or list) – Data to POST.
Returns:

deserialized response JSON. Usually dict or list.

Raises:

RequestFailedException

_put_json(path, data)[source]

Execute a PUT request against the Jive API, sending JSON.

Parameters:
  • path (str) – path or full URL to PUT to
  • data (dict or list) – Data to POST.
Returns:

deserialized response JSON. Usually dict or list.

abs_url(path)[source]

Given a relative path under the base URL of the Jive instance, return the absolute URL formed by joining the base_url to the specified path.

Parameters:path (str) – relative path on Jive instance
Returns:absolute URL to path on the Jive instance
Return type:str
api_version()[source]

Get the Jive API version information

Returns:raw API response dict for /version endpoint
Return type:dict
create_content(contents, publish_date=None)[source]

POST to create a new Content object in Jive. This is the low-level direct API call that corresponds to Create content. Please see the more specific wrapper methods if they suit your purposes.

Parameters:
  • contents (dict) – A JSON-serializable Jive content representation, suitable for POSTing to the /contents API endpoint.
  • publish_date (datetime.datetime) – A backdated publish and update date to set on the content. This allows publishing content with backdated publish dates, for migration purposes.
Returns:

API response of Content object

Return type:

dict

Raises:

RequestFailedException, ContentConflictException

get_content(content_id)[source]

Given the content ID of a content object in Jive, return the API (dict) representation of that content object. This is the low-level direct API call that corresponds to Get Content.

This GETs content with the “Silent Directive” that prevents Jive read counts from being incremented. See Silent Directive for Contents Service.

Parameters:content_id (str) – the Jive contentID of the content
Returns:content object representation
Return type:dict
get_content_in_place(place_id)[source]

Given the placeID of a Place in Jive, return a list of all Content in that Place. Note that this list can be extremely long. Each element of the list is a full representation of the Content object, including body, which should (theoretically) be identical to that returned by get_content(). This is the low-level direct API call that corresponds to PlaceService - Get Content.

Note:

  1. The place_id for a Place in Jive can be found by viewing the place in the web UI and appending /api/v3 to the URL. It will be the placeID field of the resulting JSON response.
  2. For some reason, while the web UI shows blog posts in Places, they actually belong to a blog-specific child place and will not be returned in the response. To retrieve blog posts, view the JSON object for the place using the /api/v3 URL and find the ref of the blog resource for it. You will then need to call this method a second time with that placeID.
Parameters:place_id (str) – the Jive placeID of the Place to list Content in
Returns:list of content object representation dicts for content in the place
Return type:list of dict
get_image(image_id)[source]

GET the image specified by image_id as binary content. This method currently can only retrieve the exact original image. This is the low-level direct API call that corresponds to Get Image.

Parameters:image_id (str) – Jive Image ID to get. This can be found in a Content (i.e. Document or Post) object’s contentImages list.
Returns:binary content of Image
Return type:bytes
update_content(content_id, contents, update_date=None)[source]

PUT to update an existing Content object in Jive. This is the low-level direct API call that corresponds to Update content. Please see the more specific wrapper methods if they suit your purposes.

Warning: In current Jive versions, it appears that editing/updating a (blog) Post will change the date-based URL to the post, breaking all existing links to it!

Parameters:
  • content_id (str) – The Jive contentID of the content to update.
  • contents (dict) – A JSON-serializable Jive content representation, suitable for POSTing to the /contents API endpoint.
  • update_date (datetime.datetime) – A backdated update date to set on the content. This allows publishing content with backdated publish dates, for migration purposes.
Returns:

API response of Content object

Return type:

dict

Raises:

RequestFailedException, ContentConflictException

upload_image(img_data, img_filename, content_type)[source]

Upload a new Image resource to be stored on the server as a temporary image, i.e. for embedding in an upcoming Document, Post, etc. Returns Image object and the user-facing URI for the image itself, i.e. https://sandbox.jiveon.com/api/core/v3/images/601174?a=1522503578891 . This is the low-level direct API call that corresponds to Upload New Image.

Note: Python’s requests lacks streaming file support. As such, images sent using this method will be entirely read into memory and then sent. This may not work very well for extremely large images.

Warning: As far as I can tell, the user-visible URI to an image can only be retrieved when the image is uploaded. There does not seem to be a way to get it from the API for an existing image.

Parameters:
  • img_data (bytes) – The binary image data.
  • img_filename (str) – The filename for the image. This is purely for display purposes.
  • content_type (str) – The MIME Content Type for the image data.
Returns:

2-tuple of (string user-facing URI to the image i.e. for use in HTML, dict Image object representation)

Return type:

tuple

user(id_number='@me')[source]

Return dict of information about the specified user.

Parameters:id_number (str) – User ID number. Defaults to @me, the current user
Returns:user information
Return type:dict
jiveapi.api.TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.000%z'

API url param timestamp format, like ‘2012-01-31T22:46:12.044+0000’ note that sub-second time is ignored and set to zero.