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: -
_get
(path, autopaginate=True)[source]¶ Execute a GET request against the Jive API, handling pagination.
Parameters: 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
orlist
) – Data to POST.
Returns: deserialized response JSON. Usually dict or list.
Raises:
-
_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
orlist
) – 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 instanceReturn type: str
-
api_version
()[source]¶ Get the Jive API version information
Returns: raw API response dict for /version
endpointReturn 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: Raises: - contents (dict) – A JSON-serializable Jive content representation,
suitable for POSTing to the
-
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:
- 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 theplaceID
field of the resulting JSON response. - 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 theref
of theblog
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
ofdict
- The
-
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: Raises:
-
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: Returns: 2-tuple of (string user-facing URI to the image i.e. for use in HTML, dict Image object representation)
Return type:
-
-
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.