Extracts a CronJob ID from an APIAuditEntry's HTTP request path.
481073
def _ExtractCronJobIdFromPath(entry, event):
  """"""
  match = re.match(r".*cron-job/([^/]+).*", entry.http_request_path)
  if match:
    event.urn = "aff4:/cron/{}".format(match.group(1))
134084
static String getJobIdFromPath(Path aPath) {
    String fileName = aPath.getName();
    JobFile jf = new JobFile(fileName);
    String jobId = jf.getJobid();
    if(jobId == null) {
      throw new ProcessingException("job id is null for " + aPath.toUri());
    }
    return jobId;
  }
14639
def ResolveCronJobFlowURN(self, cron_job_id):
    """"""
    if not self._value:
      raise ValueError("Can't call ResolveCronJobFlowURN on an empty "
                       "client id.")

    return cron_job_id.ToURN().Add(self._value)
662273
function() {
      if( StackMob['useRelativePathForAjax'] ){
        // Build "relative path" (also used for OAuth signing)
        return StackMob.apiDomain ? StackMob.apiDomain : (this.getHostname() + (this.getPort() ? ':' + this.getPort() : '')) + '/';
      } else {
        // Use absolute path and operate through CORS
        return StackMob.apiDomain ? StackMob.apiDomain : (StackMob['API_SERVER'] + '/');
      }
    }
1063097
def build_api_url(host=REMOTES['default']['ip'],
                  port=REMOTES['default']['port'],
                  path=REMOTES['default']['path'],
                  username=None,
                  password=None,
                  ssl=False):
    """"""
    credentials = make_http_credentials(username, password)
    scheme = 'http'
    if not path:
        path = ''
    if path and not path.startswith('/'):
        path = "/%s" % path
    if ssl:
        scheme += 's'
    return "%s://%s%s:%i%s" % (scheme, credentials, host, port, path)
1095501
def identify(self, req, resp, resource, uri_kwargs):
        """"""
        try:
            return req.get_header('X-Api-Key', True)
        except (KeyError, HTTPMissingHeader):
            pass
1014709
private static String getServerIdString(String id) {

        if (id.contains(CmsADEManager.CLIENT_ID_SEPERATOR)) {
            id = id.substring(0, id.indexOf(CmsADEManager.CLIENT_ID_SEPERATOR));
        }
        return id;
    }
1344581
def BuildApprovalSymlinksUrns(self, approval_id):
    """"""
    return [
        self.ApprovalSymlinkUrnBuilder("cron", self.subject_urn.Basename(),
                                       self.token.username, approval_id)
    ]
103176
def get_task_id(task, base_path_or_url):
    
    name = task.get('name')
    if base_path_or_url:
        if Util.is_url(base_path_or_url):
            name = urllib.parse.urljoin(base_path_or_url, name)
        else:
            name = os.path.normpath(os.path.join(os.path.dirname(base_path_or_url), name))
    task_id = [name,
               task.get('properties'),
               task.get('runset'),
               ]
    return tuple(task_id)
42803
def CheckCronJobAccess(self, username, cron_job_id):
    """"""

    self._CheckAccess(
        username, str(cron_job_id),
        rdf_objects.ApprovalRequest.ApprovalType.APPROVAL_TYPE_CRON_JOB)
39746
def url(self):
        
        endpoint = 'taskinfo?taskID=%d' % self.id
        return posixpath.join(self.connection.weburl, endpoint)
945263
private URI extractURI(RequestElements intuitRequest) throws FMSException
    {
        URI uri = null;

        try {
            uri = new URI(intuitRequest.getRequestParameters().get(RequestElements.REQ_PARAM_RESOURCE_URL));
        } catch (URISyntaxException e) {
            throw new FMSException("URISyntaxException", e);
        }
        return uri;
    }
1292442
def ReadCronJobRuns(self, job_id):
    """"""
    runs = [
        run for run in itervalues(self.cronjob_runs)
        if run.cron_job_id == job_id
    ]
    return sorted(runs, key=lambda run: run.started_at, reverse=True)
368769
def read_service_ids_by_date(path: str) -> Dict[datetime.date, FrozenSet[str]]:
    """"""
    feed = load_raw_feed(path)
    return _service_ids_by_date(feed)
6903
def generate_crontab(current_crontab, path_to_jobs, path_to_app, unique_id):
    
    set_disable_envar = ''
    if os.environ.get('DISABLE_COLLECTORS') == 'true':
        set_disable_envar = 'DISABLE_COLLECTORS={} '.format(
            os.environ.get('DISABLE_COLLECTORS'))
    job_template = '{schedule} ' \
                   '{set_disable_envar}' \
                   '{app_path}/venv/bin/pp-collector ' \
                   '-l {collector_slug} ' \
                   '-c {app_path}/config/{credentials} ' \
                   '-t {app_path}/config/{token} ' \
                   '-b {app_path}/config/{performanceplatform} ' \
                   '>> {app_path}/log/out.log 2>> {app_path}/log/error.log'

    crontab = [line.strip() for line in current_crontab]
    crontab = remove_existing_crontab_for_app(crontab, unique_id)
    additional_crontab = []

    job_number = 0
    with open(path_to_jobs) as jobs:
        try:
            for job in jobs:
                parsed = parse_job_line(job)

                if parsed is not None:
                    job_number += 1
                    if skip_job(job_number):
                        continue

                    schedule, collector_slug, credentials, \
                        token, performanceplatform = parsed

                    cronjob = job_template.format(
                        schedule=schedule,
                        set_disable_envar=set_disable_envar,
                        app_path=path_to_app,
                        collector_slug=collector_slug,
                        credentials=credentials,
                        token=token,
                        performanceplatform=performanceplatform
                    )

                    additional_crontab.append(cronjob)

        except ValueError as e:
            raise ParseError(str(e))

    if additional_crontab:
        crontab.append(crontab_begin_comment(unique_id))
        crontab.extend(additional_crontab)
        crontab.append(crontab_end_comment(unique_id))

    return crontab
266881
private function getCronTimestamp(string $cron_id): ?int
    {
        $items = $this->client->zscore(self::CRON_QUEUE_NAME, $cron_id);

        if (empty($items)) {
            return null;
        }

        return (int)$items[0];
    }
151439
private String getApiId(Api api) {
        return getApiId(api.getOrganizationId(), api.getApiId(), api.getVersion());
    }