# coding: utf-8

"""
    Knetik Platform API Documentation latest 

    This is the spec for the Knetik API.  Use this in conjunction with the documentation found at https://knetikcloud.com.

    OpenAPI spec version: latest 
    Contact: support@knetik.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


class ActivitiesApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def add_user(self, activity_occurrence_id, **kwargs):
        """
        Add a user to an occurrence
        If called with no body, defaults to the user making the call.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.add_user(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param bool test: if true, indicates that the user should NOT be added. This can be used to test for eligibility
        :param bool bypass_restrictions: if true, indicates that restrictions such as max player count should be ignored. Can only be used with ACTIVITIES_ADMIN
        :param IntWrapper user_id: The id of the user, or null for 'caller'
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.add_user_with_http_info(activity_occurrence_id, **kwargs)
        else:
            (data) = self.add_user_with_http_info(activity_occurrence_id, **kwargs)
            return data

    def add_user_with_http_info(self, activity_occurrence_id, **kwargs):
        """
        Add a user to an occurrence
        If called with no body, defaults to the user making the call.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.add_user_with_http_info(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param bool test: if true, indicates that the user should NOT be added. This can be used to test for eligibility
        :param bool bypass_restrictions: if true, indicates that restrictions such as max player count should be ignored. Can only be used with ACTIVITIES_ADMIN
        :param IntWrapper user_id: The id of the user, or null for 'caller'
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'test', 'bypass_restrictions', 'user_id']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method add_user" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `add_user`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']

        query_params = []
        if 'test' in params:
            query_params.append(('test', params['test']))
        if 'bypass_restrictions' in params:
            query_params.append(('bypass_restrictions', params['bypass_restrictions']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'user_id' in params:
            body_params = params['user_id']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/users', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityOccurrenceResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def create_activity(self, **kwargs):
        """
        Create an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity(async=True)
        >>> result = thread.get()

        :param async bool
        :param ActivityResource activity_resource: The activity resource object
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.create_activity_with_http_info(**kwargs)
        else:
            (data) = self.create_activity_with_http_info(**kwargs)
            return data

    def create_activity_with_http_info(self, **kwargs):
        """
        Create an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param ActivityResource activity_resource: The activity resource object
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_resource']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_activity" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_resource' in params:
            body_params = params['activity_resource']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def create_activity_occurrence(self, **kwargs):
        """
        Create a new activity occurrence. Ex: start a game
        Has to enforce extra rules if not used as an admin. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity_occurrence(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool test: if true, indicates that the occurrence should NOT be created. This can be used to test for eligibility and valid settings
        :param CreateActivityOccurrenceRequest activity_occurrence_resource: The activity occurrence object
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.create_activity_occurrence_with_http_info(**kwargs)
        else:
            (data) = self.create_activity_occurrence_with_http_info(**kwargs)
            return data

    def create_activity_occurrence_with_http_info(self, **kwargs):
        """
        Create a new activity occurrence. Ex: start a game
        Has to enforce extra rules if not used as an admin. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity_occurrence_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool test: if true, indicates that the occurrence should NOT be created. This can be used to test for eligibility and valid settings
        :param CreateActivityOccurrenceRequest activity_occurrence_resource: The activity occurrence object
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['test', 'activity_occurrence_resource']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_activity_occurrence" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'test' in params:
            query_params.append(('test', params['test']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_occurrence_resource' in params:
            body_params = params['activity_occurrence_resource']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityOccurrenceResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def create_activity_template(self, **kwargs):
        """
        Create a activity template
        Activity Templates define a type of activity and the properties they have. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity_template(async=True)
        >>> result = thread.get()

        :param async bool
        :param TemplateResource activity_template_resource: The activity template resource object
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.create_activity_template_with_http_info(**kwargs)
        else:
            (data) = self.create_activity_template_with_http_info(**kwargs)
            return data

    def create_activity_template_with_http_info(self, **kwargs):
        """
        Create a activity template
        Activity Templates define a type of activity and the properties they have. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_activity_template_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param TemplateResource activity_template_resource: The activity template resource object
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_template_resource']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_activity_template" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_template_resource' in params:
            body_params = params['activity_template_resource']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/templates', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='TemplateResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def delete_activity(self, id, **kwargs):
        """
        Delete an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_activity(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.delete_activity_with_http_info(id, **kwargs)
        else:
            (data) = self.delete_activity_with_http_info(id, **kwargs)
            return data

    def delete_activity_with_http_info(self, id, **kwargs):
        """
        Delete an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_activity_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_activity" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `delete_activity`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/{id}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def delete_activity_template(self, id, **kwargs):
        """
        Delete a activity template
        If cascade = 'detach', it will force delete the template even if it's attached to other objects. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_activity_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param str cascade: The value needed to delete used templates
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.delete_activity_template_with_http_info(id, **kwargs)
        else:
            (data) = self.delete_activity_template_with_http_info(id, **kwargs)
            return data

    def delete_activity_template_with_http_info(self, id, **kwargs):
        """
        Delete a activity template
        If cascade = 'detach', it will force delete the template even if it's attached to other objects. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_activity_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param str cascade: The value needed to delete used templates
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'cascade']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_activity_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `delete_activity_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []
        if 'cascade' in params:
            query_params.append(('cascade', params['cascade']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/templates/{id}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def get_activities(self, **kwargs):
        """
        List activity definitions
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activities(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool filter_template: Filter for activities that are templates, or specifically not if false
        :param str filter_name: Filter for activities that have a name starting with specified string
        :param str filter_id: Filter for activities with an id in the given comma separated list of ids
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceBareActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_activities_with_http_info(**kwargs)
        else:
            (data) = self.get_activities_with_http_info(**kwargs)
            return data

    def get_activities_with_http_info(self, **kwargs):
        """
        List activity definitions
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activities_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool filter_template: Filter for activities that are templates, or specifically not if false
        :param str filter_name: Filter for activities that have a name starting with specified string
        :param str filter_id: Filter for activities with an id in the given comma separated list of ids
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceBareActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['filter_template', 'filter_name', 'filter_id', 'size', 'page', 'order']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_activities" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'filter_template' in params:
            query_params.append(('filter_template', params['filter_template']))
        if 'filter_name' in params:
            query_params.append(('filter_name', params['filter_name']))
        if 'filter_id' in params:
            query_params.append(('filter_id', params['filter_id']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'order' in params:
            query_params.append(('order', params['order']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceBareActivityResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def get_activity(self, id, **kwargs):
        """
        Get a single activity
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_activity_with_http_info(id, **kwargs)
        else:
            (data) = self.get_activity_with_http_info(id, **kwargs)
            return data

    def get_activity_with_http_info(self, id, **kwargs):
        """
        Get a single activity
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_activity" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_activity`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/{id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def get_activity_occurrence_details(self, activity_occurrence_id, **kwargs):
        """
        Load a single activity occurrence details
        <b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_occurrence_details(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_activity_occurrence_details_with_http_info(activity_occurrence_id, **kwargs)
        else:
            (data) = self.get_activity_occurrence_details_with_http_info(activity_occurrence_id, **kwargs)
            return data

    def get_activity_occurrence_details_with_http_info(self, activity_occurrence_id, **kwargs):
        """
        Load a single activity occurrence details
        <b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_occurrence_details_with_http_info(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_activity_occurrence_details" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `get_activity_occurrence_details`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityOccurrenceResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def get_activity_template(self, id, **kwargs):
        """
        Get a single activity template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_activity_template_with_http_info(id, **kwargs)
        else:
            (data) = self.get_activity_template_with_http_info(id, **kwargs)
            return data

    def get_activity_template_with_http_info(self, id, **kwargs):
        """
        Get a single activity template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_activity_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_activity_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/templates/{id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='TemplateResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def get_activity_templates(self, **kwargs):
        """
        List and search activity templates
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_templates(async=True)
        >>> result = thread.get()

        :param async bool
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_activity_templates_with_http_info(**kwargs)
        else:
            (data) = self.get_activity_templates_with_http_info(**kwargs)
            return data

    def get_activity_templates_with_http_info(self, **kwargs):
        """
        List and search activity templates
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_activity_templates_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['size', 'page', 'order']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_activity_templates" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'order' in params:
            query_params.append(('order', params['order']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/templates', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceTemplateResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def list_activity_occurrences(self, **kwargs):
        """
        List activity occurrences
        <b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.list_activity_occurrences(async=True)
        >>> result = thread.get()

        :param async bool
        :param str filter_activity: Filter for occurrences of the given activity ID
        :param str filter_status: Filter for occurrences in the given status
        :param int filter_event: Filter for occurrences played during the given event
        :param int filter_challenge: Filter for occurrences played within the given challenge
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.list_activity_occurrences_with_http_info(**kwargs)
        else:
            (data) = self.list_activity_occurrences_with_http_info(**kwargs)
            return data

    def list_activity_occurrences_with_http_info(self, **kwargs):
        """
        List activity occurrences
        <b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.list_activity_occurrences_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param str filter_activity: Filter for occurrences of the given activity ID
        :param str filter_status: Filter for occurrences in the given status
        :param int filter_event: Filter for occurrences played during the given event
        :param int filter_challenge: Filter for occurrences played within the given challenge
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['filter_activity', 'filter_status', 'filter_event', 'filter_challenge', 'size', 'page', 'order']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_activity_occurrences" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'filter_activity' in params:
            query_params.append(('filter_activity', params['filter_activity']))
        if 'filter_status' in params:
            query_params.append(('filter_status', params['filter_status']))
        if 'filter_event' in params:
            query_params.append(('filter_event', params['filter_event']))
        if 'filter_challenge' in params:
            query_params.append(('filter_challenge', params['filter_challenge']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'order' in params:
            query_params.append(('order', params['order']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceActivityOccurrenceResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def remove_user(self, activity_occurrence_id, user_id, **kwargs):
        """
        Remove a user from an occurrence
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.remove_user(activity_occurrence_id, user_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param str user_id: The id of the user, or 'me' (required)
        :param bool ban: if true, indicates that the user should not be allowed to re-join. Can only be set by host or admin
        :param bool bypass_restrictions: if true, indicates that restrictions such as current status should be ignored. Can only be used with ACTIVITIES_ADMIN
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.remove_user_with_http_info(activity_occurrence_id, user_id, **kwargs)
        else:
            (data) = self.remove_user_with_http_info(activity_occurrence_id, user_id, **kwargs)
            return data

    def remove_user_with_http_info(self, activity_occurrence_id, user_id, **kwargs):
        """
        Remove a user from an occurrence
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.remove_user_with_http_info(activity_occurrence_id, user_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param str user_id: The id of the user, or 'me' (required)
        :param bool ban: if true, indicates that the user should not be allowed to re-join. Can only be set by host or admin
        :param bool bypass_restrictions: if true, indicates that restrictions such as current status should be ignored. Can only be used with ACTIVITIES_ADMIN
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'user_id', 'ban', 'bypass_restrictions']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method remove_user" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `remove_user`")
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `remove_user`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']

        query_params = []
        if 'ban' in params:
            query_params.append(('ban', params['ban']))
        if 'bypass_restrictions' in params:
            query_params.append(('bypass_restrictions', params['bypass_restrictions']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/users/{user_id}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def set_activity_occurrence_results(self, activity_occurrence_id, **kwargs):
        """
        Sets the status of an activity occurrence to FINISHED and logs metrics
        In addition to user permissions requirements there is security based on the core_settings.results_trust setting. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_activity_occurrence_results(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceResultsResource activity_occurrence_results: The activity occurrence object
        :return: ActivityOccurrenceResults
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.set_activity_occurrence_results_with_http_info(activity_occurrence_id, **kwargs)
        else:
            (data) = self.set_activity_occurrence_results_with_http_info(activity_occurrence_id, **kwargs)
            return data

    def set_activity_occurrence_results_with_http_info(self, activity_occurrence_id, **kwargs):
        """
        Sets the status of an activity occurrence to FINISHED and logs metrics
        In addition to user permissions requirements there is security based on the core_settings.results_trust setting. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_activity_occurrence_results_with_http_info(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceResultsResource activity_occurrence_results: The activity occurrence object
        :return: ActivityOccurrenceResults
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'activity_occurrence_results']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method set_activity_occurrence_results" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `set_activity_occurrence_results`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_occurrence_results' in params:
            body_params = params['activity_occurrence_results']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/results', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityOccurrenceResults',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def set_activity_occurrence_settings(self, activity_occurrence_id, **kwargs):
        """
        Sets the settings of an activity occurrence
        <b>Permissions Needed:</b> ACTIVITIES_USER and host or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_activity_occurrence_settings(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceSettingsResource settings: The new settings
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.set_activity_occurrence_settings_with_http_info(activity_occurrence_id, **kwargs)
        else:
            (data) = self.set_activity_occurrence_settings_with_http_info(activity_occurrence_id, **kwargs)
            return data

    def set_activity_occurrence_settings_with_http_info(self, activity_occurrence_id, **kwargs):
        """
        Sets the settings of an activity occurrence
        <b>Permissions Needed:</b> ACTIVITIES_USER and host or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_activity_occurrence_settings_with_http_info(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceSettingsResource settings: The new settings
        :return: ActivityOccurrenceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'settings']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method set_activity_occurrence_settings" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `set_activity_occurrence_settings`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'settings' in params:
            body_params = params['settings']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/settings', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityOccurrenceResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def set_user_status(self, activity_occurrence_id, user_id, **kwargs):
        """
        Set a user's status within an occurrence
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_user_status(activity_occurrence_id, user_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param str user_id: The id of the user (required)
        :param ActivityUserStatusWrapper status: The new status
        :return: ActivityUserResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.set_user_status_with_http_info(activity_occurrence_id, user_id, **kwargs)
        else:
            (data) = self.set_user_status_with_http_info(activity_occurrence_id, user_id, **kwargs)
            return data

    def set_user_status_with_http_info(self, activity_occurrence_id, user_id, **kwargs):
        """
        Set a user's status within an occurrence
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.set_user_status_with_http_info(activity_occurrence_id, user_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param str user_id: The id of the user (required)
        :param ActivityUserStatusWrapper status: The new status
        :return: ActivityUserResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'user_id', 'status']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method set_user_status" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `set_user_status`")
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `set_user_status`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'status' in params:
            body_params = params['status']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/users/{user_id}/status', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityUserResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def update_activity(self, id, **kwargs):
        """
        Update an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :param ActivityResource activity_resource: The activity resource object
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_activity_with_http_info(id, **kwargs)
        else:
            (data) = self.update_activity_with_http_info(id, **kwargs)
            return data

    def update_activity_with_http_info(self, id, **kwargs):
        """
        Update an activity
        <b>Permissions Needed:</b> ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the activity (required)
        :param ActivityResource activity_resource: The activity resource object
        :return: ActivityResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'activity_resource']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_activity" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_activity`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_resource' in params:
            body_params = params['activity_resource']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/{id}', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ActivityResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def update_activity_occurrence_status(self, activity_occurrence_id, **kwargs):
        """
        Update the status of an activity occurrence
        If setting to 'FINISHED' reward will be run based on current metrics that have been recorded already. Alternatively, see results endpoint to finish and record all metrics at once. Can be called by non-host participants if non_host_status_control is true. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER and host or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity_occurrence_status(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceStatusWrapper activity_occurrence_status: The activity occurrence status object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_activity_occurrence_status_with_http_info(activity_occurrence_id, **kwargs)
        else:
            (data) = self.update_activity_occurrence_status_with_http_info(activity_occurrence_id, **kwargs)
            return data

    def update_activity_occurrence_status_with_http_info(self, activity_occurrence_id, **kwargs):
        """
        Update the status of an activity occurrence
        If setting to 'FINISHED' reward will be run based on current metrics that have been recorded already. Alternatively, see results endpoint to finish and record all metrics at once. Can be called by non-host participants if non_host_status_control is true. <br><br><b>Permissions Needed:</b> ACTIVITIES_USER and host or ACTIVITIES_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity_occurrence_status_with_http_info(activity_occurrence_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int activity_occurrence_id: The id of the activity occurrence (required)
        :param ActivityOccurrenceStatusWrapper activity_occurrence_status: The activity occurrence status object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['activity_occurrence_id', 'activity_occurrence_status']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_activity_occurrence_status" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'activity_occurrence_id' is set
        if ('activity_occurrence_id' not in params) or (params['activity_occurrence_id'] is None):
            raise ValueError("Missing the required parameter `activity_occurrence_id` when calling `update_activity_occurrence_status`")


        collection_formats = {}

        path_params = {}
        if 'activity_occurrence_id' in params:
            path_params['activity_occurrence_id'] = params['activity_occurrence_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_occurrence_status' in params:
            body_params = params['activity_occurrence_status']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activity-occurrences/{activity_occurrence_id}/status', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def update_activity_template(self, id, **kwargs):
        """
        Update an activity template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param TemplateResource activity_template_resource: The activity template resource object
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_activity_template_with_http_info(id, **kwargs)
        else:
            (data) = self.update_activity_template_with_http_info(id, **kwargs)
            return data

    def update_activity_template_with_http_info(self, id, **kwargs):
        """
        Update an activity template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_activity_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param TemplateResource activity_template_resource: The activity template resource object
        :return: TemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'activity_template_resource']
        all_params.append('async')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_activity_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_activity_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'activity_template_resource' in params:
            body_params = params['activity_template_resource']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/activities/templates/{id}', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='TemplateResource',
                                        auth_settings=auth_settings,
                                        async=params.get('async'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)
