CreateCommunityRequest

class wwt_api_client.communities.CreateCommunityRequest(communities_client)[source]

Bases: wwt_api_client.communities.CommunitiesAPIRequest

Create a new community.

The response gives the ID of the new community.

Attributes
payload

Methods

invalidity_reason(self)

Check whether the parameters of this request are valid.

make_request(self)

Generate a requests.Request from the current parameters.

send(self[, raw_response])

Issue the request and return its result.

to_text(self)

Issue the request and return its results as text.

to_xml(self)

Issue the request and return its results as parsed XML.

Attributes Summary

payload

The request payload is JSON resembling.

Methods Summary

invalidity_reason(self)

Check whether the parameters of this request are valid.

make_request(self)

Generate a requests.Request from the current parameters.

Attributes Documentation

payload = None

The request payload is JSON resembling:

{
  "communityJson": {
    "CategoryID": 20,
    "ParentID": "610131",
    "AccessTypeID": 2,
    "IsOffensive":false,
    "IsLink": false,
    "CommunityType": "Community",
    "Name": "Community name",
    "Description": "Community description",
    "Tags": "tag1,tag2"
  }
}

(It doesn’t feel worthwhile to implement this payload as a fully-fledged data structure at the moment.)

Methods Documentation

invalidity_reason(self)[source]

Check whether the parameters of this request are valid.

Returns
reasonstring or None

If None, indicates that this request is valid. Otherwise, the returned string explains what about the request’ parameters is invalid.

Examples

You can manually check if a request is correctly set up:

>>> from wwt_api_client import Client
>>> req = Client().show_image('http://example.com/space.jpg', 'My Image')
>>> assert req.invalidity_reason() is None
make_request(self)[source]

Generate a requests.Request from the current parameters.

This method returns a requests.Request object ready for sending to the API server.

Returns
requestrequests.Request object

The HTTP request.

Examples

Get the URL that will be accessed for a request:

>>> from six.moves.urllib.parse import urlparse
>>> from wwt_api_client import Client
>>> req = Client().show_image('http://example.com/space.jpg', 'My Image')
>>> parsed_url = urlparse(req.make_request().prepare().url)
>>> print(parsed_url.path)
/WWTWeb/ShowImage.aspx