Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Syndeia Cloud 3.3 now has an official Python2/3 client to Intercax’s Syndeia Cloud v3.3 REST API.

Syndeia Cloud REST API - Python SDK

Official Python2/3 client to Intercax’s Syndeia Cloud v3.3 REST API.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 3.3

  • Package version: 3.3.0.2

  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements

  • (Ana)conda Package Manager

  • Python 2.7 and 3.4+ (natively or via Conda)

  • Connection details of Intercax Syndeia Cloud v3.3 server

  • Credentials to access Intercax Syndeia Cloud v3.3 server

Installation & Uninstallation

Currently only available via conda (wheel and egg can be made available upon request)

conda install

If you do not have the Conda package manager, first get it by installing Anaconda or Miniconda (see details here)

To install via a conda channel:

conda install syndeia_cloud_33x_client_sdk

To install into a specific environment:

conda install -name myenv syndeia_cloud_33x_client_sdk

To install from a local file (ie: if you downloaded the package directly):

conda install /some/path/syndeia_cloud_33x_client_sdk-3.3.0.2-py_0.tar.bz2  # ex: for v3.3.0.2, update as appropriate

conda uninstall

To uninstall the package:

conda uninstall syndeia_cloud_33x_client_sdk
conda clean -t # to ensure any old cached tarballs are cleared out

Usage

The general pattern is to:

  1. Instantiate the configuration (once) with the Syndeia Cloud URL, your username, and password (see STEPs 2-3 in Quickstart below)

  2. Instantiate the API client using the configuration from previous step (see STEP 4 in Quickstart below)

  3. Use the API client object to instantiate other main API classes, such as:

    • AuthAPI for sign-in and other authentication calls (see STEP 5 in Quickstart below).

    • UserAPI for create, read, update, delete operations on users

    • RepositoryAPI for create, read, update, delete operations on repositories (see STEP 6 in Quickstart below)

    • ContainerAPI for create, read, update, delete operations on containers (see STEP 7 in Quickstart below)

    • ArtifactAPI for create, read, update, delete operations on artifacts (see STEP 8 in Quickstart below)

    • RelationAPI for create, read, update, delete operations on relations (see STEP 9 in Quickstart below)

(Strictly speaking, steps 6+ are optional but it will show you how to make sample calls to some of the core endpoint concepts, ie: Repositories, Containers, Artifacts, and Relations)

For more information on the Python API functions, see Documentation for API Endpoints and Documentation for Models.
For an interactive way to explore the REST API, see the Swagger UI at: http(s)://mySyndeiaCloudServer.domain.tld:port/docs/swagger-ui/index.html?url=/assets/swagger/swagger.json, ex: <https://mySyndeiaServer.domain.com:9443/docs/swagger-ui/index.html?url=/assets/swagger/swagger.json>

Usage in Jupyter Notebook

Jupyter Noterbook / Lab is an interactive computing environment spun off of iPython that allows one to execute a variety of languages in an interactive fashion for scientific computing & data analysis. The interactive environment is similar to the commercial product MATLAB.

To use the Syndeia Cloud python3 client SDK in Jupyter Notebook:

  1. Ensure that you have already installed the SDK (see conda install section above) & JupyterLab/Notebook (conda install jupyterlab or conda install notebook).

  2. Launch JupyterLab/Notebook (ex: via Anaconda-Navigator or the CLI) and open the provided example iPython Notebook file (syndeia_cloud_3.3.0_client_sdk_example.ipynb) from the accompanying syndeia_cloud_33x_client_sdk...-py_0_docs package:

  3. Edit the 3rd cell to specify your deployment’s Syndeia Cloud’s configuration.host and configuration.username values as described in the comments.

  4. Click in the side area of the editing area and select all cells via Command-A (on Mac) or CTRL-A (on Windows)

  5. Run the selected cells by hitting Shift-Enter.

  6. You will be prompted for your specified user’s password, enter it in.

  7. After submitting it, you should get results similar to the below for some of the cells ( (info) the exact results will differ depending on what data you have, if any, on the server)


    (lightbulb) If one of the outputs is too verbose, you can encapsulate results in a scrollable area by R-clicking the side area next to a cell and selecting Enable Scrolling for Outputs to make navigating the Jupyter notebook easier.

Authorization

  • Syndeia Cloud 3.3 currently supports Basic Auth + an LDAP(S) authentication provider

  • Syndeia Cloud 3.3 repositories currently support Basic + OAuth

