Esempio n. 1
0
def delete_policies(sdsecure: SdSecureClient, ids: List):
    for id in ids:
        ok, res = sdsecure.delete_policy_id(id=id)
        if not ok:
            print(f"error deleting the policy {id}: {res}")
            return EXIT_CODES.ERR_DELETING_POLICY
        print(f"Deleted policy {id}")
    return EXIT_CODES.OK
Esempio n. 2
0
#
# Parse arguments
#
if len(sys.argv) != 2:
    usage()

sdc_token = sys.argv[1]

#
# Instantiate the SDC client
#
sdclient = SdSecureClient(sdc_token, 'https://secure.sysdig.com')

# Get a list of policyIds
ok, res = sdclient.list_policies()
policies = []

if not ok:
    print(res)
    sys.exit(1)
else:
    policies = res

for policy in policies:
    print("deleting policy: " + str(policy['id']))
    ok, res = sdclient.delete_policy_id(policy['id'])
    if not ok:
        print(res)
        sys.exit(1)
Esempio n. 3
0
        id = arg
    elif opt in ("-n", "--name"):
        name = arg

if len(id) + len(name) == 0:
    usage()

if len(args) < 1:
    usage()

sdc_token = args[0]

#
# Instantiate the SDC client
#
sdclient = SdSecureClient(sdc_token, 'https://secure.sysdig.com')

if len(id) > 0:
    ok, res = sdclient.delete_policy_id(id)
else:
    ok, res = sdclient.delete_policy_name(name)

#
# Return the result
#
if ok:
    print(json.dumps(res, indent=2))
else:
    print(res)
    sys.exit(1)