Skip to content

Commit 7b503b8

Browse files
Merge pull request #738 from jasonnovichRunAI/v2.17-RUN-16823-whats-new-only
V2.17-RUN-16823-whats-new-only
2 parents 65120ac + 2ad80b3 commit 7b503b8

File tree

4 files changed

+227
-73
lines changed

4 files changed

+227
-73
lines changed

docs/developer/overview-developer.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
---
22
title: Developer Documentation Overview
3+
summary: This article is an overview of the developer documentation for the Run:ai platform.
4+
authors:
5+
- Jason Novich
6+
date: 2024-Apr-10
37
---
48

5-
# Overview: Developer Documentation
9+
Developers can access Run:ai through various programmatic interfaces.
610

7-
Developers can access Run:ai through various programmatic interfaces.
11+
## API Support
812

13+
The endpoints and parameters specified in the API reference are the ones that are officially supported by Run:ai. Endpoints and parameters that are **NOT** listed in the reference are not officially supported.
14+
15+
Endpoints and parameters marked as `deprecated` means they remain operational and can be used; however, Run:ai will **NO LONGER RECOMMEND USING THEM**, **WILL NOT ADD FUNCTIONALITY TO THEM**, and **WILL NO LONGER BE SUPPORTED AFTER**
16+
17+
Option1 : <#of versions>
18+
Option 2: <time period>.
19+
20+
For details, see the [Deprecation notifications](../home/whats-new-2-17.md#deprecation-notifications).
921

1022
## API Architecture
1123

@@ -19,32 +31,31 @@ Below is a diagram of the Run:ai API Architecture. A developer may:
1931

2032
![api architecture image](img/api-architecture.png)
2133

22-
2334
## Administrator API
2435

25-
Add, delete, modify and list Run:ai meta-data objects such as Projects, Departments, Users, and more.
36+
Add, delete, modify and list Run:ai meta-data objects such as Projects, Departments, Users, and more.
2637

2738
The API is provided as REST and is accessible via the control plane endpoint.
2839

29-
For more information see [Administrator REST API](admin-rest-api/overview.md).
40+
For more information see [Administrator REST API](admin-rest-api/overview.md).
3041

3142
## Cluster API
3243

33-
Submit and delete Workloads.
44+
Submit and delete Workloads.
3445

3546
The API is provided as [Kubernetes API](./cluster-api/submit-yaml.md).
3647

37-
Cluster API is accessible via the GPU cluster itself. As such, __multiple clusters may have multiple endpoints__.
48+
Cluster API is accessible via the GPU cluster itself. As such, **multiple clusters may have multiple endpoints**.
3849

3950
!!! Note
40-
The same functionality is also available via the [Run:ai Command-line interface](../Researcher/cli-reference/Introduction.md). The CLI provides an alternative for automating with shell scripts.
51+
The same functionality is also available via the [Run:ai Command-line interface](../Researcher/cli-reference/Introduction.md). The CLI provides an alternative for automating with shell scripts.
52+
4153
## Metrics API
4254

43-
Retrieve metrics from multiple GPU clusters.
55+
Retrieve metrics from multiple GPU clusters.
4456

4557
See the [Metrics API](metrics/metrics.md) document.
4658

4759
## API Authentication
4860

4961
See [API Authentication](rest-auth.md) for information on how to gain authenticated access to Run:ai APIs.
50-

docs/developer/rest-auth.md

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,67 @@
11

22
# API Authentication
33

4+
The following document explains how to authenticate with Run:ai APIs.
45

5-
The following document explains how to authenticate with Run:ai APIs.
6-
7-
Run:ai APIs are accessed using _bearer tokens_. A token can be obtained in several ways:
6+
Run:ai APIs are accessed using *bearer tokens*. A token can be obtained in several ways:
87

98
* When logging into the Run:ai user interface, you enter an email and password (or authenticated via single sign-on) which are used to obtain a token.
109
* When using the Run:ai command-line, you use a Kubernetes profile and are authenticated by pre-running `runai login` (or oc login with OpenShift). The command attaches a token to the profile and allows you access to Run:ai functionality.
11-
* When using Run:ai APIs, you need to create an __Application__ through the Run:ai user interface. The Application is created with specific roles and contains a _secret_. Using the secret you can obtain a token and use it within subsequent API calls.
10+
* When using Run:ai APIs, you need to create an **Application** through the Run:ai user interface. The Application is created with specific roles and contains a *secret*. Using the secret you can obtain a token and use it within subsequent API calls.
1211

1312
## Create a Client Application
1413

1514
* Open the Run:ai Run:ai User Interface.
16-
* Go to `Settings | Application` and create a new Application.
17-
* Set the required roles:
18-
* Select `Researcher` to manipulate _Jobs_ using the [Cluster API](cluster-api/submit-rest.md). To provide access to a specific project, you will also need to go to `Application | Projects` and provide the Application with access to specific projects.
19-
* Select `Editor` to manipulate _Projects_ and _Departments_ using the [Administrator REST API](admin-rest-api/overview.md).
20-
* Select `Administrator` to manipulate _Users_, _Tenant Settings_ and _Clusters_ using the [Administrator REST API](admin-rest-api/overview.md).
21-
* Copy the `<APPLICATION-NAME>` and `<CLIENT-SECRET>` to be used below
22-
* Go to `Settings | General`, under `Researcher Authentication` copy `<REALM>`.
15+
* Go to `Settings & Tools`, `Application` and create a new Application.
16+
* Copy the `<APPLICATION>` and `<SECRET KEY>` to be used below
2317

24-
!!! Important Note
25-
Creating Client Application tokens is only available with SaaS installations where the tenant has been created post-January 2022 or any Self-hosted installation. If you are an administrator but do not see the `Settings | Application` area, please contact Run:ai customer support.
18+
### Access rules for the Application
19+
20+
* Set the required roles:
21+
* Select `Researcher` to manipulate *Jobs* using the [Cluster API](cluster-api/submit-rest.md). To provide access to a specific project, you will also need to go to `Application | Projects` and provide the Application with access to specific projects.
22+
* Select `Editor` to manipulate *Projects* and *Departments* using the [Administrator REST API](admin-rest-api/overview.md).
23+
* Select `Administrator` to manipulate *Users*, *Tenant Settings* and *Clusters* using the [Administrator REST API](admin-rest-api/overview.md).
2624

2725
## Request an API Token
2826

29-
Use the above parameters to get a temporary token to access Run:ai as follows.
27+
Use the above parameters to get a temporary token to access Run:ai as follows.
3028

31-
### Example command to get an API token
29+
### Example command to get an API token
3230

33-
Replace `<COMPANY-URL>` below with `app.run.ai` for SaaS installations (not `<company>.run.ai`) or the Run:ai user interface URL for Self-hosted installations.
31+
Replace `<COMPANY-URL>` below with:
32+
33+
* For SaaS installations use `<company>.run.ai`
34+
* For self-hosted use the Run:ai user interface URL.
3435

3536
=== "cURL"
3637
``` bash
37-
curl -X POST 'https://<COMPANY-URL>/auth/realms/<REALM>/protocol/openid-connect/token' \
38-
--header 'Content-Type: application/x-www-form-urlencoded' \
39-
--data-urlencode 'grant_type=client_credentials' \
40-
--data-urlencode 'scope=openid' \
41-
--data-urlencode 'response_type=id_token' \
42-
--data-urlencode 'client_id=<APPLICATION-NAME>' \
43-
--data-urlencode 'client_secret=<CLIENT-SECRET>'
38+
curl -X POST \
39+
'https://<runai_url>/api/v1/token' \
40+
--header 'Accept: */*' \
41+
--header 'Content-Type: application/json' \
42+
--data-raw '{
43+
"grantType":"app_token",
44+
"AppId":"<APPLICATION NAME>",
45+
"AppSecret" : "<SECRET KEY>"
46+
}'
4447
```
4548

4649
=== "Python"
4750
``` python
48-
import requests
49-
import json
50-
51-
COMPANY_URL = "app.run.ai"
52-
COMPANY_REALM = "acme"
53-
APPLICATION_NAME = "app-name"
54-
CLIENT_SECRET = "secret"
55-
56-
def runai_authenticate():
57-
url = "https://" + COMPANY_URL + "/auth/realms/" + \
58-
COMPANY_REALM + "/protocol/openid-connect/token"
59-
60-
payload = 'grant_type=client_credentials&scope=openid&response_type=id_token&client_id=' + \
61-
APPLICATION_NAME + '&client_secret=' + CLIENT_SECRET
62-
headers = {
63-
'Content-Type': 'application/x-www-form-urlencoded'
51+
import requests
52+
import json
53+
reqUrl = "https://cp-590d-run-13764-kc-upgrade.runailabs.com/api/v1/token"
54+
headersList = {
55+
"Accept": "*/*",
56+
"Content-Type": "application/json"
6457
}
65-
66-
response = requests.request("POST", url, headers=headers, data=payload)
67-
if response.status_code //100 == 2:
68-
j = json.loads(response.text)
69-
return j["access_token"]
70-
else:
71-
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
72-
return
58+
payload = json.dumps({
59+
"grantType":"app_token",
60+
"AppId":"<APPLICATION NAME>",
61+
"AppSecret" : "<SECRET KEY>"
62+
})
63+
response = requests.request("POST", reqUrl, data=payload, headers=headersList)
64+
print(response.text)
7365
```
7466

7567
### Response
@@ -78,19 +70,11 @@ The API response will look as follows:
7870

7971
``` JSON title="API Response"
8072
{
81-
"access_token": "...", // (1)
82-
"expires_in": 36000,
83-
....
84-
"token_type": "bearer"
85-
"id_token": "..."
73+
"accessToken": "<TOKEN>",
8674
}
8775
```
8876

89-
1. Use the `id_token` as the Bearer token below.
90-
91-
92-
To call APIs, the application must pass the retrieved `access_token` as a Bearer token in the Authorization header of your HTTP request.
93-
94-
* To retrieve and manipulate Workloads, use the [Cluster API](cluster-api/workload-overview-dev.md). Researcher API works at the cluster level and you will have different endpoints for different clusters.
95-
* To retrieve and manipulate other metadata objects, use the [Administrator REST API](admin-rest-api/overview.md). Administrator API works at the control-plane level and you have a single endpoint for all clusters.
77+
To call APIs, the application must pass the retrieved `accessToken` as a *Bearer token* in the Authorization header of your HTTP request.
9678

79+
* To retrieve and manipulate Workloads, use the [Cluster API](cluster-api/workload-overview-dev.md). Researcher API works at the cluster level and you will have different endpoints for different clusters.
80+
* To retrieve and manipulate other metadata objects, use the [Administrator REST API](admin-rest-api/overview.md). Administrator API works at the control-plane level and you have a single endpoint for all clusters.

0 commit comments

Comments
 (0)