Created
June 16, 2016 18:40
-
-
Save keithmccammon/977638c9eb91ba3ecc3b177083b9c332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Given a sensor ID and a file path, delete the file. This performs no logging | |
and returns no status. It is generally unhelpful and not a template upon which | |
you want to build. But if the file is present and not locked it will be | |
destroyed :) | |
""" | |
import argparse | |
import sys | |
from cbapi.response import CbEnterpriseResponseAPI | |
from cbapi.response.models import Sensor | |
from cbapi.response.live_response_api import LiveResponseSession | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--profile", type=str, action="store", | |
help="The credentials.response profile to use.") | |
parser.add_argument("sensorid", type=int, action="store", | |
help="The sensor to which we should connect.") | |
parser.add_argument("filepath", type=str, action="store", | |
help="The file to delete.") | |
args = parser.parse_args() | |
if args.profile: | |
cb = CbEnterpriseResponseAPI(profile=args.profile) | |
else: | |
cb = CbEnterpriseResponseAPI() | |
lr = cb.live_response.request_session(args.sensorid) | |
lr.delete_file(args.filepath) | |
lr.close() | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment