oblv-ctl


Nameoblv-ctl JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/ObliviousAI/oblv-ctl/tree/master/README.md
SummaryA client library for accessing Oblivious APIs
upload_time2023-06-15 10:36:15
maintainer
docs_urlNone
authorOblivious Support
requires_python>=3.7,<4.0
licenseApache-2.0
keywords oblivious python package
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # oblv-ctl

A Python library to access Oblivious APIs.

## Usage

First, create a client, with your API key. This key can be created in the
[Oblivious Console UI](https://console.oblivious.ai/). Go to the
settings page, and create your ApiKey. Once done, the client can be
created as follows

``` {.python}
from oblv_ctl import authenticate
client = authenticate(apikey=*your_key_here*)
```


Using this client, all the Oblivious actions can be performed, including the deployment of enclaves. Below is a step-by-step guide, to creating your first deployment.


The deployments can be created in two ways - using a pre-built static service or dynamically deploying the code.

# Dynamic Service Deployment
### 1 Create a service

A service refers to a branch/tag of your repository that needs to be
deployed. For your first service. you can use the repository
[ObliviousAI/FastAPI-Enclave-Services](https://github.com/ObliviousAI/FastAPI-Enclave-Services).
Execute the below command to create the service.

``` {.python}
client.add_service(repo_owner="ObliviousAI",repo_name="FastAPI-Enclave-Services", ref="master", data = {
    "auth": [
        {
            "auth_name": "auth_name",
            "auth_type": "signed_headers"
        }
    ],
    "base_image": "oblv_ubuntu_18_04_proxy_nsm_api_python_3_8",
    "build_args": [],
    "meta": {
        "author": "Team Oblivious",
        "author_email": "hello@oblivious.ai",
        "git": "https://github.com/ObliviousAI/FastAPI-Enclave-Services.git",
        "version": "0.1.0"
    },
    "paths": [
        {
            "access": "user",
            "path": "/hello/",
            "short_description": "Hello world example"
        }
    ],
    "roles": [
        {
            "role_auth": "auth_name",
            "role_cardinality": 1,
            "role_description": "Role for the data scientist",
            "role_name": "user"
        }
    ],
    "traffic": {
        "inbound": [
            {
                "name": "main_io",
                "port": 80,
                "type": "tcp"
            }
        ],
        "outbound": [
            {
                "domain": "example.com",
                "name": "example",
                "port": 443,
                "type": "tcp"
            }
        ]
    }
})
```

The data provided here is sample service data. You can update the data as per your requirements, adhering to the schema.
The response for the call above gives results as follows - 


>{ \
>&nbsp;&nbsp;&nbsp;&nbsp;"message": "Success", \
>&nbsp;&nbsp;&nbsp;&nbsp;"service":&nbsp;&nbsp;&nbsp;&nbsp;{ \
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ref": "master", \
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"service_validated": true, \
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"sha": "6b1b3e9cf6b0cb7264aad2fc80d91a009ccf0fc1", \
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "branch" \
>&nbsp;&nbsp;&nbsp;&nbsp;} \
>} 


You have now successfully created your first service, and it can be now deployed to an enclave.

### 2 Enclave Creation

To create an enclave, you need to decide on a few of the parameters -

-   **deployment_name** - A unique deployment name. You cannot have two
    running deployments with the same name.
-   **region_name** - could be one of the AWS regions from
    - ***us-east-1*** (N. Virginia) 
    - ***us-west-2*** (Oregon)
    - ***eu-central-1*** (Frankfurt)
    - ***eu-west-2*** (London)
-   **visibility** - ***private*** or ***public***
-   **is_dev_env** - ***True*** or ***False***.
-   **tags** - A list of tags for your deployment
-   **account_type** - This is the VCS type, and only GitHub*** is
    supported for now.
-   **build_args** - Arguments specific to your deployment. It includes adding users to their roles with their public keys, runtime arguments and
    any additional arguments for your build. It also includes the infra
    size needed for the deployment. The options are -
    -   ***c5.xlarge*** - CPU:4 RAM:8 GB \-- Credit Utilization: 68.0/hr
    -   ***m5.xlarge*** - CPU:4 RAM:16 GB \-- Credit Utilization:
        76.8/hr
    -   ***r5.xlarge*** - CPU:4 RAM:32 GB \-- Credit Utilization:
        100.8/hr
    -   ***c5.2xlarge*** - CPU:8 RAM:16 GB \-- Credit Utilization:
        136.0/hr
    -   ***m5.2xlarge*** - CPU:8 RAM:32 GB \-- Credit Utilization:
        153.6/hr

A valid example for *build_args* for the service you created -


```
args = {
    "users": {
      "admin": [
        {
          "user_name": "<your name>",
          "public key": "<your public key>"
        }
      ]
    },
    "infra_reqs": "m5.xlarge",  
}

```

> 📝 **Note:**
>
> <b>admin</b> here
> is the role defined for the deployment in service.yaml
> file
>
> The service used,
> does not have requirements for any runtime or build arguments, so not
> needed here.

``` {.python}
from oblv_ctl.models import CreateDeploymentInput
input = CreateDeploymentInput(
    owner="ObliviousAI",
    repo="FastAPI-Enclave-Services",
    account_type="github",
    ref="master",
    ref_type="branch",
    region_name="us-east-1",
    deployment_name="Depl",
    visibility="private",
    is_dev_env=True,
    tags=[],
    build_args=args
)
response = client.create_deployment(input)
```


On successful request, enclave creation is initiated, and it returns an
id for the deployment, which can be later used to track the status and
connection details for the enclave.

### 3 Enclave Information
To check the state of the deployment, run

``` {.python}
client.deployment_info(response.deployment_id).current_state
```

> 'CFT Initiated'


When the deployment state becomes ***Running***, it indicates that the
enclave is now available for connection.

To connect to the enclave, you need **Oblv CLI** installed in your
system. The commands to use the CLI can be found in this
[documentation](https://docs.oblivious.ai/cli/usage_examples).

Cli binaries can be found [here](https://docs.oblivious.ai/cli/binaries)

The URL to connect to the enclave using CLI can be accessed using

``` {.python}
client.deployment_info(response.deployment_id).instance.service_url
```

>
>'https://conso-appli-15aiaxip9pcxk-94364694.enclave.oblivious.ai'
>


The PCR codes can be found using

``` {.python}
client.deployment_info(response.deployment_id).pcr_codes
```

>['d8dd856bacf4a8f0840ab530579b906091803e818e01dc4b8f51c247a7adfcfe55b4ef5f17be6d53bb952d92d87a376c',
'bcdf05fefccaa8e55bf2c8d6dee9e79bbff31e34bf28a99aa19e6b29c37ee80b214a414b7607236edf26fcb78654e63f','79477bad9504a347afb557a8ccd6f62ea61243311dff39f66944f5150242128da0cd070f0ce629c6beb6bb4f0b52f5ed' ]


# Static Service Deployment
In this type of deployment, services are prebuilt and kept ahead of time. You can either create you static service first and then go ahead for deployment, or you could simply use a service available in marketplace.

### 1 Create a service
Execute the below command to create a static service.

```python
oblv_client.add_static_service(
    name="first deployment",
    description="First Static Service creation",
    repo_owner="ObliviousAI",
    repo_name="FastAPI-Enclave-Services",
    ref="60d7c177be25cc9758520580f78f7d6b135b17c8",
    arguments={}
)
```


### 2 Enclave Creation
Execute the below command to create deployment from static service. 

```python
from oblv_ctl.models import StaticDeploymentInput
obj = StaticDeploymentInput(
    service="<service_id>",
    deployment_name="first_static_deployment",
    region_name="us-east-1",
    is_dev_env=True,
    runtime_args="somthing",
    users = {"somerole": [{"user_name": "<your name>", "public key": "<your public key>"}]},
    infra_reqs="m5.xlarge",
    marketplace=False
)
oblv_client.create_static_service_deployment(obj)
```

The next steps for getting deployment information and the pcr codes are same for both the service types and can be found [here](#3-enclave-information).
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ObliviousAI/oblv-ctl/tree/master/README.md",
    "name": "oblv-ctl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "Oblivious,python,package",
    "author": "Oblivious Support",
    "author_email": "support@oblivious.ai",
    "download_url": "https://files.pythonhosted.org/packages/d1/cc/11d0258b9fbf7709c5afe5e7a915234d2de29861ce32b4771894350f6ae9/oblv_ctl-0.4.1.tar.gz",
    "platform": null,
    "description": "# oblv-ctl\n\nA Python library to access Oblivious APIs.\n\n## Usage\n\nFirst, create a client, with your API key. This key can be created in the\n[Oblivious Console UI](https://console.oblivious.ai/). Go to the\nsettings page, and create your ApiKey. Once done, the client can be\ncreated as follows\n\n``` {.python}\nfrom oblv_ctl import authenticate\nclient = authenticate(apikey=*your_key_here*)\n```\n\n\nUsing this client, all the Oblivious actions can be performed, including the deployment of enclaves. Below is a step-by-step guide, to creating your first deployment.\n\n\nThe deployments can be created in two ways - using a pre-built static service or dynamically deploying the code.\n\n# Dynamic Service Deployment\n### 1 Create a service\n\nA service refers to a branch/tag of your repository that needs to be\ndeployed. For your first service. you can use the repository\n[ObliviousAI/FastAPI-Enclave-Services](https://github.com/ObliviousAI/FastAPI-Enclave-Services).\nExecute the below command to create the service.\n\n``` {.python}\nclient.add_service(repo_owner=\"ObliviousAI\",repo_name=\"FastAPI-Enclave-Services\", ref=\"master\", data = {\n    \"auth\": [\n        {\n            \"auth_name\": \"auth_name\",\n            \"auth_type\": \"signed_headers\"\n        }\n    ],\n    \"base_image\": \"oblv_ubuntu_18_04_proxy_nsm_api_python_3_8\",\n    \"build_args\": [],\n    \"meta\": {\n        \"author\": \"Team Oblivious\",\n        \"author_email\": \"hello@oblivious.ai\",\n        \"git\": \"https://github.com/ObliviousAI/FastAPI-Enclave-Services.git\",\n        \"version\": \"0.1.0\"\n    },\n    \"paths\": [\n        {\n            \"access\": \"user\",\n            \"path\": \"/hello/\",\n            \"short_description\": \"Hello world example\"\n        }\n    ],\n    \"roles\": [\n        {\n            \"role_auth\": \"auth_name\",\n            \"role_cardinality\": 1,\n            \"role_description\": \"Role for the data scientist\",\n            \"role_name\": \"user\"\n        }\n    ],\n    \"traffic\": {\n        \"inbound\": [\n            {\n                \"name\": \"main_io\",\n                \"port\": 80,\n                \"type\": \"tcp\"\n            }\n        ],\n        \"outbound\": [\n            {\n                \"domain\": \"example.com\",\n                \"name\": \"example\",\n                \"port\": 443,\n                \"type\": \"tcp\"\n            }\n        ]\n    }\n})\n```\n\nThe data provided here is sample service data. You can update the data as per your requirements, adhering to the schema.\nThe response for the call above gives results as follows - \n\n\n>{ \\\n>&nbsp;&nbsp;&nbsp;&nbsp;\"message\": \"Success\", \\\n>&nbsp;&nbsp;&nbsp;&nbsp;\"service\":&nbsp;&nbsp;&nbsp;&nbsp;{ \\\n>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"ref\": \"master\", \\\n>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"service_validated\": true, \\\n>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"sha\": \"6b1b3e9cf6b0cb7264aad2fc80d91a009ccf0fc1\", \\\n>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"type\": \"branch\" \\\n>&nbsp;&nbsp;&nbsp;&nbsp;} \\\n>} \n\n\nYou have now successfully created your first service, and it can be now deployed to an enclave.\n\n### 2 Enclave Creation\n\nTo create an enclave, you need to decide on a few of the parameters -\n\n-   **deployment_name** - A unique deployment name. You cannot have two\n    running deployments with the same name.\n-   **region_name** - could be one of the AWS regions from\n    - ***us-east-1*** (N. Virginia) \n    - ***us-west-2*** (Oregon)\n    - ***eu-central-1*** (Frankfurt)\n    - ***eu-west-2*** (London)\n-   **visibility** - ***private*** or ***public***\n-   **is_dev_env** - ***True*** or ***False***.\n-   **tags** - A list of tags for your deployment\n-   **account_type** - This is the VCS type, and only GitHub*** is\n    supported for now.\n-   **build_args** - Arguments specific to your deployment. It includes adding users to their roles with their public keys, runtime arguments and\n    any additional arguments for your build. It also includes the infra\n    size needed for the deployment. The options are -\n    -   ***c5.xlarge*** - CPU:4 RAM:8 GB \\-- Credit Utilization: 68.0/hr\n    -   ***m5.xlarge*** - CPU:4 RAM:16 GB \\-- Credit Utilization:\n        76.8/hr\n    -   ***r5.xlarge*** - CPU:4 RAM:32 GB \\-- Credit Utilization:\n        100.8/hr\n    -   ***c5.2xlarge*** - CPU:8 RAM:16 GB \\-- Credit Utilization:\n        136.0/hr\n    -   ***m5.2xlarge*** - CPU:8 RAM:32 GB \\-- Credit Utilization:\n        153.6/hr\n\nA valid example for *build_args* for the service you created -\n\n\n```\nargs = {\n    \"users\": {\n      \"admin\": [\n        {\n          \"user_name\": \"<your name>\",\n          \"public key\": \"<your public key>\"\n        }\n      ]\n    },\n    \"infra_reqs\": \"m5.xlarge\",  \n}\n\n```\n\n> \ud83d\udcdd **Note:**\n>\n> <b>admin</b> here\n> is the role defined for the deployment in service.yaml\n> file\n>\n> The service used,\n> does not have requirements for any runtime or build arguments, so not\n> needed here.\n\n``` {.python}\nfrom oblv_ctl.models import CreateDeploymentInput\ninput = CreateDeploymentInput(\n    owner=\"ObliviousAI\",\n    repo=\"FastAPI-Enclave-Services\",\n    account_type=\"github\",\n    ref=\"master\",\n    ref_type=\"branch\",\n    region_name=\"us-east-1\",\n    deployment_name=\"Depl\",\n    visibility=\"private\",\n    is_dev_env=True,\n    tags=[],\n    build_args=args\n)\nresponse = client.create_deployment(input)\n```\n\n\nOn successful request, enclave creation is initiated, and it returns an\nid for the deployment, which can be later used to track the status and\nconnection details for the enclave.\n\n### 3 Enclave Information\nTo check the state of the deployment, run\n\n``` {.python}\nclient.deployment_info(response.deployment_id).current_state\n```\n\n> 'CFT Initiated'\n\n\nWhen the deployment state becomes ***Running***, it indicates that the\nenclave is now available for connection.\n\nTo connect to the enclave, you need **Oblv CLI** installed in your\nsystem. The commands to use the CLI can be found in this\n[documentation](https://docs.oblivious.ai/cli/usage_examples).\n\nCli binaries can be found [here](https://docs.oblivious.ai/cli/binaries)\n\nThe URL to connect to the enclave using CLI can be accessed using\n\n``` {.python}\nclient.deployment_info(response.deployment_id).instance.service_url\n```\n\n>\n>'https://conso-appli-15aiaxip9pcxk-94364694.enclave.oblivious.ai'\n>\n\n\nThe PCR codes can be found using\n\n``` {.python}\nclient.deployment_info(response.deployment_id).pcr_codes\n```\n\n>['d8dd856bacf4a8f0840ab530579b906091803e818e01dc4b8f51c247a7adfcfe55b4ef5f17be6d53bb952d92d87a376c',\n'bcdf05fefccaa8e55bf2c8d6dee9e79bbff31e34bf28a99aa19e6b29c37ee80b214a414b7607236edf26fcb78654e63f','79477bad9504a347afb557a8ccd6f62ea61243311dff39f66944f5150242128da0cd070f0ce629c6beb6bb4f0b52f5ed' ]\n\n\n# Static Service Deployment\nIn this type of deployment, services are prebuilt and kept ahead of time. You can either create you static service first and then go ahead for deployment, or you could simply use a service available in marketplace.\n\n### 1 Create a service\nExecute the below command to create a static service.\n\n```python\noblv_client.add_static_service(\n    name=\"first deployment\",\n    description=\"First Static Service creation\",\n    repo_owner=\"ObliviousAI\",\n    repo_name=\"FastAPI-Enclave-Services\",\n    ref=\"60d7c177be25cc9758520580f78f7d6b135b17c8\",\n    arguments={}\n)\n```\n\n\n### 2 Enclave Creation\nExecute the below command to create deployment from static service. \n\n```python\nfrom oblv_ctl.models import StaticDeploymentInput\nobj = StaticDeploymentInput(\n    service=\"<service_id>\",\n    deployment_name=\"first_static_deployment\",\n    region_name=\"us-east-1\",\n    is_dev_env=True,\n    runtime_args=\"somthing\",\n    users = {\"somerole\": [{\"user_name\": \"<your name>\", \"public key\": \"<your public key>\"}]},\n    infra_reqs=\"m5.xlarge\",\n    marketplace=False\n)\noblv_client.create_static_service_deployment(obj)\n```\n\nThe next steps for getting deployment information and the pcr codes are same for both the service types and can be found [here](#3-enclave-information).",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A client library for accessing Oblivious APIs",
    "version": "0.4.1",
    "project_urls": {
        "Homepage": "https://github.com/ObliviousAI/oblv-ctl/tree/master/README.md",
        "Repository": "https://github.com/ObliviousAI/oblv-ctl"
    },
    "split_keywords": [
        "oblivious",
        "python",
        "package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b11bdee645447e72c0f4df9aa451f41f3536e751ea588a15a698b07c8a619ea7",
                "md5": "db0b4dc1a3e40d6643075dd2adae5155",
                "sha256": "ff30da333c37f178a779804b05057480b0e18bd75e41629e80889f1c2c960d1c"
            },
            "downloads": -1,
            "filename": "oblv_ctl-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db0b4dc1a3e40d6643075dd2adae5155",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 171251,
            "upload_time": "2023-06-15T10:36:12",
            "upload_time_iso_8601": "2023-06-15T10:36:12.738937Z",
            "url": "https://files.pythonhosted.org/packages/b1/1b/dee645447e72c0f4df9aa451f41f3536e751ea588a15a698b07c8a619ea7/oblv_ctl-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d1cc11d0258b9fbf7709c5afe5e7a915234d2de29861ce32b4771894350f6ae9",
                "md5": "4b46cc576971b731fa58e4565a5d6e46",
                "sha256": "2dbcd0d45671918f1730c8e2066d67c96978a176b2ade2262559418a1614f031"
            },
            "downloads": -1,
            "filename": "oblv_ctl-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4b46cc576971b731fa58e4565a5d6e46",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 54203,
            "upload_time": "2023-06-15T10:36:15",
            "upload_time_iso_8601": "2023-06-15T10:36:15.905975Z",
            "url": "https://files.pythonhosted.org/packages/d1/cc/11d0258b9fbf7709c5afe5e7a915234d2de29861ce32b4771894350f6ae9/oblv_ctl-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-15 10:36:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ObliviousAI",
    "github_project": "oblv-ctl",
    "github_not_found": true,
    "lcname": "oblv-ctl"
}
        
Elapsed time: 0.07744s