Skip to content

Commit

Permalink
fix for get_event_series_list and sample app for it
Browse files Browse the repository at this point in the history
  • Loading branch information
guirava committed Sep 23, 2024
1 parent bd477e6 commit 1ae6477
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
8 changes: 3 additions & 5 deletions rubrik_polaris/common/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,9 @@ def get_event_series_list(self, object_type=[], status=[], activity_type=[], sev
"lastActivityStatus": status,
"lastActivityType": activity_type,
"severity": severity,
"cluster": {
"id": cluster_ids,
},
"lastUpdated_gt": start_time,
"lastUpdated_lt": end_time,
"clusterId": cluster_ids,
"lastUpdatedTimeGt": start_time,
"lastUpdatedTimeLt": end_time,
"objectName": ""
}
}
Expand Down
60 changes: 29 additions & 31 deletions sample/polaris_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@
import sys
from rubrik_polaris.rubrik_polaris import PolarisClient


pp = pprint.PrettyPrinter(indent=4)

parser = argparse.ArgumentParser()
parser.add_argument('-p', '--password', dest='password', help="Polaris Password", default=None)
parser.add_argument('-u', '--username', dest='username', help="Polaris UserName", default=None)
parser.add_argument('-d', '--domain', dest='domain', help="Polaris Domain", default=None)
parser.add_argument('-k', '--keyfile', dest='json_keyfile', help="JSON Keyfile", default=None)
parser.add_argument('-r', '--root', dest='root_domain', help="Polaris Root Domain", default=None)
parser.add_argument('--insecure', help='Deactivate SSL Verification', action="store_true")

args = parser.parse_args()

try:

### Instantiate with json keyfile
if args.json_keyfile:
rubrik = PolarisClient(json_keyfile=args.json_keyfile, insecure=args.insecure)
else:
### Instantiate with username/password
rubrik = PolarisClient(domain=args.domain, username=args.username, password=args.password, root_domain=args.root_domain,
insecure=args.insecure)

except Exception as err:
print(err)
sys.exit(1)
def build_arg_parser():
"""Parse command-line arguments for Polaris client."""
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--password', dest='password', help="Polaris Password", default=None)
parser.add_argument('-u', '--username', dest='username', help="Polaris UserName", default=None)
parser.add_argument('-d', '--domain', dest='domain', help="Polaris Domain", default=None)
parser.add_argument('-k', '--keyfile', dest='json_keyfile', help="JSON Keyfile", default=None)
parser.add_argument('-r', '--root', dest='root_domain', help="Polaris Root Domain", default=None)
parser.add_argument('--insecure', help='Deactivate SSL Verification', action="store_true")

return parser

def create_polaris_client(args):
"""Create and return a PolarisClient based on provided arguments."""
try:
if args.json_keyfile:
rubrik = PolarisClient(json_keyfile=args.json_keyfile, insecure=args.insecure)
else:
rubrik = PolarisClient(domain=args.domain, username=args.username, password=args.password,
root_domain=args.root_domain, insecure=args.insecure)
return rubrik

except Exception as err:
print(f"Error creating PolarisClient: {err}")
sys.exit(1)

if __name__ == "__main__":
args = build_arg_parser().parse_args()
rubrik = create_polaris_client(args)

### Get GCP SA
# pp.pprint(rubrik.get_account_gcp_default_sa())
Expand Down Expand Up @@ -121,13 +126,6 @@
# pp.pprint(rubrik.get_accounts_azure())
# pp.pprint(rubrik.update_account_aws())

### Event interface
# end_time = datetime.datetime.now().isoformat()
# start_time = (datetime.datetime.now() - datetime.timedelta(days=1)).isoformat()
# todays_failed_events = rubrik.get_event_series_list(cluster_ids=['603109f2-eb30-4da8-9389-911d66abb524'], status=["Failure"], start_time=start_time, end_time=end_time)
# todays_failed_events = rubrik.get_event_series_list(start_time=start_time, end_time=end_time)
# print("Returned events : {}".format(len(todays_failed_events)))

### Basic event summaries
# summary = {}
# for event in todays_failed_events:
Expand Down

0 comments on commit 1ae6477

Please sign in to comment.