def RequestCronJobApproval(self, cron_job_id, requestor=None, reason=None, email_cc_address=None, approver="approver"): """Request cron job approval for a given cron job.""" if not requestor: requestor = self.token.username if not reason: reason = self.token.reason self.CreateUser(requestor) self.CreateUser(approver) args = api_user.ApiCreateCronJobApprovalArgs( cron_job_id=cron_job_id, approval=api_user.ApiCronJobApproval( reason=reason, notified_users=[approver], email_cc_addresses=([email_cc_address] if email_cc_address else []))) handler = api_user.ApiCreateCronJobApprovalHandler() result = handler.Handle( args, token=access_control.ACLToken(username=requestor)) return result.id
def setUp(self): super(ApiCreateCronJobApprovalHandlerTest, self).setUp() self.SetUpApprovalTest() cron_manager = aff4_cronjobs.GetCronManager() cron_args = rdf_cronjobs.CreateCronJobFlowArgs( periodicity="1d", allow_overruns=False) cron_id = cron_manager.CreateJob(cron_args=cron_args, token=self.token) self.handler = user_plugin.ApiCreateCronJobApprovalHandler() self.args = user_plugin.ApiCreateCronJobApprovalArgs(cron_job_id=cron_id) self.args.approval.reason = self.token.reason self.args.approval.notified_users = ["approver"] self.args.approval.email_cc_addresses = ["*****@*****.**"]
def CreateCronJobApproval(self, args, token=None): return api_user.ApiCreateCronJobApprovalHandler()