示例#1
0
 def create_slo_recalculation_tasks():
     tasks = [
         Tasks.create(method='POST',
                      url='/sli/latency_for_x_days',
                      params={'x_days': x_days})
         for x_days in [4, 5, 7]
     ]
     tasks.append(
         Tasks.create(
             method='POST',
             url='/sli/quality'))
     return tasks
示例#2
0
 def schedule_backup_task(self, projectId, datasetId, tableId):
     logging.info("Schedule_backup_task: '%s:%s.%s'", projectId, datasetId,
                  tableId)
     task = Tasks.create(method='GET',
                         url='/tasks/backups/table/{0}/{1}/{2}'.format(
                             projectId, datasetId, tableId))
     Tasks.schedule('backup-worker', task)
示例#3
0
 def create_table_backup_task(project_id, dataset_id, table_id):
     logging.debug(u'Create Table Backup task for %s:%s.%s', project_id,
                   dataset_id, table_id)
     table_id = urllib2.quote(table_id.encode('UTF-8'))
     return Tasks.create(method='GET',
                         url=u'/tasks/backups/table/{0}/{1}/{2}'.format(
                             project_id, dataset_id, table_id))
示例#4
0
 def test_should_create_task_with_additional_correlation_id_header(self, _):
     # when
     task = Tasks.create(url='/example/task1',
                         headers={'key': 'value'})
     # then
     header_value = task.headers[request_correlation_id.HEADER_NAME]
     self.assertEqual(header_value, 'correlation-id')
     self.assertEqual(task.headers['key'], 'value')
示例#5
0
    def create_project_backup_scheduler_task(project_id, page_token=None):
        logging.debug(
            u'Create Project Backup Scheduler task for %s, page_token: %s',
            project_id, page_token)

        params = {'projectId': project_id}
        if page_token:
            params['pageToken'] = page_token

        return Tasks.create(url='/tasks/schedulebackup/project', params=params)
示例#6
0
    def create_organisation_backup_scheduler_task(page_token=None):
        logging.debug(
            u'Create Organisation Backup Scheduler task for page_token: %s',
            page_token)

        params = {}
        if page_token:
            params['pageToken'] = page_token

        return Tasks.create(method='GET',
                            url='/tasks/schedulebackup/organization',
                            params=params)
示例#7
0
    def create_partitioned_table_backup_scheduler_task(project_id, dataset_id,
                                                       table_id):
        logging.debug(
            u'Create Partitioned Table Backup Scheduler task for %s:%s.%s',
            project_id, dataset_id, table_id)

        return Tasks.create(url='/tasks/schedulebackup/partitionedtable',
                            params={
                                'projectId': project_id,
                                'datasetId': dataset_id,
                                'tableId': table_id
                            })
示例#8
0
 def __backup_dataset(self, project_id, dataset_id):
     logging.info('Backing up dataset: %s', dataset_id)
     task = Tasks.create(url='/tasks/backups/dataset',
                         params={
                             'projectId': project_id,
                             'datasetId': dataset_id
                         },
                         headers={
                             request_correlation_id.HEADER_NAME:
                             self.request_correlation_id
                         })
     Tasks.schedule('backup-scheduler', task)
示例#9
0
    def schedule_tasks_for_partition_backup(project_id, dataset_id, table_id,
                                            partition_ids):
        logging.info(
            "Scheduling backup tasks for table: '%s/%s/%s partitions: %s'",
            project_id, dataset_id, table_id, partition_ids)

        tasks = []
        for partition_id in partition_ids:
            task = Tasks.create(method='GET',
                                url='/tasks/backups/table/{}/{}/{}/{}'.format(
                                    project_id, dataset_id, table_id,
                                    partition_id))
            tasks.append(task)
        Tasks.schedule('backup-worker', tasks)
示例#10
0
 def test_should_create_task_without_correlation_id_header(self, _):
     # when
     task = Tasks.create(url='/example/task1',
                         headers={'key': 'value'})
     # then
     self.assertEqual(task.headers['key'], 'value')
示例#11
0
 def test_should_create_task_with_correlation_id_header(self, _):
     # when
     task = Tasks.create(url='/example/task1')
     # then
     header_value = task.headers[request_correlation_id.HEADER_NAME]
     self.assertEqual(header_value, 'correlation-id')