<commit_before>"""A job to send a HTTP GET periodically."""

import logging
import requests

from ndscheduler import job

logger = logging.getLogger(__name__)


class CurlJob(job.JobBase):
    TIMEOUT = 10

    @classmethod
    def meta_info(cls):
        return {
            'job_class_string': '%s.%s' % (cls.__module__, cls.__name__),
            'notes': ('This sends a HTTP GET to a particular URL'),
            'arguments': [
                # url
                {'type': 'string', 'description': 'What URL you want to make a GET call?'},
            ],
            'example_arguments': ('["http://localhost:8888/api/v1/jobs"]')
        }

    def run(self, url, *args, **kwargs):
        print 'Calling GET on url: %s' % (url)

        session = requests.Session()
        session.request('GET',
                        url,
                        timeout=self.TIMEOUT,
                        headers=None,
                        data=None)


if __name__ == "__main__":
    job = CurlJob.create_test_instance()
    job.run('http://localhost:888/api/v1/jobs')<commit_msg>Add delete example in CURL job<commit_after>"""A job to send a HTTP GET periodically."""

import logging
import requests

from ndscheduler import job

logger = logging.getLogger(__name__)


class CurlJob(job.JobBase):
    TIMEOUT = 10

    @classmethod
    def meta_info(cls):
        return {
            'job_class_string': '%s.%s' % (cls.__module__, cls.__name__),
            'notes': ('This sends a HTTP request to a particular URL'),
            'arguments': [
                # url
                {'type': 'string', 'description': 'What URL you want to make a GET call?'},
                # Request Type
                {'type': 'string', 'description': 'What request type do you want? '
                                                  '(currently supported: GET/DELETE)'},

            ],
            'example_arguments': ('["http://localhost:8888/api/v1/jobs", "GET"]'
                                  '["http://localhost:8888/api/v1/jobs/ba12e", "DELETE"]')
        }

    def run(self, url, request_type,  *args, **kwargs):
        print 'Calling GET on url: %s' % (url)

        session = requests.Session()
        result = session.request(request_type,
                                 url,
                                 timeout=self.TIMEOUT,
                                 headers=None,
                                 data=None)
        print(result.text)


if __name__ == "__main__":
    job = CurlJob.create_test_instance()
    job.run('http://localhost:888/api/v1/jobs')
{'fraction_non_alphanumeric': 0.12742060418280401, 'fraction_numerical': 0.011231603408210689, 'mean_word_length': 1.7218124341412013, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648969', 'n_tokens_mistral': 741, 'n_tokens_neox': 698, 'n_words': 186}