# Path: ndscheduler/corescheduler/job.py
# class JobBase:
#     def __init__(self, job_id, execution_id):
#     def create_test_instance(cls):
#     def get_scheduled_description(cls):
#     def get_scheduled_error_description(cls):
#     def get_running_description(cls):
#     def get_failed_description(cls):
#     def get_succeeded_description(cls, result=None):
#     def get_scheduled_error_result(cls):
#     def get_failed_result(cls):
#     def meta_info(cls):
#     def run_job(cls, job_id, execution_id, *args, **kwargs):
#     def run(self, *args, **kwargs):


import logging
import json
import os
import socket
import requests
from ndscheduler.corescheduler import job
            #
            # You can get this url by adding an incoming webhook:
            # https://nextdoor.slack.com/apps/new/A0F7XDUAZ-incoming-webhooks
            url = os.environ['SIMPLE_SCHEDULER_SLACK_URL']
        except KeyError:
            logger.error('Environment variable SIMPLE_SCHEDULER_SLACK_URL is not specified. '
                         'So we cannot send slack message.')
            raise KeyError('You have to set Environment variable SIMPLE_SCHEDULER_SLACK_URL first.')
        else:
            session = requests.Session()
            adapter = requests.adapters.HTTPAdapter(max_retries=self.MAX_RETRIES)
            session.mount('http://', adapter)
            session.mount('https://', adapter)

            message += ' // `sent from %s`' % socket.gethostname()
            payload = {
                'channel': channel,
                'username': name,
                'text': message,
                'link_names': 1,
                "mrkdwn": 1,
                'icon_emoji': icon_emoji
            }
            session.request('POST', url, timeout=self.TIMEOUT,
                            headers={'content-type': 'application/json'},
                            data=json.dumps(payload))


if __name__ == "__main__":
    # You can easily test this job here

# Path: ndscheduler/corescheduler/job.py
# class JobBase:
#     def __init__(self, job_id, execution_id):
#     def create_test_instance(cls):
#     def get_scheduled_description(cls):
#     def get_scheduled_error_description(cls):
#     def get_running_description(cls):
#     def get_failed_description(cls):
#     def get_succeeded_description(cls, result=None):
#     def get_scheduled_error_result(cls):
#     def get_failed_result(cls):
#     def meta_info(cls):
#     def run_job(cls, job_id, execution_id, *args, **kwargs):
#     def run(self, *args, **kwargs):


# Path: simple_scheduler/jobs/slack_job.py
import logging
import json
import os
import socket
import requests
from ndscheduler.corescheduler import job

            #
            # You can get this url by adding an incoming webhook:
            # https://nextdoor.slack.com/apps/new/A0F7XDUAZ-incoming-webhooks
            url = os.environ['SIMPLE_SCHEDULER_SLACK_URL']
        except KeyError:
            logger.error('Environment variable SIMPLE_SCHEDULER_SLACK_URL is not specified. '
                         'So we cannot send slack message.')
            raise KeyError('You have to set Environment variable SIMPLE_SCHEDULER_SLACK_URL first.')
        else:
            session = requests.Session()
            adapter = requests.adapters.HTTPAdapter(max_retries=self.MAX_RETRIES)
            session.mount('http://', adapter)
            session.mount('https://', adapter)

            message += ' // `sent from %s`' % socket.gethostname()
            payload = {
                'channel': channel,
                'username': name,
                'text': message,
                'link_names': 1,
                "mrkdwn": 1,
                'icon_emoji': icon_emoji
            }
            session.request('POST', url, timeout=self.TIMEOUT,
                            headers={'content-type': 'application/json'},
                            data=json.dumps(payload))


if __name__ == "__main__":
    # You can easily test this job here

    job = SlackJob.create_test_instance()