Пример #1
0
 def update_geoblock(self, stream_target_id, param_dict, wait=False):
     """ Updates a geoblocked location """
     if isinstance(param_dict, dict):
         path = self.base_url + '{}/geoblock'.format(stream_target_id)
         param_dict = {
             'geoblock': param_dict
         }
         response = session.patch(path, json.dumps(param_dict),
             headers=self.headers)
         # if we want to wait until we're able to make the update
         # it may take up to 30 minutes for mutability after creation
         if ('meta' in response.json()) and wait:
             if response.json()['meta']['code'] == 'ERR-423-GeoblockingBusy':
                 while 'meta' in response.json():
                     response = session.patch(path, json.dumps(param_dict),
                         headers=self.headers)
                     time.sleep(5)
                 return response.json()
         else:
             raise GeoblockingBusy({
                 'message': 'The stream target is already processing a \
                 geoblocking request. Please try again later, or try \
                 submitting your request with the wait=True parameter.'
                 })
         return response.json()
     else:
         raise InvalidParamDict({
             'message': 'Invalid parameter dictionary provided.'
         })
Пример #2
0
 def update_token_auth(self, stream_target_id, param_dict, wait=False):
     """
     Used to update details associated with a token authorization
     """
     if isinstance(param_dict, dict):
         path = self.base_url + '{}/token_auth'.format(stream_target_id)
         param_dict = {
             'token_auth': param_dict
         }
         response = session.patch(path, json.dumps(param_dict),
             headers=self.headers)
         if ('meta' in response.json()) and wait: # if we want to try again
             if response.json()['meta']['code'] == 'ERR-423-TokenAuthBusy':
                 while 'meta' in response.json():
                     response = session.patch(path, json.dumps(param_dict),
                         headers=self.headers)
                     time.sleep(5)
                 return response.json()
         else:
             raise TokenAuthBusy({
                 'message': 'The stream target is already processing a \
                 token auth request. Please try again later, or try \
                 submitting your request with the wait=True parameter.'
                 })
         return response.json()
     else:
         raise InvalidParamDict({
             'message': 'Invalid parameter dictionary provided.'
         })
Пример #3
0
 def update(self, sched_id, param_dict):
     """
     Used to update the details associated with a specific schedule
     """
     path = self.base_url + sched_id
     if isinstance(param_dict, dict):
         param_dict = {'schedule': param_dict}
         response = session.patch(path,
                                  json.dumps(param_dict),
                                  headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict(
             {'message': 'Param_dict needs to be a valid dictionary.'})
Пример #4
0
 def create_property(self, stream_target_id, param_dict):
     """
     Used to create a property for a stream target
     """
     if isinstance(param_dict, dict):
         path = self.base_url + '{}/properties'.format(stream_target_id)
         param_dict = {'property': param_dict}
         response = session.post(path,
                                 json.dumps(param_dict),
                                 headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict(
             {'message': 'Invalid parameter dictionary provided.'})
Пример #5
0
 def create_token_auth(self, stream_target_id, param_dict):
     """
     Create token authorization for a stream target
     """
     if isinstance(param_dict, dict):
         path = self.base_url + '{}/token_auth'.format(stream_target_id)
         param_dict = {'token_auth': param_dict}
         response = session.post(path,
                                 json.dumps(param_dict),
                                 headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict(
             {'message': 'Invalid parameter dictionary provided.'})
Пример #6
0
 def update(self, stream_target_id, param_dict):
     """
     Used to update details associated with a particular stream target
     """
     if isinstance(param_dict, dict):
         path = self.base_url + stream_target_id
         param_dict = {'stream_target': param_dict}
         response = session.patch(path,
                                  json.dumps(param_dict),
                                  headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict(
             {'message': 'Invalid parameter dictionary provided.'})
Пример #7
0
 def update(self, source_id, param_dict):
     """
     Used to update the details associated with a particular source
     """
     if isinstance(param_dict, dict):
         path = self.base_url + source_id
         param_dict = {'stream_source': param_dict}
         response = session.patch(path,
                                  json.dumps(param_dict),
                                  headers=self.headers)
         return response.json()
     else:
         return InvalidParamDict(
             {'message': 'The provided parameter dictionary is not valid.'})
Пример #8
0
 def create(self, param_dict):
     """
     Used to create a source
     """
     if isinstance(param_dict, dict):
         path = self.base_url
         param_dict = {'stream_source': param_dict}
         response = session.post(path,
                                 json.dumps(param_dict),
                                 headers=self.headers)
         return response.json()
     else:
         return InvalidParamDict(
             {'message': 'The provided parameter dictionary is not valid.'})
Пример #9
0
 def create_geoblock(self, stream_target_id, param_dict):
     """
     Create a geoblock location for a stream target
     NOTE: WOWZA ALPHA FEATURE
     """
     if isinstance(param_dict, dict):
         path = self.base_url + '{}/geoblock'.format(stream_target_id)
         param_dict = {'geoblock': param_dict}
         response = session.post(path,
                                 json.dumps(param_dict),
                                 headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict(
             {'message': 'Invalid parameter dictionary provided.'})
Пример #10
0
 def create(self, param_dict):
     """
     Used to create a new stream
     """
     if isinstance(param_dict, dict):
         path = self.base_url
         param_dict = {'stream_target': param_dict}
         response = session.post(path,
                                 json.dumps(param_dict),
                                 headers=self.headers)
         if 'meta' in response.json():
             if 'LimitReached' in response.json()['meta']['code']:
                 raise LimitReached(
                     {'message': response.json()['meta']['message']})
         return response.json()
     else:
         return InvalidParamDict(
             {'message': 'Invalid parameter dictionary provided.'})
Пример #11
0
 def update(self, stream_id, param_dict):
     """
     Used to update a live stream.
     Expects a dictionary with key-value pairs of the parameter to change
     and the value to change it to.
     """
     if isinstance(param_dict, dict):
         param_dict = {
             'live_stream': param_dict
         }
         path = self.base_url + 'live_streams/{}'.format(stream_id)
         response = session.patch(path, json.dumps(param_dict), headers=self.headers)
         return response.json()
     else:
         raise InvalidParamDict({
             'message': 'Desired parameters for update should be passed in \
             as a dictionary with key-value pairs. \
             i.e. {\'transcoder_type\': \'transcoded\'}'
         })