Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description="Interact with the Datadog API",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--config', help="location of your dogrc file (default ~/.dogrc)",
                        default=os.path.expanduser('~/.dogrc'))
    parser.add_argument('--api-key', help="your API key, from "
                        "https://app.datadoghq.com/account/settings#api. "
                        "You can also set the environment variables DATADOG_API_KEY or DD_API_KEY",
                        dest='api_key', default=os.environ.get('DATADOG_API_KEY', os.environ.get('DD_API_KEY')))
    parser.add_argument('--application-key', help="your Application key, from "
                        "https://app.datadoghq.com/account/settings#api. "
                        "You can also set the environment variables DATADOG_APP_KEY or DD_APP_KEY",
                        dest='app_key', default=os.environ.get('DATADOG_APP_KEY', os.environ.get('DD_APP_KEY')))
    parser.add_argument('--pretty', help="pretty-print output (suitable for human consumption, "
                        "less useful for scripting)", dest='format',
                        action='store_const', const='pretty')
    parser.add_argument('--raw', help="raw JSON as returned by the HTTP service",
                        dest='format', action='store_const', const='raw')
    parser.add_argument('--timeout', help="time to wait in seconds before timing"
                        " out an API call (default 10)", default=10, type=int)
    parser.add_argument('-v', '--version', help='Dog API version', action='version',
                        version='%(prog)s {0}'.format(get_version()))

    config = DogshellConfig()

    # Set up subparsers for each service
    subparsers = parser.add_subparsers(title='Modes', dest='mode')
    subparsers.required = True

    CommentClient.setup_parser(subparsers)
    SearchClient.setup_parser(subparsers)
    MetricClient.setup_parser(subparsers)
    TagClient.setup_parser(subparsers)
    EventClient.setup_parser(subparsers)
    MonitorClient.setup_parser(subparsers)
    TimeboardClient.setup_parser(subparsers)
    DashboardClient.setup_parser(subparsers)
    ScreenboardClient.setup_parser(subparsers)
    DashboardListClient.setup_parser(subparsers)
    HostClient.setup_parser(subparsers)
    DowntimeClient.setup_parser(subparsers)
    ServiceCheckClient.setup_parser(subparsers)
    ServiceLevelObjectiveClient.setup_parser(subparsers)

    args = parser.parse_args()
    config.load(args.config, args.api_key, args.app_key)

    # Initialize datadog.api package
    initialize(**config)

    args.func(args)
Exemple #2
0
def main():

    parser = argparse.ArgumentParser(description="Interact with the Datadog API",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--config', help="location of your dogrc file (default ~/.dogrc)",
                        default=os.path.expanduser('~/.dogrc'))
    parser.add_argument('--api-key', help="your API key, from "
                        "https://app.datadoghq.com/account/settings#api",
                        dest='api_key', default=None)
    parser.add_argument('--application-key', help="your Application key, from "
                        "https://app.datadoghq.com/account/settings#api",
                        dest='app_key', default=None)
    parser.add_argument('--pretty', help="pretty-print output (suitable for human consumption, "
                        "less useful for scripting)", dest='format',
                        action='store_const', const='pretty')
    parser.add_argument('--raw', help="raw JSON as returned by the HTTP service",
                        dest='format', action='store_const', const='raw')
    parser.add_argument('--timeout', help="time to wait in seconds before timing"
                        " out an API call (default 10)", default=10, type=int)
    parser.add_argument('-v', '--version', help='Dog API version', action='version',
                        version='%(prog)s {version}'
                        .format(version=pkg.require("datadog")[0].version))

    config = DogshellConfig()

    # Set up subparsers for each service

    subparsers = parser.add_subparsers(title='Modes', dest='mode')
    subparsers.required = True

    CommentClient.setup_parser(subparsers)
    SearchClient.setup_parser(subparsers)
    MetricClient.setup_parser(subparsers)
    TagClient.setup_parser(subparsers)
    EventClient.setup_parser(subparsers)
    MonitorClient.setup_parser(subparsers)
    TimeboardClient.setup_parser(subparsers)
    ScreenboardClient.setup_parser(subparsers)
    HostClient.setup_parser(subparsers)
    DowntimeClient.setup_parser(subparsers)
    ServiceCheckClient.setup_parser(subparsers)

    args = parser.parse_args()
    config.load(args.config, args.api_key, args.app_key)

    # Initialize datadog.api package
    initialize(**config)

    args.func(args)
Exemple #3
0
def main():
    if sys.argv[0].endswith("dog"):
        warnings.warn("dog is pending deprecation. Please use dogshell instead.", PendingDeprecationWarning)

    parser = argparse.ArgumentParser(
        description="Interact with the Datadog API", formatter_class=argparse.ArgumentDefaultsHelpFormatter
    )
    parser.add_argument(
        "--config", help="location of your dogrc file (default ~/.dogrc)", default=os.path.expanduser("~/.dogrc")
    )
    parser.add_argument(
        "--api-key",
        help="your API key, from "
        "https://app.datadoghq.com/account/settings#api. "
        "You can also set the environment variables DATADOG_API_KEY or DD_API_KEY",
        dest="api_key",
        default=os.environ.get("DATADOG_API_KEY", os.environ.get("DD_API_KEY")),
    )
    parser.add_argument(
        "--application-key",
        help="your Application key, from "
        "https://app.datadoghq.com/account/settings#api. "
        "You can also set the environment variables DATADOG_APP_KEY or DD_APP_KEY",
        dest="app_key",
        default=os.environ.get("DATADOG_APP_KEY", os.environ.get("DD_APP_KEY")),
    )
    parser.add_argument(
        "--pretty",
        help="pretty-print output (suitable for human consumption, " "less useful for scripting)",
        dest="format",
        action="store_const",
        const="pretty",
    )
    parser.add_argument(
        "--raw", help="raw JSON as returned by the HTTP service", dest="format", action="store_const", const="raw"
    )
    parser.add_argument(
        "--timeout", help="time to wait in seconds before timing" " out an API call (default 10)", default=10, type=int
    )
    parser.add_argument(
        "-v", "--version", help="Dog API version", action="version", version="%(prog)s {0}".format(__version__)
    )

    config = DogshellConfig()

    # Set up subparsers for each service
    subparsers = parser.add_subparsers(title="Modes", dest="mode")
    subparsers.required = True

    CommentClient.setup_parser(subparsers)
    SearchClient.setup_parser(subparsers)
    MetricClient.setup_parser(subparsers)
    TagClient.setup_parser(subparsers)
    EventClient.setup_parser(subparsers)
    MonitorClient.setup_parser(subparsers)
    TimeboardClient.setup_parser(subparsers)
    DashboardClient.setup_parser(subparsers)
    ScreenboardClient.setup_parser(subparsers)
    DashboardListClient.setup_parser(subparsers)
    HostClient.setup_parser(subparsers)
    DowntimeClient.setup_parser(subparsers)
    ServiceCheckClient.setup_parser(subparsers)
    ServiceLevelObjectiveClient.setup_parser(subparsers)

    args = parser.parse_args()
    config.load(args.config, args.api_key, args.app_key)

    # Initialize datadog.api package
    initialize(**config)

    args.func(args)