def main(cmd_line_args): cappella_api = CapellaAPI() if cmd_line_args.debug: capella_logging('debug') cappella_api.set_logging_level('DEBUG') else: capella_logging('info') # Check Capella API status if cappella_api.api_status().status_code == 200: capella_api_response = cappella_api.create_project( dict(name=cmd_line_args.projectName)) if capella_api_response.status_code == 201: # Our project was created print("Created project " + cmd_line_args.projectName + " with ID of " + capella_api_response.json()['id']) else: print("Failed to create project " + cmd_line_args.project) print("Capella API returned " + str(capella_api_response.status_code)) print("Full error message") print(capella_api_response.json()["message"]) else: print("Check Capella API is up.")
def create_project(pod, tenant, name): capella_api = CapellaAPI(pod.url_public, tenant.api_secret_key, tenant.api_access_key, tenant.user, tenant.pwd) resp = capella_api.create_project(tenant.id, name) if resp.status_code != 201: raise Exception("Creating capella project failed: {}".format( resp.content)) project_id = json.loads(resp.content).get("id") tenant.project_id = project_id CapellaUtils.log.info("Project ID: {}".format(project_id))