prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>727. Minimum Window Subsequence.py<|end_file_name|><|fim▁begin|>from collections import defaultdict class Solution(object): def minWindow(self, S, T): """ :type S: str :type T: str :rtype: str """ pre = defaultdict(list) for i, c in enumerate(T, -1): pre[c].append(i) for val in pre.values(): val.reverse() start_index = [None] * (len(T) + 1) lo, hi = float('-inf'), 0 for i, c in enumerate(S): start_index[-1] = i for p in pre[c]: if start_index[p] is not None: <|fim_middle|> if (c == T[-1] and start_index[-2] is not None and i - start_index[-2] < hi - lo): lo, hi = start_index[-2], i if lo < 0: return '' else: return S[lo:hi+1] # print(Solution().minWindow("abcdebdde", "bde")) # print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt")) print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm")) <|fim▁end|>
start_index[p + 1] = start_index[p]
<|file_name|>727. Minimum Window Subsequence.py<|end_file_name|><|fim▁begin|>from collections import defaultdict class Solution(object): def minWindow(self, S, T): """ :type S: str :type T: str :rtype: str """ pre = defaultdict(list) for i, c in enumerate(T, -1): pre[c].append(i) for val in pre.values(): val.reverse() start_index = [None] * (len(T) + 1) lo, hi = float('-inf'), 0 for i, c in enumerate(S): start_index[-1] = i for p in pre[c]: if start_index[p] is not None: start_index[p + 1] = start_index[p] if (c == T[-1] and start_index[-2] is not None and i - start_index[-2] < hi - lo): <|fim_middle|> if lo < 0: return '' else: return S[lo:hi+1] # print(Solution().minWindow("abcdebdde", "bde")) # print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt")) print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm")) <|fim▁end|>
lo, hi = start_index[-2], i
<|file_name|>727. Minimum Window Subsequence.py<|end_file_name|><|fim▁begin|>from collections import defaultdict class Solution(object): def minWindow(self, S, T): """ :type S: str :type T: str :rtype: str """ pre = defaultdict(list) for i, c in enumerate(T, -1): pre[c].append(i) for val in pre.values(): val.reverse() start_index = [None] * (len(T) + 1) lo, hi = float('-inf'), 0 for i, c in enumerate(S): start_index[-1] = i for p in pre[c]: if start_index[p] is not None: start_index[p + 1] = start_index[p] if (c == T[-1] and start_index[-2] is not None and i - start_index[-2] < hi - lo): lo, hi = start_index[-2], i if lo < 0: <|fim_middle|> else: return S[lo:hi+1] # print(Solution().minWindow("abcdebdde", "bde")) # print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt")) print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm")) <|fim▁end|>
return ''
<|file_name|>727. Minimum Window Subsequence.py<|end_file_name|><|fim▁begin|>from collections import defaultdict class Solution(object): def minWindow(self, S, T): """ :type S: str :type T: str :rtype: str """ pre = defaultdict(list) for i, c in enumerate(T, -1): pre[c].append(i) for val in pre.values(): val.reverse() start_index = [None] * (len(T) + 1) lo, hi = float('-inf'), 0 for i, c in enumerate(S): start_index[-1] = i for p in pre[c]: if start_index[p] is not None: start_index[p + 1] = start_index[p] if (c == T[-1] and start_index[-2] is not None and i - start_index[-2] < hi - lo): lo, hi = start_index[-2], i if lo < 0: return '' else: <|fim_middle|> # print(Solution().minWindow("abcdebdde", "bde")) # print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt")) print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm")) <|fim▁end|>
return S[lo:hi+1]
<|file_name|>727. Minimum Window Subsequence.py<|end_file_name|><|fim▁begin|>from collections import defaultdict class Solution(object): def <|fim_middle|>(self, S, T): """ :type S: str :type T: str :rtype: str """ pre = defaultdict(list) for i, c in enumerate(T, -1): pre[c].append(i) for val in pre.values(): val.reverse() start_index = [None] * (len(T) + 1) lo, hi = float('-inf'), 0 for i, c in enumerate(S): start_index[-1] = i for p in pre[c]: if start_index[p] is not None: start_index[p + 1] = start_index[p] if (c == T[-1] and start_index[-2] is not None and i - start_index[-2] < hi - lo): lo, hi = start_index[-2], i if lo < 0: return '' else: return S[lo:hi+1] # print(Solution().minWindow("abcdebdde", "bde")) # print(Solution().minWindow("nkzcnhczmccqouqadqtmjjzltgdzthm", "bt")) print(Solution().minWindow("cnhczmccqouqadqtmjjzl", "mm")) <|fim▁end|>
minWindow
<|file_name|>verify.py<|end_file_name|><|fim▁begin|># Copyright 2010 http://www.collabq.com import logging from django.conf import settings from django.http import HttpResponseRedirect from common import api from common import exception class VerifyInstallMiddleware(object):<|fim▁hole|> logging.info("VerifyInstallMiddleware") logging.info("Path %s" % request.path) if not request.path == '/install': try: root_user = api.actor_get(api.ROOT, settings.ROOT_NICK) logging.info("Root Exists") except: logging.info("Root Does Not Exists") return HttpResponseRedirect('/install')<|fim▁end|>
def process_request(self, request):
<|file_name|>verify.py<|end_file_name|><|fim▁begin|># Copyright 2010 http://www.collabq.com import logging from django.conf import settings from django.http import HttpResponseRedirect from common import api from common import exception class VerifyInstallMiddleware(object): <|fim_middle|> <|fim▁end|>
def process_request(self, request): logging.info("VerifyInstallMiddleware") logging.info("Path %s" % request.path) if not request.path == '/install': try: root_user = api.actor_get(api.ROOT, settings.ROOT_NICK) logging.info("Root Exists") except: logging.info("Root Does Not Exists") return HttpResponseRedirect('/install')
<|file_name|>verify.py<|end_file_name|><|fim▁begin|># Copyright 2010 http://www.collabq.com import logging from django.conf import settings from django.http import HttpResponseRedirect from common import api from common import exception class VerifyInstallMiddleware(object): def process_request(self, request): <|fim_middle|> <|fim▁end|>
logging.info("VerifyInstallMiddleware") logging.info("Path %s" % request.path) if not request.path == '/install': try: root_user = api.actor_get(api.ROOT, settings.ROOT_NICK) logging.info("Root Exists") except: logging.info("Root Does Not Exists") return HttpResponseRedirect('/install')
<|file_name|>verify.py<|end_file_name|><|fim▁begin|># Copyright 2010 http://www.collabq.com import logging from django.conf import settings from django.http import HttpResponseRedirect from common import api from common import exception class VerifyInstallMiddleware(object): def process_request(self, request): logging.info("VerifyInstallMiddleware") logging.info("Path %s" % request.path) if not request.path == '/install': <|fim_middle|> <|fim▁end|>
try: root_user = api.actor_get(api.ROOT, settings.ROOT_NICK) logging.info("Root Exists") except: logging.info("Root Does Not Exists") return HttpResponseRedirect('/install')
<|file_name|>verify.py<|end_file_name|><|fim▁begin|># Copyright 2010 http://www.collabq.com import logging from django.conf import settings from django.http import HttpResponseRedirect from common import api from common import exception class VerifyInstallMiddleware(object): def <|fim_middle|>(self, request): logging.info("VerifyInstallMiddleware") logging.info("Path %s" % request.path) if not request.path == '/install': try: root_user = api.actor_get(api.ROOT, settings.ROOT_NICK) logging.info("Root Exists") except: logging.info("Root Does Not Exists") return HttpResponseRedirect('/install')<|fim▁end|>
process_request
<|file_name|>a.py<|end_file_name|><|fim▁begin|># import re, os # from jandy.profiler import Profiler # # # class Base: # def __init__(self): # print('init call') # # def compile(self, str): # re.compile(str)<|fim▁hole|># try: # p.start() # b = Base() # b.compile("foo|bar") # print("Hello World!!\n") # finally: # p.done() # # # #try: # # b.print_usage() # #except e.MyException as e: # # raise ValueError('failed')<|fim▁end|>
# # # # p = Profiler("12K", "localhost:3000", 1)
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input())<|fim▁hole|>n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01'<|fim▁end|>
print 'NOTAS:'
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): <|fim_middle|> n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: <|fim_middle|> print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
qnt = int(count) / value
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: <|fim_middle|> else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: <|fim_middle|> if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): <|fim_middle|> else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
print '%.0f moeda(s) de R$ 0.01' % m1
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def calc_note(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: <|fim_middle|> <|fim▁end|>
print '0 moeda(s) de R$ 0.01'
<|file_name|>1021.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- def <|fim_middle|>(count, value): qnt = 0 if count >= value: qnt = int(count) / value print '%d nota(s) de R$ %d.00' % (qnt, value) return count - qnt * value n = float(raw_input()) print 'NOTAS:' n = calc_note(n, 100) n = calc_note(n, 50) n = calc_note(n, 20) n = calc_note(n, 10) n = calc_note(n, 5) n = calc_note(n, 2) print 'MOEDAS:' print '%d moeda(s) de R$ 1.00' % int(n) n -= int(n) m50 = n / 0.50 print '%d moeda(s) de R$ 0.50' % m50 n -= int(m50) * 0.50 m25 = n / 0.25 print '%d moeda(s) de R$ 0.25' % m25 n -= int(m25) * 0.25 m10 = n / 0.10 print '%d moeda(s) de R$ 0.10' % m10 n -= int(m10) * 0.10 if round(n, 2) >= 0.05: print '1 moeda(s) de R$ 0.05' m1 = (n - 0.05) * 100 else: print '0 moeda(s) de R$ 0.05' m1 = round(n, 2) * 100 if round(m1, 0): print '%.0f moeda(s) de R$ 0.01' % m1 else: print '0 moeda(s) de R$ 0.01' <|fim▁end|>
calc_note
<|file_name|>testLock2.py<|end_file_name|><|fim▁begin|>"""import portalocker with portalocker.Lock('text.txt', timeout=5) as fh: fh.write("Sono in testLoxk2.py") """ from lockfile import LockFile <|fim▁hole|>with lock: print lock.path, 'is locked.' with open('text.txt', "a") as file: file.write("Sono in testLock2.py")<|fim▁end|>
lock = LockFile('text.txt')
<|file_name|>strFormat.py<|end_file_name|><|fim▁begin|># testStr = "Hello {name}, How long have you bean?. I'm {myName}" # # testStr = testStr.format(name="Leo", myName="Serim") # # print(testStr)<|fim▁hole|> # print( "4" in "3.5")<|fim▁end|>
limit = None hello = str(limit, "") print(hello)
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"],<|fim▁hole|> "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data()<|fim▁end|>
"offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"],
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): <|fim_middle|> class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True)
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): <|fim_middle|> class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2)
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): <|fim_middle|> @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): <|fim_middle|> @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Return the name of the sensor.""" return f"{self.client_name} {self._name}"
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): <|fim_middle|> @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Return the state of the sensor.""" return self._state
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): <|fim_middle|> @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): <|fim_middle|> async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Icon to use in the frontend, if any.""" return self._icon
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): <|fim_middle|> class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2)
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: <|fim_middle|> <|fim▁end|>
"""Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data()
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): <|fim_middle|> @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
"""Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {}
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): <|fim_middle|> <|fim▁end|>
"""Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data()
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: <|fim_middle|> class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
self._state = round(self.ebox_data.data[self.type], 2)
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def <|fim_middle|>(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
async_setup_platform
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def <|fim_middle|>(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
__init__
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def <|fim_middle|>(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
name
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def <|fim_middle|>(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
state
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def <|fim_middle|>(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
unit_of_measurement
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def <|fim_middle|>(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
icon
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def <|fim_middle|>(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
async_update
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def <|fim_middle|>(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def async_update(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
__init__
<|file_name|>sensor.py<|end_file_name|><|fim▁begin|>""" Support for EBox. Get data from 'My Usage Page' page: https://client.ebox.ca/myusage For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.ebox/ """ import logging from datetime import timedelta import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, CONF_NAME, CONF_MONITORED_VARIABLES, ) from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) GIGABITS = "Gb" PRICE = "CAD" DAYS = "days" PERCENT = "%" DEFAULT_NAME = "EBox" REQUESTS_TIMEOUT = 15 SCAN_INTERVAL = timedelta(minutes=15) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) SENSOR_TYPES = { "usage": ["Usage", PERCENT, "mdi:percent"], "balance": ["Balance", PRICE, "mdi:square-inc-cash"], "limit": ["Data limit", GIGABITS, "mdi:download"], "days_left": ["Days left", DAYS, "mdi:calendar-today"], "before_offpeak_download": ["Download before offpeak", GIGABITS, "mdi:download"], "before_offpeak_upload": ["Upload before offpeak", GIGABITS, "mdi:upload"], "before_offpeak_total": ["Total before offpeak", GIGABITS, "mdi:download"], "offpeak_download": ["Offpeak download", GIGABITS, "mdi:download"], "offpeak_upload": ["Offpeak Upload", GIGABITS, "mdi:upload"], "offpeak_total": ["Offpeak Total", GIGABITS, "mdi:download"], "download": ["Download", GIGABITS, "mdi:download"], "upload": ["Upload", GIGABITS, "mdi:upload"], "total": ["Total", GIGABITS, "mdi:download"], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_MONITORED_VARIABLES): vol.All( cv.ensure_list, [vol.In(SENSOR_TYPES)] ), vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the EBox sensor.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) httpsession = hass.helpers.aiohttp_client.async_get_clientsession() ebox_data = EBoxData(username, password, httpsession) name = config.get(CONF_NAME) from pyebox.client import PyEboxError try: await ebox_data.async_update() except PyEboxError as exp: _LOGGER.error("Failed login: %s", exp) raise PlatformNotReady sensors = [] for variable in config[CONF_MONITORED_VARIABLES]: sensors.append(EBoxSensor(ebox_data, variable, name)) async_add_entities(sensors, True) class EBoxSensor(Entity): """Implementation of a EBox sensor.""" def __init__(self, ebox_data, sensor_type, name): """Initialize the sensor.""" self.client_name = name self.type = sensor_type self._name = SENSOR_TYPES[sensor_type][0] self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._icon = SENSOR_TYPES[sensor_type][2] self.ebox_data = ebox_data self._state = None @property def name(self): """Return the name of the sensor.""" return f"{self.client_name} {self._name}" @property def state(self): """Return the state of the sensor.""" return self._state @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property def icon(self): """Icon to use in the frontend, if any.""" return self._icon async def async_update(self): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.type in self.ebox_data.data: self._state = round(self.ebox_data.data[self.type], 2) class EBoxData: """Get data from Ebox.""" def __init__(self, username, password, httpsession): """Initialize the data object.""" from pyebox import EboxClient self.client = EboxClient(username, password, REQUESTS_TIMEOUT, httpsession) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) async def <|fim_middle|>(self): """Get the latest data from Ebox.""" from pyebox.client import PyEboxError try: await self.client.fetch_data() except PyEboxError as exp: _LOGGER.error("Error on receive last EBox data: %s", exp) return # Update data self.data = self.client.get_data() <|fim▁end|>
async_update
<|file_name|>excise.py<|end_file_name|><|fim▁begin|>def excise(conn, qrelname, tid): with conn.cursor() as cur: # Assume 'id' column exists and print that for bookkeeping. # # TODO: Instead should find unique constraints and print # those, or try to print all attributes that are not corrupt. sql = 'DELETE FROM {0} WHERE ctid = %s RETURNING id'.format(qrelname) params = (tid,) cur.execute(sql, params) <|fim▁hole|> row = cur.fetchone() if row: return row[0] return None<|fim▁end|>
<|file_name|>excise.py<|end_file_name|><|fim▁begin|>def excise(conn, qrelname, tid): <|fim_middle|> <|fim▁end|>
with conn.cursor() as cur: # Assume 'id' column exists and print that for bookkeeping. # # TODO: Instead should find unique constraints and print # those, or try to print all attributes that are not corrupt. sql = 'DELETE FROM {0} WHERE ctid = %s RETURNING id'.format(qrelname) params = (tid,) cur.execute(sql, params) row = cur.fetchone() if row: return row[0] return None
<|file_name|>excise.py<|end_file_name|><|fim▁begin|>def excise(conn, qrelname, tid): with conn.cursor() as cur: # Assume 'id' column exists and print that for bookkeeping. # # TODO: Instead should find unique constraints and print # those, or try to print all attributes that are not corrupt. sql = 'DELETE FROM {0} WHERE ctid = %s RETURNING id'.format(qrelname) params = (tid,) cur.execute(sql, params) row = cur.fetchone() if row: <|fim_middle|> return None <|fim▁end|>
return row[0]
<|file_name|>excise.py<|end_file_name|><|fim▁begin|>def <|fim_middle|>(conn, qrelname, tid): with conn.cursor() as cur: # Assume 'id' column exists and print that for bookkeeping. # # TODO: Instead should find unique constraints and print # those, or try to print all attributes that are not corrupt. sql = 'DELETE FROM {0} WHERE ctid = %s RETURNING id'.format(qrelname) params = (tid,) cur.execute(sql, params) row = cur.fetchone() if row: return row[0] return None <|fim▁end|>
excise
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none'<|fim▁hole|> if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } )<|fim▁end|>
})
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): <|fim_middle|> <|fim▁end|>
page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } )
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): <|fim_middle|> # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
raise PermissionDenied
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: <|fim_middle|> else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page)
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: <|fim_middle|> if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
restriction = None restriction_exists_on_ancestor = False
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': <|fim_middle|> else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } )
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: <|fim_middle|> else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } )
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction <|fim_middle|> else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
if restriction: restriction.delete()
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: <|fim_middle|> else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
restriction.delete()
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: <|fim_middle|> return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
restriction = form.save(commit=False) restriction.page = page form.save()
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET <|fim_middle|> if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' })
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: <|fim_middle|> if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' })
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: <|fim_middle|> else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
form = PageViewRestrictionForm(instance=restriction)
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page <|fim_middle|> if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' })
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions <|fim_middle|> else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } )
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def set_privacy(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here <|fim_middle|> <|fim▁end|>
return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } )
<|file_name|>page_privacy.py<|end_file_name|><|fim▁begin|>from __future__ import absolute_import, unicode_literals from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from wagtail.wagtailadmin.forms import PageViewRestrictionForm from wagtail.wagtailadmin.modal_workflow import render_modal_workflow from wagtail.wagtailcore.models import Page, PageViewRestriction def <|fim_middle|>(request, page_id): page = get_object_or_404(Page, id=page_id) page_perms = page.permissions_for_user(request.user) if not page_perms.can_set_view_restrictions(): raise PermissionDenied # fetch restriction records in depth order so that ancestors appear first restrictions = page.get_view_restrictions().order_by('page__depth') if restrictions: restriction = restrictions[0] restriction_exists_on_ancestor = (restriction.page != page) else: restriction = None restriction_exists_on_ancestor = False if request.method == 'POST': form = PageViewRestrictionForm(request.POST, instance=restriction) if form.is_valid() and not restriction_exists_on_ancestor: if form.cleaned_data['restriction_type'] == PageViewRestriction.NONE: # remove any existing restriction if restriction: restriction.delete() else: restriction = form.save(commit=False) restriction.page = page form.save() return render_modal_workflow( request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', { 'is_public': (form.cleaned_data['restriction_type'] == 'none') } ) else: # request is a GET if not restriction_exists_on_ancestor: if restriction: form = PageViewRestrictionForm(instance=restriction) else: # no current view restrictions on this page form = PageViewRestrictionForm(initial={ 'restriction_type': 'none' }) if restriction_exists_on_ancestor: # display a message indicating that there is a restriction at ancestor level - # do not provide the form for setting up new restrictions return render_modal_workflow( request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None, { 'page_with_restriction': restriction.page, } ) else: # no restriction set at ancestor level - can set restrictions here return render_modal_workflow( request, 'wagtailadmin/page_privacy/set_privacy.html', 'wagtailadmin/page_privacy/set_privacy.js', { 'page': page, 'form': form, } ) <|fim▁end|>
set_privacy
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' <|fim▁hole|> Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>'<|fim▁end|>
class FeedbackPage(Page): def __init__(self, version, response, solution): """
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): <|fim_middle|> class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): <|fim_middle|> def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution)
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): <|fim_middle|> def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], )
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): <|fim_middle|> class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): <|fim_middle|> class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): <|fim_middle|> def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): <|fim_middle|> def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], )
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): <|fim_middle|> class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): <|fim_middle|> <|fim▁end|>
class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): <|fim_middle|> def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed"
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): <|fim_middle|> @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, }
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): <|fim_middle|> @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The account_sid :rtype: unicode """ return self._properties['account_sid']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): <|fim_middle|> @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The message_sid :rtype: unicode """ return self._properties['message_sid']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): <|fim_middle|> @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): <|fim_middle|> @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The date_created :rtype: datetime """ return self._properties['date_created']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): <|fim_middle|> @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The date_updated :rtype: datetime """ return self._properties['date_updated']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): <|fim_middle|> def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
""" :returns: The uri :rtype: unicode """ return self._properties['uri']
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): <|fim_middle|> <|fim▁end|>
""" Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>'
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def <|fim_middle|>(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__init__
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def <|fim_middle|>(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
create
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def <|fim_middle|>(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__repr__
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def <|fim_middle|>(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__init__
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def <|fim_middle|>(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
get_instance
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def <|fim_middle|>(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__repr__
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def <|fim_middle|>(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__init__
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def <|fim_middle|>(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
account_sid
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def <|fim_middle|>(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
message_sid
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def <|fim_middle|>(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
outcome
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def <|fim_middle|>(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
date_created
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def <|fim_middle|>(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
date_updated
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def <|fim_middle|>(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
uri
<|file_name|>feedback.py<|end_file_name|><|fim▁begin|># coding=utf-8 """ This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from twilio.base import deserialize from twilio.base import values from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.page import Page class FeedbackList(ListResource): def __init__(self, version, account_sid, message_sid): """ Initialize the FeedbackList :param Version version: Version that contains the resource :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackList :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackList """ super(FeedbackList, self).__init__(version) # Path Solution self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } self._uri = '/Accounts/{account_sid}/Messages/{message_sid}/Feedback.json'.format(**self._solution) def create(self, outcome=values.unset): """ Create a new FeedbackInstance :param FeedbackInstance.Outcome outcome: The outcome :returns: Newly created FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ data = values.of({ 'Outcome': outcome, }) payload = self._version.create( 'POST', self._uri, data=data, ) return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackList>' class FeedbackPage(Page): def __init__(self, version, response, solution): """ Initialize the FeedbackPage :param Version version: Version that contains the resource :param Response response: Response from the API :param account_sid: The account_sid :param message_sid: The message_sid :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackPage :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackPage """ super(FeedbackPage, self).__init__(version, response) # Path Solution self._solution = solution def get_instance(self, payload): """ Build an instance of FeedbackInstance :param dict payload: Payload response from the API :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ return FeedbackInstance( self._version, payload, account_sid=self._solution['account_sid'], message_sid=self._solution['message_sid'], ) def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackPage>' class FeedbackInstance(InstanceResource): class Outcome(object): CONFIRMED = "confirmed" UMCONFIRMED = "umconfirmed" def __init__(self, version, payload, account_sid, message_sid): """ Initialize the FeedbackInstance :returns: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance :rtype: twilio.rest.api.v2010.account.message.feedback.FeedbackInstance """ super(FeedbackInstance, self).__init__(version) # Marshaled Properties self._properties = { 'account_sid': payload['account_sid'], 'message_sid': payload['message_sid'], 'outcome': payload['outcome'], 'date_created': deserialize.rfc2822_datetime(payload['date_created']), 'date_updated': deserialize.rfc2822_datetime(payload['date_updated']), 'uri': payload['uri'], } # Context self._context = None self._solution = { 'account_sid': account_sid, 'message_sid': message_sid, } @property def account_sid(self): """ :returns: The account_sid :rtype: unicode """ return self._properties['account_sid'] @property def message_sid(self): """ :returns: The message_sid :rtype: unicode """ return self._properties['message_sid'] @property def outcome(self): """ :returns: The outcome :rtype: FeedbackInstance.Outcome """ return self._properties['outcome'] @property def date_created(self): """ :returns: The date_created :rtype: datetime """ return self._properties['date_created'] @property def date_updated(self): """ :returns: The date_updated :rtype: datetime """ return self._properties['date_updated'] @property def uri(self): """ :returns: The uri :rtype: unicode """ return self._properties['uri'] def <|fim_middle|>(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Api.V2010.FeedbackInstance>' <|fim▁end|>
__repr__
<|file_name|>setup.py<|end_file_name|><|fim▁begin|><|fim▁hole|>from __future__ import division, print_function, absolute_import from os.path import join def configuration(parent_package='', top_path=None): import warnings from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info, BlasNotFoundError config = Configuration('odr', parent_package, top_path) libodr_files = ['d_odr.f', 'd_mprec.f', 'dlunoc.f'] blas_info = get_info('blas_opt') if blas_info: libodr_files.append('d_lpk.f') else: warnings.warn(BlasNotFoundError.__doc__) libodr_files.append('d_lpkbls.f') odrpack_src = [join('odrpack', x) for x in libodr_files] config.add_library('odrpack', sources=odrpack_src) sources = ['__odrpack.c'] libraries = ['odrpack'] + blas_info.pop('libraries', []) include_dirs = ['.'] + blas_info.pop('include_dirs', []) config.add_extension('__odrpack', sources=sources, libraries=libraries, include_dirs=include_dirs, depends=(['odrpack.h'] + odrpack_src), **blas_info ) config.add_data_dir('tests') return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict())<|fim▁end|>
#!/usr/bin/env python
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import division, print_function, absolute_import from os.path import join def configuration(parent_package='', top_path=None): <|fim_middle|> if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict()) <|fim▁end|>
import warnings from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info, BlasNotFoundError config = Configuration('odr', parent_package, top_path) libodr_files = ['d_odr.f', 'd_mprec.f', 'dlunoc.f'] blas_info = get_info('blas_opt') if blas_info: libodr_files.append('d_lpk.f') else: warnings.warn(BlasNotFoundError.__doc__) libodr_files.append('d_lpkbls.f') odrpack_src = [join('odrpack', x) for x in libodr_files] config.add_library('odrpack', sources=odrpack_src) sources = ['__odrpack.c'] libraries = ['odrpack'] + blas_info.pop('libraries', []) include_dirs = ['.'] + blas_info.pop('include_dirs', []) config.add_extension('__odrpack', sources=sources, libraries=libraries, include_dirs=include_dirs, depends=(['odrpack.h'] + odrpack_src), **blas_info ) config.add_data_dir('tests') return config
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python from __future__ import division, print_function, absolute_import from os.path import join def configuration(parent_package='', top_path=None): import warnings from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info, BlasNotFoundError config = Configuration('odr', parent_package, top_path) libodr_files = ['d_odr.f', 'd_mprec.f', 'dlunoc.f'] blas_info = get_info('blas_opt') if blas_info: <|fim_middle|> else: warnings.warn(BlasNotFoundError.__doc__) libodr_files.append('d_lpkbls.f') odrpack_src = [join('odrpack', x) for x in libodr_files] config.add_library('odrpack', sources=odrpack_src) sources = ['__odrpack.c'] libraries = ['odrpack'] + blas_info.pop('libraries', []) include_dirs = ['.'] + blas_info.pop('include_dirs', []) config.add_extension('__odrpack', sources=sources, libraries=libraries, include_dirs=include_dirs, depends=(['odrpack.h'] + odrpack_src), **blas_info ) config.add_data_dir('tests') return config if __name__ == '__main__': from numpy.distutils.core import setup setup(**configuration(top_path='').todict()) <|fim▁end|>
libodr_files.append('d_lpk.f')