71 lines
1.8 KiB
Python
Executable File
71 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from rsc import RSCAuth, RSCGraphQL
|
|
|
|
|
|
MUTATION = """
|
|
mutation CreateCloudNativeRcvAwsStorageSettingMutation($input: CreateCloudNativeRcvAwsStorageSettingInput!) {
|
|
createCloudNativeRcvAwsStorageSetting(input: $input) {
|
|
targetMapping {
|
|
id
|
|
name
|
|
__typename
|
|
}
|
|
__typename
|
|
}
|
|
}
|
|
"""
|
|
|
|
|
|
def create_rcv_archive_location(name, config_file):
|
|
auth = RSCAuth(config_file=config_file)
|
|
gql = RSCGraphQL(auth)
|
|
|
|
variables = {
|
|
"input": {
|
|
"name": name,
|
|
"region": "UK_SOUTH",
|
|
"cloudNativeLocTemplateType": "SPECIFIC_REGION",
|
|
"tier": "BACKUP",
|
|
"redundancy": "SINGLE_ZONE",
|
|
}
|
|
}
|
|
|
|
print("Creating RCV archive location with input:")
|
|
print(json.dumps(variables["input"], indent=2))
|
|
print("Submitting GraphQL mutation and waiting for response...")
|
|
|
|
response = gql.query(MUTATION, variables)
|
|
result = response["data"]["createCloudNativeRcvAwsStorageSetting"]["targetMapping"]
|
|
|
|
print("Created RCV archive location successfully:")
|
|
print(json.dumps(result, indent=2))
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser(
|
|
description="Create a Cloud Native RCV AWS archive location in Rubrik Security Cloud"
|
|
)
|
|
parser.add_argument("name", help="Archive location name")
|
|
parser.add_argument(
|
|
"--config-file",
|
|
default="rsc.json",
|
|
help="Path to config JSON file (default: rsc.json)",
|
|
)
|
|
return parser.parse_args()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = parse_args()
|
|
try:
|
|
create_rcv_archive_location(
|
|
name=args.name,
|
|
config_file=args.config_file,
|
|
)
|
|
except Exception as e:
|
|
print(f"Error: {e}", file=sys.stderr)
|
|
sys.exit(1)
|