Gets the base details from the CloudWatch Event.
15051
def get_historical_base_info(event):
    """"""
    data = {
        'principalId': get_principal(event),
        'userIdentity': get_user_identity(event),
        'accountId': event['account'],
        'userAgent': event['detail'].get('userAgent'),
        'sourceIpAddress': event['detail'].get('sourceIPAddress'),
        'requestParameters': event['detail'].get('requestParameters')
    }

    if event['detail'].get('eventTime'):
        data['eventTime'] = event['detail']['eventTime']

    if event['detail'].get('eventSource'):
        data['eventSource'] = event['detail']['eventSource']

    if event['detail'].get('eventName'):
        data['eventName'] = event['detail']['eventName']

    return data
474417
def _return_base_data(self, url, container, container_object=None,
                          container_headers=None, object_headers=None):
        
        headers = self.job_args['base_headers']
        headers.update({'X-Auth-Token': self.job_args['os_token']})

        _container_uri = url.geturl().rstrip('/')

        if container:
            _container_uri = '%s/%s' % (
                _container_uri, cloud_utils.quoter(container)
            )

        if container_object:
            _container_uri = '%s/%s' % (
                _container_uri, cloud_utils.quoter(container_object)
            )

        if object_headers:
            headers.update(object_headers)

        if container_headers:
            headers.update(container_headers)

        return headers, urlparse.urlparse(_container_uri)
1079828
def fetch_events(cursor, config, account_name):
    """"""
    query = config['indexer'].get('query',
        'select * from events where user_agent glob \'*CloudCustodian*\'')

    for event in cursor.execute(query):
        event['account'] = account_name
        event['_index'] = config['indexer']['idx_name']
        event['_type'] = config['indexer'].get('idx_type', 'traildb')
        yield event
313172
def output_deployment_summary(awsclient, deployment_id):
    
    log.info('\ndeployment summary:')
    log.info('%-22s %-12s %s', 'Instance ID', 'Status', 'Most recent event')
    for instance_id in _list_deployment_instances(awsclient, deployment_id):
        status, last_event = \
            _get_deployment_instance_summary(awsclient, deployment_id, instance_id)
        log.info(Fore.MAGENTA + '%-22s' + Fore.RESET + ' %-12s %s',
                 instance_id, status, last_event)
651440
function getBaseInfo() {
        // get base from current script file path
        // notice: timestamp
        var scripts = doc.getElementsByTagName('script'),
            i,
            info;

        for (i = scripts.length - 1; i >= 0; i--) {
            if ((info = getBaseInfoFromOneScript(scripts[i]))) {
                return info;
            }
        }

        var msg = 'must load kissy by file name in browser environment: ' +
            'seed-debug.js or seed.js loader.js or loader-debug.js';

        S.log(msg, 'error');
        return null;
    }
539587
def get_data(conn_objs, providers):
    """"""
    cld_svc_map = {"aws": nodes_aws,
                   "azure": nodes_az,
                   "gcp": nodes_gcp,
                   "alicloud": nodes_ali}
    sys.stdout.write("\rCollecting Info:  ")
    sys.stdout.flush()
    busy_obj = busy_disp_on()
    collec_fn = [[cld_svc_map[x.rstrip('1234567890')], conn_objs[x]]
                 for x in providers]
    ngroup = Group()
    node_list = []
    node_list = ngroup.map(get_nodes, collec_fn)
    ngroup.join()
    busy_disp_off(dobj=busy_obj)
    sys.stdout.write("\r                                                 \r")
    sys.stdout.write("\033[?25h")  # cursor back on
    sys.stdout.flush()
    return node_list
642544
def get_event_data(self, section):
        
        event_group = '{}/BaseCalled_{}'.format(self.group_name, section)
        data = self.handle.get_analysis_dataset(event_group, 'Events')
        return data
1034123
def capture_update_records(records):
    """"""
    for record in records:
        data = cloudwatch.get_historical_base_info(record)
        vpc = describe_vpc(record)

        if len(vpc) > 1:
            raise Exception(f'[X] Multiple vpcs found. Record: {record}')

        if not vpc:
            LOG.warning(f'[?] No vpc information found. Record: {record}')
            continue

        vpc = vpc[0]

        # determine event data for vpc
        LOG.debug(f'Processing vpc. VPC: {vpc}')
        data.update({
            'VpcId': vpc.get('VpcId'),
            'arn': get_arn(vpc['VpcId'], cloudwatch.get_region(record), data['accountId']),
            'configuration': vpc,
            'State': vpc.get('State'),
            'IsDefault': vpc.get('IsDefault'),
            'CidrBlock': vpc.get('CidrBlock'),
            'Name': get_vpc_name(vpc),
            'Region': cloudwatch.get_region(record),
            'version': VERSION
        })

        data['Tags'] = pull_tag_dict(vpc)

        LOG.debug(f'[+] Writing DynamoDB Record. Records: {data}')

        current_revision = CurrentVPCModel(**data)
        current_revision.save()
463236
def _get_base():
        
        try:
            name, _aliaslist, _addresslist = socket.gethostbyname_ex('deploy')
        except socket.gaierror:
            name = 'deploy'
        fallback = 'https://{name}/'.format(name=name)
        return os.environ.get('VELOCIRAPTOR_URL', fallback)