UserSecurity

  • Type: API key

  • API key parameter name: X-Auth-Token

  • Location: HTTP header

Quickstart

# - STEP 1.  Import libs -------------------------
from __future__ import print_function
import time
import getpass
import uuid
import syndeia_cloud_33x_client_sdk
from syndeia_cloud_33x_client_sdk.rest import ApiException
from pprint import pprint

# - STEP 2.  Instantiate Configuration object (this is used to set server & credential details) -------------------------
configuration = syndeia_cloud_33x_client_sdk.Configuration()

# - STEP 3.  Set configuration object instance properties --------------------
# Note, if you are unsure of any of the below, contact your CAE Syndeia Cloud server admin 

# configuration.host = "http(s)://host.domain.tld:9000(HTTP)|9443(HTTPS)", ex:  
configuration.host = "<https://mySyndeiaCloudServer.domain.tld:9443"> # -or- "<http://mySyndeiaCloudServer.domain.tld:9000"> if using HTTP

# configuration.username = "username", for LDAP = LDAP "username", for Basic auth = your email address (usually)
configuration.username = "myUsername"

# configuration.password = getpass.getpass()|"myP4$$wD" (prompt for password) | (specify) 
configuration.password = getpass.getpass()

# TLS:  uncomment the below if server is using a self-signed cert, or it isn't in the trust store, or you want to skip SSL validation
# configuration.verify_ssl = False 

# - STEP 4.  Instantiate Syndeia REST ApiClient object with the configuration -----------------------------
api_client_instance = syndeia_cloud_33x_client_sdk.ApiClient(configuration)
# Now, given the api_client_instance, you can instiate any part of the API - AuthAPI, UserAPI, RepositoryAPI, etc.

# - STEP 5.  Authenticate ---------------------------------------------
# Instantiate AuthAPI object
auth_api_instance = syndeia_cloud_33x_client_sdk.AuthApi(api_client_instance)

# IF using LDAP, use the below:  
sign_in_provider_instance = syndeia_cloud_33x_client_sdk.models.SignInProvider(username = configuration.username, password = configuration.password)
authed_instance = auth_api_instance.authenticate_by_provider('LDAP', sign_in_provider_instance)

# ELSE, uncomment and use the below for Basic auth:   
# signin_instance = syndeia_cloud_33x_client_sdk.models.SignIn(username = configuration.username, password = configuration.password, remember_me = False)
# authed_instance = auth_api_instance.sign_in_user(signin_instance)

# grab returned (bearer) token and save in in the configuration object for subsequent requests
configuration.api_key['X-Auth-Token'] = authed_instance.resources.token

# - STEP 6A (optional).  Get all repositories ----------------------------
repository_api_instance = syndeia_cloud_33x_client_sdk.RepositoryApi(api_client_instance)

try:
    # Get all repositories
    repositories_response = repository_api_instance.get_repositories()
    pprint(repositories_response)
except ApiException as e:
    print("Exception when calling RepositoryApi->get_repositories: %s\n" % e)

# print number of repositories
num_repositories = len(repositories_response.resources)
print(num_repositories)

# for all repositories, print repository name (repository host)
for r in repositories_response.resources:
    print(r.name + " ( " + r.host + " ) ")

# - STEP 6B (optional).  Create a test repository ----------------------------
repository_api_instance = syndeia_cloud_33x_client_sdk.RepositoryApi(api_client_instance)
repository_create_instance = syndeia_cloud_33x_client_sdk.RepositoryCreate(gid = str(uuid.uuid4())[:11], 
                                                                       name = 'myRepo of Type Foo by ' + configuration.username, 
                                                                       host = '<https://myRepo.domain.com',> 
                                                                       type = {'name': 'Foo Type'}
                                                                      )

try:
    # Create a new repository
    repository_create_response = repository_api_instance.create_repository(repository_create_instance)
    pprint(repository_create_response)
except ApiException as e:
    print("Exception when calling RepositoryApi->create_repository: %s\n" % e)

# - STEP 7 (optional).  Get containers --------------------------------------
# Instantiate the ContainerAPI
container_api_instance = syndeia_cloud_33x_client_sdk.ContainerApi(api_client_instance)

try:
    container_response = container_api_instance.get_containers()
    print(container_response)
except ApiException as e:
    print("Exception when calling ContainerApi->get_containers: %s\n" % e)

# print number of containers   
num_containers = len(container_response.resources)
print(num_containers)

# print out container name (key)
for c in syndeia_containers:
    print(c.name + " (" + c.key + ")")

# - STEP 8 (optional).  Get artifacts --------------------------------------
# Instantiate the ArtifactAPI
artifact_api_instance = syndeia_cloud_33x_client_sdk.ArtifactApi(api_client_instance)

try:
    artifact_response = artifact_api_instance.get_artifacts()
    print(artifact_response)
except ApiException as e:
    print("Exception when calling ArtifactApi->get_artifacts: %s\n" % e)

# print number of artifacts
num_artifacts = len(artifact_response.resources)
print(num_artifacts)

# - STEP 9 (optional).  Get relations --------------------------------------
# Instantiate the RelationAPI
relation_api_instance = syndeia_cloud_33x_client_sdk.RelationApi(api_client_instance)

try:
    relation_response = relation_api_instance.get_relations()
    print(relation_response)
except ApiException as e:
    print("Exception when calling RelationApi->get_relations: %s\n" % e)

# Number of relations
num_relations = len(relation_response.resources)
print(num_relations)

# Get relations by specific Syndeia projects
# Get the Syndeia container with key UAV_MBEE
uav_relations = relation_api_instance.get_relations_by_container_key("UAV_MBEE")

num_uav_relations = len(uav_relations.resources)
print(num_uav_relations)

for r in uav_relations.resources:
    print(r.key + " - " + r.name)

Documentation for API Endpoints

All URIs are relative to http://<your_SC_server_FQDN>

Class

Method

HTTP request

Description

ArtifactApi

create_artifact

POST /artifacts

Create a new artifact

ArtifactApi

delete_artifacts_by_key

DELETE /artifacts/{key}

Delete an artifact given the artifact key

ArtifactApi

get_artifact_by_external_id

POST /artifacts/external/id

Get an artifact given the artifact external id

ArtifactApi

get_artifact_by_key

GET /artifacts/{key}

Get an artifact given the artifact key

ArtifactApi

get_artifact_by_key_and_version

GET /artifacts/{key}/versions/{version}

Get an artifact given the artifact key and version

ArtifactApi

get_artifact_versions_by_key

GET /artifacts/{key}/versions

Get all versions of an artifact given the artifact key

ArtifactApi

get_artifacts

GET /artifacts

Get all artifacts

ArtifactApi

update_artifact_by_key

PUT /artifacts/{key}

Update artifact given the artifact key

ArtifactTypeApi

create_artifact_type

POST /types/artifact

Create a new Artifact type

ArtifactTypeApi

delete_artifact_type_by_key

DELETE /types/artifact/{key}

Delete an Artifact type given the Artifact type key

ArtifactTypeApi

get_artifact_type_by_external_id

POST /types/artifact/external/id

Get an artifact type given the artifact type external id

ArtifactTypeApi

get_artifact_type_by_key

GET /types/artifact/{key}

Get an Artifact type given the Artifact type key

ArtifactTypeApi

get_artifact_type_by_key_and_attribute_definition_id

GET /types/artifact/{key}/attribdefs/{id}

Get an attribute definition of an artifact type given the artifact type key and attribute definition id

ArtifactTypeApi

get_artifact_types

GET /types/artifact

Get all artifact types

ArtifactTypeApi

update_artifact_type_by_key

PUT /types/artifact/{key}

Update an Artifact type given the Artifact key

AuthApi

create_super_user

GET /signUp/superuser

Sign-up super user

AuthApi

create_user

POST /signUp

Create a new user (sign-up)

AuthApi

diable_internal_user

POST /account/disable

Disable internal user

AuthApi

enable_internal_user

POST /account/enable

Enable internal user

AuthApi

get_new_password

POST /password/reset

Reset user password

AuthApi

get_token

POST /signIn

Sign-in a user

AuthApi

get_token_by_provider

POST /authenticate/{provider}

Authenticate user through Auth Provider e.g LDAP

AuthApi

sign_out_user

GET /signOut

Sign-out a user

AuthApi

update_password

POST /password/change

Change user password

ContainerApi

create_container

POST /containers

Create a new container

ContainerApi

delete_container_by_key

DELETE /containers/{key}

Delete a container given the container key

ContainerApi

get_container_by_external_id

POST /containers/external/id

Get a container given the container external id

ContainerApi

get_container_by_key

GET /containers/{key}

Get a container given the container key

ContainerApi

get_containers

GET /containers

Get all containers

ContainerApi

update_container_by_key

PUT /containers/{key}

Update a container given the container key

ContainerTypeApi

create_container_type

POST /types/container

Create a new Container type

ContainerTypeApi

delete_container_type_by_key

DELETE /types/container/{key}

Delete a Container type given the container type key

ContainerTypeApi

get_container_type_by_external_id

POST /types/container/external/id

Get a container type given the container type external id

ContainerTypeApi

get_container_type_by_key

GET /types/container/{key}

Get a Container type given the Container type key

ContainerTypeApi

get_container_type_by_key_and_attribute_definition_id

GET /types/container/{key}/attribdefs/{id}

Get a attribute definition of container type given the container type key and attribute definition id

ContainerTypeApi

get_container_types

GET /types/container

Get all container types

ContainerTypeApi

update_container_type_by_key

PUT /types/container/{key}

Update a Container type given the Container key

GraphApi

get_raw_graph_result

POST /graph/query/raw

Get result of a graph query

RelationApi

create_relation

POST /relations

Create a new relation

RelationApi

delete_relations_by_key

DELETE /relations/{key}

Delete a relation given the relation key

RelationApi

get_relation_by_external_id

POST /relations/external/id

Get a relation given the relation external id

RelationApi

get_relation_by_key

GET /relations/{key}

Get a relation given the relation key

RelationApi

get_relation_by_key_and_version

GET /relations/{key}/versions/{version}

Get a relation given the relation key and version

RelationApi

get_relation_versions_by_key

GET /relations/{key}/versions

Get all versions of a relation given the relation key

RelationApi

get_relations

GET /relations

Get all relations

RelationApi

update_relation_by_key

PUT /relations/{key}

Update relation given the relation key

RelationTypeApi

create_relation_type

POST /types/relation

Create a new Relation type

RelationTypeApi

delete_relation_type_by_key

DELETE /types/relation/{key}

Delete a Relation type given the Relation type key

RelationTypeApi

get_relation_type_by_external_id

POST /types/relation/external/id

Get a relation type given the relation type external id

RelationTypeApi

get_relation_type_by_key

GET /types/relation/{key}

Get a Relation type given the Relation type key

RelationTypeApi

get_relation_type_by_key_and_attribute_definition_id

GET /types/relation/{key}/attribdefs/{id}

Get an attribute definition of relation type given the relation type key and attribute definition id

RelationTypeApi

get_relation_types

GET /types/relation

Get all relation types

RelationTypeApi

update_relation_type_by_key

PUT /types/relation/{key}

Update a Relation type given the Relation key

RepositoryApi

create_repository

POST /repositories

Create a new repository

RepositoryApi

delete_repository_by_key

DELETE /repositories/{key}

Delete a repository given the repository key

RepositoryApi

get_repositories

GET /repositories

Get all repositories

RepositoryApi

get_repository_by_external_id

POST /repositories/external/id

Get a repository given the repository external id

RepositoryApi

get_repository_by_key

GET /repositories/{key}

Get a repository given the repository key

RepositoryApi

update_repository_by_key

PUT /repositories/{key}

Update a repository given the repository key

RepositoryTypeApi

create_repository_type

POST /types/repository

Create a new repository type

RepositoryTypeApi

delete_repository_type_by_key

DELETE /types/repository/{key}

Delete a repository type given the repository type key

RepositoryTypeApi

get_repository_type_by_external_id

POST /types/repository/external/id

Get a repository type given the repository type external id

RepositoryTypeApi

get_repository_type_by_key

GET /types/repository/{key}

Get a repository type given the repository type key

RepositoryTypeApi

get_repository_type_by_key_and_attribute_definition_id

GET /types/repository/{key}/attribdefs/{id}

Get a attribute definition of repository type given the repository type key and attribute definition id

RepositoryTypeApi

get_repository_types

GET /types/repository

Get all repository types

RepositoryTypeApi

update_repository_type_by_key

PUT /types/repository/{key}

Update a repository type given the repository key

UserApi

delete_user_by_key

DELETE /users/{key}

Delete a user given the user key

UserApi

get_user_by_key

GET /users/{key}

Get a user given the user key

UserApi

get_user_by_username

GET /users/username/{username}

Get a user given the user name

UserApi

get_users

GET /users

Get all users

UserApi

update_user_by_key

PUT /users/{key}

Update a user given the user key

Documentation For Models

Authors

  • Intercax DevTeam,

  • OpenAPI

2020-04-13T11:05:51 ET, brian

  • No labels