def apikey(self): """ :returns: connio.rest.api.v3.account.apikey.ApiKeyInstance :rtype: connio.rest.api.v3.account.apikey.ApiKeyInstance """ if self._apikey is None: self._apikey = ApiKeyContext( self._version, account_id=self._solution['account_id'], owner_type='users', owner_id=self._solution['id'], ) return self._apikey.fetch()
class SysUserContext(InstanceContext): """ """ def __init__(self, version, account_id, id): """ Initialize the SysUserContext :param Version version: Version that contains the resource :param sid: Fetch by unique User id :returns: connio.rest.api.v3.sysuser.SysUserContext :rtype: connio.rest.api.v3.sysuser.SysUserContext """ super(SysUserContext, self).__init__(version) # Path Solution self._solution = {'account_id': account_id, 'id': id} self._uri = '/users/{id}'.format(**self._solution) self._apikey = None @property def apikey(self): """ :returns: connio.rest.api.v3.account.apikey.ApiKeyInstance :rtype: connio.rest.api.v3.account.apikey.ApiKeyInstance """ if self._apikey is None: self._apikey = ApiKeyContext( self._version, account_id=self._solution['account_id'], owner_type='users', owner_id=self._solution['id'], ) return self._apikey.fetch() def fetch(self): """ Fetch a SysUserInstance :returns: Fetched SysUserInstance :rtype: connio.rest.api.v3.sysuser.SysUserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return SysUserInstance( self._version, payload, id=self._solution['id'], ) def update(self, name=values.unset, status=values.unset): """ Update the SysUserInstance :param unicode name: User name to update :param SysUserInstance.Status status: Status to update the User with :returns: Updated SysUserInstance :rtype: connio.rest.api.v3.sysuser.SysUserInstance """ data = values.of({ 'name': name, 'status': status, }) payload = self._version.update( 'PUT', self._uri, data=data, ) return SysUserInstance( self._version, payload, id=self._solution['id'], ) def delete(self): """ Deletes the SysUserInstance :rtype: bool """ return self._version.delete('delete', self._uri)
class UserContext(InstanceContext): """ """ def __init__(self, version, account_id, id): """ Initialize the UserContext :param Version version: Version that contains the resource :param account_id: The account_id :param id: Fetch by unique entity id :returns: connio.rest.api.v3.account.user.UserContext :rtype: connio.rest.api.v3.account.user.UserContext """ super(UserContext, self).__init__(version) # Path Solution self._solution = { 'account_id': account_id, 'id': id, } self._uri = '/accounts/{account_id}/users/{id}'.format( **self._solution) self._apikey = None def fetch(self): """ Fetch a UserInstance :returns: Fetched UserInstance :rtype: connio.rest.api.v3.account.user.UserInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return UserInstance( self._version, payload, account_id=self._solution['account_id'], id=self._solution['id'], ) def update(self, name=values.unset, password=values.unset): """ Update the UserInstance :param unicode name: Given name of the entity :param unicode password: :returns: Updated UserInstance :rtype: connio.rest.api.v3.account.user.UserInstance """ data = values.of({ 'name': name, 'password': password, }) payload = self._version.update( 'PUT', self._uri, data=data, ) return UserInstance( self._version, payload, account_id=self._solution['account_id'], id=self._solution['id'], ) def delete(self): """ Deletes the UserInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def apikey(self): """ :returns: connio.rest.api.v3.account.apikey.ApiKeyInstance :rtype: connio.rest.api.v3.account.apikey.ApiKeyInstance """ if self._apikey is None: self._apikey = ApiKeyContext( self._version, account_id=self._solution['account_id'], owner_type='users', owner_id=self._solution['id'], ) return self._apikey.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return '<Connio.Api.V3.UserContext {}>'.format(context)
class DeviceContext(InstanceContext): """ """ def __init__(self, version, account_id, id): """ Initialize the DeviceContext :param Version version: Version that contains the resource :param account_id: The account_id :param id: Fetch by unique entity id :returns: connio.rest.api.v3.account.device.DeviceContext :rtype: connio.rest.api.v3.account.device.DeviceContext """ super(DeviceContext, self).__init__(version) # Path Solution self._solution = { 'account_id': account_id, 'id': id, } self._uri = '/accounts/{account_id}/devices/{id}'.format( **self._solution) self._apikey = None def fetch(self): """ Fetch a DeviceInstance :returns: Fetched DeviceInstance :rtype: connio.rest.api.v3.account.device.DeviceInstance """ params = values.of({}) payload = self._version.fetch( 'GET', self._uri, params=params, ) return DeviceInstance( self._version, payload, account_id=self._solution['account_id'], id=self._solution['id'], ) def update(self, name=values.unset, friendly_name=values.unset, apps=values.unset, description=values.unset, tags=values.unset, period=values.unset, location=values.unset, custom_ids=values.unset, status=values.unset, annotate_with_location=values.unset, annotate_with_meta=values.unset): """ Update the DeviceInstance :param unicode name: Given name of the entity :param unicode friendly_name: A human readable description of this resource :returns: Updated DeviceInstance :rtype: connio.rest.api.v3.account.device.DeviceInstance """ data = values.of({ 'name': name, 'friendlyName': friendly_name, 'apps': apps, 'description': description, 'tags': tags, 'location': serialize.location(location), 'custom_ids': custom_ids, 'status': status, 'period': period, 'annotateWithLoc': annotate_with_location, 'annotateWithMeta': annotate_with_meta, }) payload = self._version.update( 'PUT', self._uri, data=data, ) return DeviceInstance( self._version, payload, account_id=self._solution['account_id'], id=self._solution['id'], ) def delete(self): """ Deletes the DeviceInstance :returns: True if delete succeeds, False otherwise :rtype: bool """ return self._version.delete('delete', self._uri) @property def apikey(self): """ :returns: connio.rest.api.v3.account.apikey.ApiKeyInstance :rtype: connio.rest.api.v3.account.apikey.ApiKeyInstance """ if self._apikey is None: self._apikey = ApiKeyContext( self._version, account_id=self._solution['account_id'], owner_type='devices', owner_id=self._solution['id'], ) return self._apikey.fetch() def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) return '<Connio.Api.V3.DeviceContext {}>'.format(context)