CommunitiesClient

class wwt_api_client.communities.CommunitiesClient(parent_client, oauth_client_secret=None, interactive_login_if_needed=False, state_dir=None)[source]

Bases: object

A client for WWT Communities API requests.

Instantiating such a client will make at least one web request, to refresh the Microsoft Live OAuth login token.

In addition, an interactive user login may be necessary. This must be explicitly allowed by the caller to prevent random programs from hanging waiting for user input. If interactive login is successful, the authentication data from such a login are saved in the current user’s state directory (~/.local/state/wwt_api_client/ on Linux machines) for subsequent use.

Methods Summary

create_community([payload])

Create a new community owned by the current user.

delete_community([id])

Delete a community.

get_community_info([id])

Get information about the specified community.

get_latest_community()

Get information about the most recently created WWT Communities.

get_my_profile()

Get the logged-in user's profile information.

get_profile_entities([entity_type, ...])

Get "entities" associated with the logged-in user's profile.

is_user_registered()

Query whether the logged-in Microsoft Live user is registered with the WWT Communities system.

Methods Documentation

create_community(payload=None)[source]

Create a new community owned by the current user.

Parameters:
See the definition of the :class:`CreateCommunityRequest` class.
Returns:
requestan initialized CreateCommunityRequest object

The request.

delete_community(id=None)[source]

Delete a community.

Parameters:
See the definition of the :class:`DeleteCommunityRequest` class.
Returns:
requestan initialized DeleteCommunityRequest object

The request.

get_community_info(id=None)[source]

Get information about the specified community.

Parameters:
See the definition of the :class:`GetCommunityInfoRequest` class.
Returns:
requestan initialized GetCommunityInfoRequest object

The request.

get_latest_community()[source]

Get information about the most recently created WWT Communities.

Returns:
requestan initialized GetLatestCommunityRequest object

The request.

Examples

There are no arguments:

>>> req = comm_client.get_latest_community()
>>> folder = req.send()  # returns wwt_data_formats.folder.Folder
get_my_profile()[source]

Get the logged-in user’s profile information.

Returns:
requestan initialized GetMyProfileRequest object

The request.

Examples

There are no arguments:

>>> req = comm_client.get_my_profile()
>>> json = req.send()  # returns JSON data structure
>>> print(json['ProfileId'])
123456
get_profile_entities(entity_type=EntityType.CONTENT, current_page=1, page_size=99999)[source]

Get “entities” associated with the logged-in user’s profile.

Parameters:
See the definition of the :class:`GetProfileEntitiesRequest` class.
Returns:
requestan initialized GetProfileEntitiesRequest object

The request.

Examples

>>> from wwt_api_client.enums import EntityType
>>> req = comm_client.get_profile_entities(
...     entity_type = EntityType.CONTENT,
...     current_page = 1,  # one-based
...     page_size = 99999,
... )
>>> json = req.send()  # returns json
>>> print(json['entities'][0]['Id'])
82077
is_user_registered()[source]

Query whether the logged-in Microsoft Live user is registered with the WWT Communities system.

Returns:
requestan initialized IsUserRegisteredRequest object

The request.

Examples

There are no arguments:

>>> req = comm_client.is_user_registered()
>>> print(req.send())
True