Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Add --delete option to push command #9

Merged
merged 2 commits into from
Feb 28, 2017

Conversation

AMeng
Copy link
Contributor

@AMeng AMeng commented Feb 13, 2017

The sync command is used to sync remote monitor state with local monitor state. This means creating, updating, and deleting monitors as needed.

Fixes #8 and, assuming all monitors are tracked in code, #7 as well.

@thesamet
Copy link
Contributor

Thanks for putting the PR together. I prefer this behavior to be implemented as a flag to push. Can it be dogpush --delete_untracked ?

@AMeng AMeng changed the title Add sync command Add --delete option to push command Feb 13, 2017
@AMeng
Copy link
Contributor Author

AMeng commented Feb 13, 2017

Delete output:

$ dogpush push --delete
Pushing 3 new monitors.
Updating 1 modified monitors.
Deleting 2 untracked monitors.

Updated help output:

$ dogpush --help
usage: dogpush [-h] [-c CONFIG] {init,push,diff,mute} ...

positional arguments:
  {init,push,diff,mute}
                        sub-command help
    init                Init new alerts file
    push                Push monitors to DataDog.
    diff                Show diff between local monitors and DataDog
    mute                Mute alerts based on their `mute_when` key

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        configuration file to load (default: ./config.yaml)

Updated push help output:

$ dogpush push --help
usage: dogpush push [-h] [-d]

optional arguments:
  -h, --help    show this help message and exit
  -d, --delete  Delete untracked monitors.

@AMeng
Copy link
Contributor Author

AMeng commented Feb 13, 2017

@thesamet changed to a flag.

parser_push.set_defaults(command=command_init)


parser_push = subparsers.add_parser(
'push', help='push monitors to datadog')
'push', help='Push monitors to DataDog.')
parser_push.add_argument('-d', '--delete', action='store_true',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete_untracked

for name in changed:
datadog.api.Monitor.update(
remote_monitors[name]['id'],
**_prepare_monitor(local_monitors[name]))

if args.delete:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

@thesamet
Copy link
Contributor

@nandrienko Reviewed this. Please merge when convenient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants