leviathan-public-content 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- leviathan_public_content-1.0.1/PKG-INFO +100 -0
- leviathan_public_content-1.0.1/README.md +59 -0
- leviathan_public_content-1.0.1/SDK.md +86 -0
- leviathan_public_content-1.0.1/leviathan_public_content.egg-info/PKG-INFO +100 -0
- leviathan_public_content-1.0.1/leviathan_public_content.egg-info/SOURCES.txt +8 -0
- leviathan_public_content-1.0.1/leviathan_public_content.egg-info/dependency_links.txt +1 -0
- leviathan_public_content-1.0.1/leviathan_public_content.egg-info/top_level.txt +1 -0
- leviathan_public_content-1.0.1/leviathan_public_content.py +85 -0
- leviathan_public_content-1.0.1/pyproject.toml +23 -0
- leviathan_public_content-1.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: leviathan-public-content
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Official read-only Python client for Leviathan Systems published resources
|
|
5
|
+
Author: Leviathan Systems
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://www.leviathansystems.co/developers/sdk
|
|
8
|
+
Project-URL: Documentation, https://www.leviathansystems.co/developers
|
|
9
|
+
Project-URL: Source, https://github.com/leviathansystems-gpu/public-content
|
|
10
|
+
Project-URL: Issues, https://github.com/leviathansystems-gpu/public-content/issues
|
|
11
|
+
Keywords: leviathan-systems,gpu-deployment,public-content
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Leviathan Systems public content clients 1.0.1
|
|
16
|
+
|
|
17
|
+
Official dependency-free JavaScript/TypeScript and Python clients for the public,
|
|
18
|
+
read-only content API. Search published titles, follow cursor pages, read a
|
|
19
|
+
catalog resource and retrieve the company profile. No account or API key is
|
|
20
|
+
needed. Package publisher authentication is separate from using the API.
|
|
21
|
+
|
|
22
|
+
## Source installation
|
|
23
|
+
|
|
24
|
+
Install from the official source repository:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
28
|
+
python -m pip install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Registry availability is shown in the official SDK documentation. The existing
|
|
32
|
+
website-hosted 1.0.0 archives remain available with their original signatures.
|
|
33
|
+
Version 1.0.1 adds registry metadata and TypeScript declarations; it preserves
|
|
34
|
+
the read-only client behavior. The CLI and Python User-Agent report 1.0.1.
|
|
35
|
+
|
|
36
|
+
## JavaScript and TypeScript
|
|
37
|
+
|
|
38
|
+
Use Node.js 20 or later. The JavaScript client also supports modern browsers
|
|
39
|
+
on the same origin. The package includes declarations for TypeScript clients.
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { LeviathanClient } from 'leviathan-public-content';
|
|
43
|
+
const client = new LeviathanClient();
|
|
44
|
+
const page = await client.listResources({ kind: 'service', q: 'rack', limit: 5 });
|
|
45
|
+
if (page.items.length) {
|
|
46
|
+
const resource = await client.readResource(page.items[0].id);
|
|
47
|
+
console.log(resource.canonical, resource.markdown);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The CLI prints JSON. After installation:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
leviathan-content --help
|
|
55
|
+
leviathan-content search rack integration
|
|
56
|
+
leviathan-content read service:rack-and-stack
|
|
57
|
+
leviathan-content profile
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Python
|
|
61
|
+
|
|
62
|
+
Use Python 3.10 or later. The client uses only the standard library.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from leviathan_public_content import LeviathanClient
|
|
66
|
+
client = LeviathanClient()
|
|
67
|
+
page = client.list_resources(kind="service", q="rack", limit=5)
|
|
68
|
+
if page["items"]:
|
|
69
|
+
resource = client.read_resource(page["items"][0]["id"])
|
|
70
|
+
print(resource["canonical"], resource["markdown"])
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Limits and errors
|
|
74
|
+
|
|
75
|
+
Search matches all query words in titles. JavaScript `resourcePages(options)`
|
|
76
|
+
and Python `resource_pages(**options)` retain the original query and origin.
|
|
77
|
+
Restart the search if a content revision invalidates a cursor. A null Markdown
|
|
78
|
+
body means read the returned canonical HTML URL.
|
|
79
|
+
|
|
80
|
+
`LeviathanAPIError` exposes HTTP status, a stable code and the retry interval
|
|
81
|
+
(`retryAfter` in JavaScript, `retry_after` in Python). Clients do not retry
|
|
82
|
+
automatically. Honor 429 and Retry-After, correct invalid input and keep reads
|
|
83
|
+
bounded. The default request timeout is 15 seconds; redirect responses are not
|
|
84
|
+
followed. Custom origins must be HTTPS, except localhost/127.0.0.1 for local tests.
|
|
85
|
+
|
|
86
|
+
Educational resources are not a statement of company capabilities, technical
|
|
87
|
+
certification or availability. Read the company profile and confirm the actual
|
|
88
|
+
project scope with the team. These clients cannot read private drafts, send
|
|
89
|
+
messages, book appointments, purchase services or approve engineering work.
|
|
90
|
+
|
|
91
|
+
## Official references
|
|
92
|
+
|
|
93
|
+
- https://www.leviathansystems.co/developers
|
|
94
|
+
- https://www.leviathansystems.co/developers/sdk
|
|
95
|
+
- https://www.leviathansystems.co/developers/cli
|
|
96
|
+
- https://www.leviathansystems.co/developers/mcp
|
|
97
|
+
- https://www.leviathansystems.co/openapi.json
|
|
98
|
+
|
|
99
|
+
The source license remains proprietary; this release does not relicense the
|
|
100
|
+
existing clients. No install scripts or runtime third-party dependencies are used.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Leviathan Systems agent integration kit
|
|
2
|
+
|
|
3
|
+
Search published GPU deployment, rack integration and structured cabling
|
|
4
|
+
resources, retrieve canonical documents and read the company's stated service
|
|
5
|
+
scope. No account, API key or directory subscription is required.
|
|
6
|
+
|
|
7
|
+
## Repository and skill installation
|
|
8
|
+
|
|
9
|
+
The official integration source is
|
|
10
|
+
https://github.com/leviathansystems-gpu/public-content. Inspect the files before
|
|
11
|
+
installing. To install the resource research skill with the skills CLI:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx skills add leviathansystems-gpu/public-content
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This installs guidance; configure the remote MCP endpoint separately if your
|
|
18
|
+
client does not load the portable plugin. A public repository and an install
|
|
19
|
+
command do not establish a skills.sh listing, usage count or platform approval.
|
|
20
|
+
|
|
21
|
+
## Connect
|
|
22
|
+
|
|
23
|
+
Add `https://www.leviathansystems.co/mcp` as a remote Streamable HTTP server in
|
|
24
|
+
your MCP client. The endpoint returns JSON and is stateless. Use the client's
|
|
25
|
+
initialization flow, then `tools/list` to inspect the current schemas.
|
|
26
|
+
|
|
27
|
+
This directory is also an [Agent Plugins 1.0 package](https://agent-plugins.org/specification):
|
|
28
|
+
`plugin.json` describes it, `mcp.json` supplies the remote connection, and
|
|
29
|
+
`skills/leviathan-resource-research/SKILL.md` describes a focused research workflow.
|
|
30
|
+
Extract the versioned ZIP and install the folder through a client that supports
|
|
31
|
+
that format. Field names differ in other clients; use their documented remote
|
|
32
|
+
MCP settings instead of copying the portable manifest into an arbitrary config.
|
|
33
|
+
Installation does not run scripts or create accounts. Connecting sends normal
|
|
34
|
+
public retrieval requests to Leviathan Systems.
|
|
35
|
+
|
|
36
|
+
## Use the three tools
|
|
37
|
+
|
|
38
|
+
1. `search_resources({"q":"rack", "kind":"service", "limit":5})`
|
|
39
|
+
2. `read_resource({"id":"service:rack-and-stack"})` using an ID returned by search.
|
|
40
|
+
3. `read_company_profile({"view":"boundaries"})` before assessing service fit.
|
|
41
|
+
|
|
42
|
+
Search matches every word in the published title. Follow `next_cursor` with the
|
|
43
|
+
original query when needed. A resource without Markdown still has its canonical
|
|
44
|
+
HTML URL. Honor HTTP 429 and `Retry-After`; do not loop over unchanged errors.
|
|
45
|
+
|
|
46
|
+
Use returned canonical links in citations. Educational articles do not establish
|
|
47
|
+
company capabilities, technical certification or project availability. The tools
|
|
48
|
+
cannot read private drafts, send messages, book appointments, purchase services
|
|
49
|
+
or approve a project. Read [AGENTS.md](./AGENTS.md) and the skill before use.
|
|
50
|
+
|
|
51
|
+
## Official links
|
|
52
|
+
|
|
53
|
+
- [Leviathan Systems](https://www.leviathansystems.co/)
|
|
54
|
+
- [MCP documentation](https://www.leviathansystems.co/developers/mcp)
|
|
55
|
+
- [REST API](https://www.leviathansystems.co/developers)
|
|
56
|
+
- [JavaScript and Python clients](https://www.leviathansystems.co/developers/sdk)
|
|
57
|
+
- [CLI](https://www.leviathansystems.co/developers/cli)
|
|
58
|
+
- [MCP.so listing](https://mcp.so/servers/leviathan-systems-public-content-mcp)
|
|
59
|
+
- [Official MCP Registry](https://registry.modelcontextprotocol.io/?q=co.leviathansystems%2Fpublic-content)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Leviathan Systems public content clients 1.0.1
|
|
2
|
+
|
|
3
|
+
Official dependency-free JavaScript/TypeScript and Python clients for the public,
|
|
4
|
+
read-only content API. Search published titles, follow cursor pages, read a
|
|
5
|
+
catalog resource and retrieve the company profile. No account or API key is
|
|
6
|
+
needed. Package publisher authentication is separate from using the API.
|
|
7
|
+
|
|
8
|
+
## Source installation
|
|
9
|
+
|
|
10
|
+
Install from the official source repository:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
14
|
+
python -m pip install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Registry availability is shown in the official SDK documentation. The existing
|
|
18
|
+
website-hosted 1.0.0 archives remain available with their original signatures.
|
|
19
|
+
Version 1.0.1 adds registry metadata and TypeScript declarations; it preserves
|
|
20
|
+
the read-only client behavior. The CLI and Python User-Agent report 1.0.1.
|
|
21
|
+
|
|
22
|
+
## JavaScript and TypeScript
|
|
23
|
+
|
|
24
|
+
Use Node.js 20 or later. The JavaScript client also supports modern browsers
|
|
25
|
+
on the same origin. The package includes declarations for TypeScript clients.
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { LeviathanClient } from 'leviathan-public-content';
|
|
29
|
+
const client = new LeviathanClient();
|
|
30
|
+
const page = await client.listResources({ kind: 'service', q: 'rack', limit: 5 });
|
|
31
|
+
if (page.items.length) {
|
|
32
|
+
const resource = await client.readResource(page.items[0].id);
|
|
33
|
+
console.log(resource.canonical, resource.markdown);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The CLI prints JSON. After installation:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
leviathan-content --help
|
|
41
|
+
leviathan-content search rack integration
|
|
42
|
+
leviathan-content read service:rack-and-stack
|
|
43
|
+
leviathan-content profile
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Python
|
|
47
|
+
|
|
48
|
+
Use Python 3.10 or later. The client uses only the standard library.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from leviathan_public_content import LeviathanClient
|
|
52
|
+
client = LeviathanClient()
|
|
53
|
+
page = client.list_resources(kind="service", q="rack", limit=5)
|
|
54
|
+
if page["items"]:
|
|
55
|
+
resource = client.read_resource(page["items"][0]["id"])
|
|
56
|
+
print(resource["canonical"], resource["markdown"])
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Limits and errors
|
|
60
|
+
|
|
61
|
+
Search matches all query words in titles. JavaScript `resourcePages(options)`
|
|
62
|
+
and Python `resource_pages(**options)` retain the original query and origin.
|
|
63
|
+
Restart the search if a content revision invalidates a cursor. A null Markdown
|
|
64
|
+
body means read the returned canonical HTML URL.
|
|
65
|
+
|
|
66
|
+
`LeviathanAPIError` exposes HTTP status, a stable code and the retry interval
|
|
67
|
+
(`retryAfter` in JavaScript, `retry_after` in Python). Clients do not retry
|
|
68
|
+
automatically. Honor 429 and Retry-After, correct invalid input and keep reads
|
|
69
|
+
bounded. The default request timeout is 15 seconds; redirect responses are not
|
|
70
|
+
followed. Custom origins must be HTTPS, except localhost/127.0.0.1 for local tests.
|
|
71
|
+
|
|
72
|
+
Educational resources are not a statement of company capabilities, technical
|
|
73
|
+
certification or availability. Read the company profile and confirm the actual
|
|
74
|
+
project scope with the team. These clients cannot read private drafts, send
|
|
75
|
+
messages, book appointments, purchase services or approve engineering work.
|
|
76
|
+
|
|
77
|
+
## Official references
|
|
78
|
+
|
|
79
|
+
- https://www.leviathansystems.co/developers
|
|
80
|
+
- https://www.leviathansystems.co/developers/sdk
|
|
81
|
+
- https://www.leviathansystems.co/developers/cli
|
|
82
|
+
- https://www.leviathansystems.co/developers/mcp
|
|
83
|
+
- https://www.leviathansystems.co/openapi.json
|
|
84
|
+
|
|
85
|
+
The source license remains proprietary; this release does not relicense the
|
|
86
|
+
existing clients. No install scripts or runtime third-party dependencies are used.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: leviathan-public-content
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Official read-only Python client for Leviathan Systems published resources
|
|
5
|
+
Author: Leviathan Systems
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://www.leviathansystems.co/developers/sdk
|
|
8
|
+
Project-URL: Documentation, https://www.leviathansystems.co/developers
|
|
9
|
+
Project-URL: Source, https://github.com/leviathansystems-gpu/public-content
|
|
10
|
+
Project-URL: Issues, https://github.com/leviathansystems-gpu/public-content/issues
|
|
11
|
+
Keywords: leviathan-systems,gpu-deployment,public-content
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Leviathan Systems public content clients 1.0.1
|
|
16
|
+
|
|
17
|
+
Official dependency-free JavaScript/TypeScript and Python clients for the public,
|
|
18
|
+
read-only content API. Search published titles, follow cursor pages, read a
|
|
19
|
+
catalog resource and retrieve the company profile. No account or API key is
|
|
20
|
+
needed. Package publisher authentication is separate from using the API.
|
|
21
|
+
|
|
22
|
+
## Source installation
|
|
23
|
+
|
|
24
|
+
Install from the official source repository:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
28
|
+
python -m pip install git+https://github.com/leviathansystems-gpu/public-content.git
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Registry availability is shown in the official SDK documentation. The existing
|
|
32
|
+
website-hosted 1.0.0 archives remain available with their original signatures.
|
|
33
|
+
Version 1.0.1 adds registry metadata and TypeScript declarations; it preserves
|
|
34
|
+
the read-only client behavior. The CLI and Python User-Agent report 1.0.1.
|
|
35
|
+
|
|
36
|
+
## JavaScript and TypeScript
|
|
37
|
+
|
|
38
|
+
Use Node.js 20 or later. The JavaScript client also supports modern browsers
|
|
39
|
+
on the same origin. The package includes declarations for TypeScript clients.
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { LeviathanClient } from 'leviathan-public-content';
|
|
43
|
+
const client = new LeviathanClient();
|
|
44
|
+
const page = await client.listResources({ kind: 'service', q: 'rack', limit: 5 });
|
|
45
|
+
if (page.items.length) {
|
|
46
|
+
const resource = await client.readResource(page.items[0].id);
|
|
47
|
+
console.log(resource.canonical, resource.markdown);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The CLI prints JSON. After installation:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
leviathan-content --help
|
|
55
|
+
leviathan-content search rack integration
|
|
56
|
+
leviathan-content read service:rack-and-stack
|
|
57
|
+
leviathan-content profile
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Python
|
|
61
|
+
|
|
62
|
+
Use Python 3.10 or later. The client uses only the standard library.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from leviathan_public_content import LeviathanClient
|
|
66
|
+
client = LeviathanClient()
|
|
67
|
+
page = client.list_resources(kind="service", q="rack", limit=5)
|
|
68
|
+
if page["items"]:
|
|
69
|
+
resource = client.read_resource(page["items"][0]["id"])
|
|
70
|
+
print(resource["canonical"], resource["markdown"])
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Limits and errors
|
|
74
|
+
|
|
75
|
+
Search matches all query words in titles. JavaScript `resourcePages(options)`
|
|
76
|
+
and Python `resource_pages(**options)` retain the original query and origin.
|
|
77
|
+
Restart the search if a content revision invalidates a cursor. A null Markdown
|
|
78
|
+
body means read the returned canonical HTML URL.
|
|
79
|
+
|
|
80
|
+
`LeviathanAPIError` exposes HTTP status, a stable code and the retry interval
|
|
81
|
+
(`retryAfter` in JavaScript, `retry_after` in Python). Clients do not retry
|
|
82
|
+
automatically. Honor 429 and Retry-After, correct invalid input and keep reads
|
|
83
|
+
bounded. The default request timeout is 15 seconds; redirect responses are not
|
|
84
|
+
followed. Custom origins must be HTTPS, except localhost/127.0.0.1 for local tests.
|
|
85
|
+
|
|
86
|
+
Educational resources are not a statement of company capabilities, technical
|
|
87
|
+
certification or availability. Read the company profile and confirm the actual
|
|
88
|
+
project scope with the team. These clients cannot read private drafts, send
|
|
89
|
+
messages, book appointments, purchase services or approve engineering work.
|
|
90
|
+
|
|
91
|
+
## Official references
|
|
92
|
+
|
|
93
|
+
- https://www.leviathansystems.co/developers
|
|
94
|
+
- https://www.leviathansystems.co/developers/sdk
|
|
95
|
+
- https://www.leviathansystems.co/developers/cli
|
|
96
|
+
- https://www.leviathansystems.co/developers/mcp
|
|
97
|
+
- https://www.leviathansystems.co/openapi.json
|
|
98
|
+
|
|
99
|
+
The source license remains proprietary; this release does not relicense the
|
|
100
|
+
existing clients. No install scripts or runtime third-party dependencies are used.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
leviathan_public_content
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Official dependency-free client for Leviathan Systems public content."""
|
|
2
|
+
import json
|
|
3
|
+
import urllib.error
|
|
4
|
+
import urllib.parse
|
|
5
|
+
import urllib.request
|
|
6
|
+
|
|
7
|
+
class LeviathanAPIError(Exception):
|
|
8
|
+
def __init__(self, message, status=0, code="NETWORK_ERROR", retry_after=None):
|
|
9
|
+
super().__init__(message)
|
|
10
|
+
self.status, self.code, self.retry_after = status, code, retry_after
|
|
11
|
+
|
|
12
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
13
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
class LeviathanClient:
|
|
17
|
+
def __init__(self, base_url="https://www.leviathansystems.co", timeout=15):
|
|
18
|
+
url = urllib.parse.urlsplit(base_url)
|
|
19
|
+
local = url.scheme == "http" and url.hostname in ("localhost", "127.0.0.1")
|
|
20
|
+
if url.username or url.password or url.query or url.fragment or url.path not in ("", "/") or not url.hostname or not (url.scheme == "https" or local):
|
|
21
|
+
raise ValueError("base_url must be an HTTPS origin, or a local development origin")
|
|
22
|
+
if not isinstance(timeout, (int, float)) or not 0 < timeout <= 60:
|
|
23
|
+
raise ValueError("timeout must be from 0 to 60 seconds")
|
|
24
|
+
self.base_url, self.timeout = base_url.rstrip("/"), timeout
|
|
25
|
+
self._opener = urllib.request.build_opener(_NoRedirect)
|
|
26
|
+
|
|
27
|
+
def _request(self, path):
|
|
28
|
+
req = urllib.request.Request(self.base_url + path, headers={"Accept": "application/json", "Leviathan-API-Version": "1", "User-Agent": "Leviathan-Public-Content-Python/1.0.1"})
|
|
29
|
+
try:
|
|
30
|
+
try:
|
|
31
|
+
response = self._opener.open(req, timeout=self.timeout)
|
|
32
|
+
except urllib.error.HTTPError as error:
|
|
33
|
+
response = error
|
|
34
|
+
with response:
|
|
35
|
+
raw = response.read(2_000_001)
|
|
36
|
+
if len(raw) > 2_000_000:
|
|
37
|
+
raise LeviathanAPIError("Response exceeds the client size limit", code="INVALID_RESPONSE")
|
|
38
|
+
try:
|
|
39
|
+
data = json.loads(raw)
|
|
40
|
+
except (ValueError, UnicodeError):
|
|
41
|
+
raise LeviathanAPIError("The server returned an unreadable response", response.status, "INVALID_RESPONSE") from None
|
|
42
|
+
if not isinstance(data, dict):
|
|
43
|
+
raise LeviathanAPIError("The server returned an invalid document", response.status, "INVALID_RESPONSE")
|
|
44
|
+
if not 200 <= response.status < 300:
|
|
45
|
+
raise LeviathanAPIError(data.get("detail", "Content request failed"), response.status, data.get("code", "HTTP_ERROR"), response.headers.get("Retry-After"))
|
|
46
|
+
return data
|
|
47
|
+
except (urllib.error.URLError, TimeoutError, OSError):
|
|
48
|
+
raise LeviathanAPIError("The content request could not complete. Check connectivity and retry.") from None
|
|
49
|
+
|
|
50
|
+
def list_resources(self, q=None, kind=None, limit=20, cursor=None):
|
|
51
|
+
if q is not None and (not isinstance(q, str) or len(q) > 200):
|
|
52
|
+
raise ValueError("q must be a string of at most 200 characters")
|
|
53
|
+
if kind is not None and kind not in ("article", "service"):
|
|
54
|
+
raise ValueError("kind must be article or service")
|
|
55
|
+
if type(limit) is not int or not 1 <= limit <= 50:
|
|
56
|
+
raise ValueError("limit must be from 1 to 50")
|
|
57
|
+
if cursor is not None and (not isinstance(cursor, str) or not 1 <= len(cursor) <= 100 or any(c not in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" for c in cursor)):
|
|
58
|
+
raise ValueError("cursor must come from a previous resource page")
|
|
59
|
+
params = {"limit": limit}
|
|
60
|
+
for key, value in (("q", q), ("kind", kind), ("cursor", cursor)):
|
|
61
|
+
if value is not None:
|
|
62
|
+
params[key] = value
|
|
63
|
+
return self._request("/api/v1/resources?" + urllib.parse.urlencode(params))
|
|
64
|
+
|
|
65
|
+
def resource_pages(self, **options):
|
|
66
|
+
cursor = options.pop("cursor", None)
|
|
67
|
+
seen = set()
|
|
68
|
+
while True:
|
|
69
|
+
page = self.list_resources(cursor=cursor, **options)
|
|
70
|
+
yield page
|
|
71
|
+
cursor = page.get("next_cursor")
|
|
72
|
+
if not cursor:
|
|
73
|
+
return
|
|
74
|
+
if cursor in seen:
|
|
75
|
+
raise LeviathanAPIError("The server repeated a cursor", code="INVALID_RESPONSE")
|
|
76
|
+
seen.add(cursor)
|
|
77
|
+
|
|
78
|
+
def read_resource(self, resource_id):
|
|
79
|
+
import re
|
|
80
|
+
if not isinstance(resource_id, str) or len(resource_id) > 210 or not re.fullmatch(r"(?:article|service):[a-z0-9-]+", resource_id):
|
|
81
|
+
raise ValueError("Use an article:slug or service:slug catalog ID")
|
|
82
|
+
return self._request("/api/v1/resources/" + urllib.parse.quote(resource_id, safe=""))
|
|
83
|
+
|
|
84
|
+
def company_profile(self):
|
|
85
|
+
return self._request("/api/machine/home")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "leviathan-public-content"
|
|
7
|
+
version = "1.0.1"
|
|
8
|
+
description = "Official read-only Python client for Leviathan Systems published resources"
|
|
9
|
+
readme = "SDK.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "LicenseRef-Proprietary"
|
|
12
|
+
authors = [{name = "Leviathan Systems"}]
|
|
13
|
+
keywords = ["leviathan-systems", "gpu-deployment", "public-content"]
|
|
14
|
+
dependencies = []
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://www.leviathansystems.co/developers/sdk"
|
|
18
|
+
Documentation = "https://www.leviathansystems.co/developers"
|
|
19
|
+
Source = "https://github.com/leviathansystems-gpu/public-content"
|
|
20
|
+
Issues = "https://github.com/leviathansystems-gpu/public-content/issues"
|
|
21
|
+
|
|
22
|
+
[tool.setuptools]
|
|
23
|
+
py-modules = ["leviathan_public_content"]
|