def _k8s_object_to_st2_trigger(self, k8s_object):
        # Define some variables
        try:
            resource_type = k8s_object['type']
            object_kind = k8s_object['object']['kind']
            name = k8s_object['object']['metadata']['name']
            namespace = k8s_object['object']['metadata']['namespace']
            uid = k8s_object['object']['metadata']['uid']
            labels_data = k8s_object['object']['metadata']['labels']
        except __HOLE__:
            msg = 'One of "type", "kind", "name", "namespace" or "uid" or "labels" ' + \
                  'do not exist in the object. Incoming object=%s' % k8s_object
            self._log.exception(msg)
            raise
        else:
            payload = self._build_a_trigger(resource_type=resource_type, name=name,
                                    labels=labels_data, namespace=namespace,
                                    object_kind=object_kind, uid=uid)
            self._log.debug('Trigger payload: %s.' % payload)
            return payload
dataset/ETHPy150Open StackStorm/st2contrib/packs/kubernetes/sensors/third_party_resource.py/ThirdPartyResource._k8s_object_to_st2_trigger