1102497
def on_value_event(self, event):
    
    if not event.summary.value:
      logger.info('The summary of the event lacks a value.')
      return None

    # The node name property in the event proto is actually a watch key, which
    # is a concatenation of several pieces of data.
    watch_key = event.summary.value[0].node_name
    tensor_value = debug_data.load_tensor_from_event(event)
    device_name = _extract_device_name_from_event(event)
    node_name, output_slot, debug_op = (
        event.summary.value[0].node_name.split(':'))
    maybe_base_expanded_node_name = (
        self._run_states.get_maybe_base_expanded_node_name(node_name,
                                                           self._run_key,
                                                           device_name))
    self._tensor_store.add(watch_key, tensor_value)
    self._outgoing_channel.put(_comm_tensor_data(
        device_name, node_name, maybe_base_expanded_node_name, output_slot,
        debug_op, tensor_value, event.wall_time))

    logger.info('on_value_event(): waiting for client ack (tensors)...')
    self._incoming_channel.get()
    logger.info('on_value_event(): client ack received (tensor).')

    # Determine if the particular debug watch key is in the current list of
    # breakpoints. If it is, send an EventReply() to unblock the debug op.
    if self._is_debug_node_in_breakpoints(event.summary.value[0].node_name):
      logger.info('Sending empty EventReply for breakpoint: %s',
                      event.summary.value[0].node_name)
      # TODO(cais): Support receiving and sending tensor value from front-end.
      return debug_service_pb2.EventReply()
    return None
581244
def get(self):
        """"""
        d = self.getBaseRevision()
        d.addCallback(self.getPatch)
        d.addCallback(self.done)
        return d
138652
def detail(callback=None, path=None, method=Method.GET, resource=None, tags=None, summary="Get specified resource.",
           middleware=None):
    # type: (Callable, Path, Methods, Resource, Tags, str, List[Any]) -> Operation
    
    def inner(c):
        op = Operation(c, path or PathParam('{key_field}'), method, resource, tags, summary, middleware)
        op.responses.add(Response(HTTPStatus.OK, "Get a {name}"))
        op.responses.add(Response(HTTPStatus.NOT_FOUND, "Not found", Error))
        return op
    return inner(callback) if callback else inner
4493
def event_detail(self, event_detail):
        
        if event_detail is not None:
            if isinstance(event_detail, str):
                self._event_detail = event_detail
            else:
                try:
                    for key, val in event_detail.items():
                        if isinstance(val, date):
                            event_detail[key] = str(val)
                    self._event_detail = json.dumps(event_detail)
                except TypeError:
                    raise TypeError('Passed in event detail object are not json serializable.Please check the format')
810538
def get_context(request, context=None):
    """"""
    if context is None:
        context = {}

    network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})

    context['launch_instance_allowed'] = policy.check(
        (("compute", "os_compute_api:servers:create"),), request)
    context['instance_quota_exceeded'] = _quota_exceeded(request, 'instances')
    context['create_network_allowed'] = policy.check(
        (("network", "create_network"),), request)
    context['network_quota_exceeded'] = _quota_exceeded(request, 'network')
    context['create_router_allowed'] = (
        network_config.get('enable_router', True) and
        policy.check((("network", "create_router"),), request))
    context['router_quota_exceeded'] = _quota_exceeded(request, 'router')
    context['console_type'] = getattr(settings, 'CONSOLE_TYPE', 'AUTO')
    context['show_ng_launch'] = (
        base.is_service_enabled(request, 'compute') and
        getattr(settings, 'LAUNCH_INSTANCE_NG_ENABLED', True))
    context['show_legacy_launch'] = (
        base.is_service_enabled(request, 'compute') and
        getattr(settings, 'LAUNCH_INSTANCE_LEGACY_ENABLED', False))
    return context
766628
def get_default_properties(event)
      client = event['client']
      check = event['check']
      {
        server_name: client['name'],
        server_ip: client['address'],
        subscriptions: client['subscriptions'].join(';'),
        environment: client['environment'],
        check_name: check['name'],
        check_command: check['command'],
        check_output: check['output'],
        timestamp: event['timestamp'].inspect
      }
    end
648668
def get_lambda_runtime_info(context):
    '''
    
    '''

    runtime_info = {
        'remaining_time': context.get_remaining_time_in_millis(),
        'function_name': context.function_name,
        'function_version': context.function_version,
        'invoked_function_arn': context.invoked_function_arn,
        'memory_limit': context.memory_limit_in_mb,
        'aws_request_id': context.aws_request_id,
        'log_group_name': context.log_group_name,
        'log_stream_name': context.log_stream_name
    }

    return runtime_info
874357
def get_metrics(awsclient, name):
    
    metrics = ['Duration', 'Errors', 'Invocations', 'Throttles']
    client_cw = awsclient.get_client('cloudwatch')
    for metric in metrics:
        response = client_cw.get_metric_statistics(
            Namespace='AWS/Lambda',
            MetricName=metric,
            Dimensions=[
                {
                    'Name': 'FunctionName',
                    'Value': name
                },
            ],
            # StartTime=datetime.now() + timedelta(days=-1),
            # EndTime=datetime.now(),
            StartTime=maya.now().subtract(days=1).datetime(),
            EndTime=maya.now().datetime(),
            Period=3600,
            Statistics=[
                'Sum',
            ],
            Unit=unit(metric)
        )
        log.info('\t%s %s' % (metric,
                           repr(aggregate_datapoints(response['Datapoints']))))
    return 0