graphlit-client 0.1.3__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Graphlit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.1
2
+ Name: graphlit_client
3
+ Version: 0.1.3
4
+ Summary: A package for creating tokens for Graphlit services
5
+ Home-page: https://github.com/graphlit/graphlit-client-python
6
+ Author: Graphlit
7
+ Author-email: questions@graphlit.com
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: PyJWT
11
+
12
+ # graphlit-client-python
13
+
14
+ ## Overview
15
+
16
+ The Graphlit Client for Python enables easy interaction with the Graphlit API, allowing developers to execute queries and mutations against the Graphlit service. This document outlines the setup process and provides a basic example of using the client.
17
+
18
+ ## Prerequisites
19
+
20
+ Before you begin, ensure you have the following:
21
+
22
+ - Python 3.x installed on your system.
23
+ - An active account on [graphlit.com](https://portal.graphlit.dev) with access to the API settings dashboard.
24
+
25
+ ## Installation
26
+
27
+ To install the Graphlit Client, use pip:
28
+
29
+ ```bash
30
+ pip install graphlit-client
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ The Graphlit Client requires three environment variables to be set for authentication and configuration:
36
+
37
+ - `ENVIRONMENT_ID`: Your environment ID.
38
+ - `ORGANIZATION_ID`: Your organization ID.
39
+ - `SECRET_KEY`: Your secret key for API access.
40
+
41
+ You can find these values in the API settings dashboard on [graphlit.com](https://portal.graphlit.dev).
42
+
43
+ ### Setting Environment Variables
44
+
45
+ To set these environment variables on your system, use the following commands, replacing `your_value` with the actual values from your account.
46
+
47
+ For Unix/Linux/macOS:
48
+
49
+ ```bash
50
+ export ENVIRONMENT_ID=your_environment_id_value
51
+ export ORGANIZATION_ID=your_organization_id_value
52
+ export SECRET_KEY=your_secret_key_value
53
+ ```
54
+
55
+ For Windows Command Prompt (CMD):
56
+
57
+ ```cmd
58
+ set ENVIRONMENT_ID=your_environment_id_value
59
+ set ORGANIZATION_ID=your_organization_id_value
60
+ set SECRET_KEY=your_secret_key_value
61
+ ```
62
+
63
+ For Windows PowerShell:
64
+
65
+ ```powershell
66
+ $env:ENVIRONMENT_ID="your_environment_id_value"
67
+ $env:ORGANIZATION_ID="your_organization_id_value"
68
+ $env:SECRET_KEY="your_secret_key_value"
69
+ ```
70
+
71
+ ## Usage Example
72
+
73
+ Here's a simple example of how to use the Graphlit Client to create a Feed.
74
+
75
+ ```python
76
+ from graphlit_client import Graphlit
77
+
78
+ # Initialize the client
79
+ client = Graphlit()
80
+
81
+ # Print the client token
82
+ print(client.token)
83
+
84
+ # Execute a query
85
+ response = client.request(query="""
86
+ mutation CreateFeed($feed: FeedInput!) {
87
+ createFeed(feed: $feed) {
88
+ id
89
+ name
90
+ state
91
+ type
92
+ }
93
+ }""", variables={
94
+ "feed": {
95
+ "type": "WEB",
96
+ "web": {
97
+ "uri": "https://openai.com/blog"
98
+ },
99
+ "name": "OpenAI Blog"
100
+ }
101
+ })
102
+
103
+ # Print the response
104
+ print(response)
105
+ ```
106
+
107
+ ## Support
108
+
109
+ For issues and support with the Graphlit Client or API,
110
+ Please refer to the [documentation](https://docs.graphlit.dev/) and
111
+ join our [Discord](https://discord.gg/ygFmfjy3Qx) community.
@@ -0,0 +1,100 @@
1
+ # graphlit-client-python
2
+
3
+ ## Overview
4
+
5
+ The Graphlit Client for Python enables easy interaction with the Graphlit API, allowing developers to execute queries and mutations against the Graphlit service. This document outlines the setup process and provides a basic example of using the client.
6
+
7
+ ## Prerequisites
8
+
9
+ Before you begin, ensure you have the following:
10
+
11
+ - Python 3.x installed on your system.
12
+ - An active account on [graphlit.com](https://portal.graphlit.dev) with access to the API settings dashboard.
13
+
14
+ ## Installation
15
+
16
+ To install the Graphlit Client, use pip:
17
+
18
+ ```bash
19
+ pip install graphlit-client
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ The Graphlit Client requires three environment variables to be set for authentication and configuration:
25
+
26
+ - `ENVIRONMENT_ID`: Your environment ID.
27
+ - `ORGANIZATION_ID`: Your organization ID.
28
+ - `SECRET_KEY`: Your secret key for API access.
29
+
30
+ You can find these values in the API settings dashboard on [graphlit.com](https://portal.graphlit.dev).
31
+
32
+ ### Setting Environment Variables
33
+
34
+ To set these environment variables on your system, use the following commands, replacing `your_value` with the actual values from your account.
35
+
36
+ For Unix/Linux/macOS:
37
+
38
+ ```bash
39
+ export ENVIRONMENT_ID=your_environment_id_value
40
+ export ORGANIZATION_ID=your_organization_id_value
41
+ export SECRET_KEY=your_secret_key_value
42
+ ```
43
+
44
+ For Windows Command Prompt (CMD):
45
+
46
+ ```cmd
47
+ set ENVIRONMENT_ID=your_environment_id_value
48
+ set ORGANIZATION_ID=your_organization_id_value
49
+ set SECRET_KEY=your_secret_key_value
50
+ ```
51
+
52
+ For Windows PowerShell:
53
+
54
+ ```powershell
55
+ $env:ENVIRONMENT_ID="your_environment_id_value"
56
+ $env:ORGANIZATION_ID="your_organization_id_value"
57
+ $env:SECRET_KEY="your_secret_key_value"
58
+ ```
59
+
60
+ ## Usage Example
61
+
62
+ Here's a simple example of how to use the Graphlit Client to create a Feed.
63
+
64
+ ```python
65
+ from graphlit_client import Graphlit
66
+
67
+ # Initialize the client
68
+ client = Graphlit()
69
+
70
+ # Print the client token
71
+ print(client.token)
72
+
73
+ # Execute a query
74
+ response = client.request(query="""
75
+ mutation CreateFeed($feed: FeedInput!) {
76
+ createFeed(feed: $feed) {
77
+ id
78
+ name
79
+ state
80
+ type
81
+ }
82
+ }""", variables={
83
+ "feed": {
84
+ "type": "WEB",
85
+ "web": {
86
+ "uri": "https://openai.com/blog"
87
+ },
88
+ "name": "OpenAI Blog"
89
+ }
90
+ })
91
+
92
+ # Print the response
93
+ print(response)
94
+ ```
95
+
96
+ ## Support
97
+
98
+ For issues and support with the Graphlit Client or API,
99
+ Please refer to the [documentation](https://docs.graphlit.dev/) and
100
+ join our [Discord](https://discord.gg/ygFmfjy3Qx) community.
@@ -0,0 +1 @@
1
+ from .client import Graphlit
@@ -0,0 +1,49 @@
1
+ import os
2
+ import requests
3
+ import jwt
4
+ import datetime
5
+
6
+ class Graphlit:
7
+ def __init__(self, environment_id=None, organization_id=None, secret_key=None):
8
+ # Get environment variables or use default values
9
+ self.issuer = os.getenv("ISSUER", "graphlit")
10
+ self.audience = os.getenv("AUDIENCE", "https://portal.graphlit.io")
11
+ self.role = os.getenv("ROLE", "Owner")
12
+
13
+ # Get other environment variables or use parameters
14
+ self.environment_id = environment_id if environment_id is not None else os.getenv("ENVIRONMENT_ID")
15
+ self.organization_id = organization_id if organization_id is not None else os.getenv("ORGANIZATION_ID")
16
+ self.secret_key = secret_key if secret_key is not None else os.getenv("SECRET_KEY")
17
+
18
+ self.base_url = "https://data-scus.graphlit.io/api/v1" # Example base URL
19
+
20
+ # Specify the expiration (one hour from now)
21
+ expiration = datetime.datetime.utcnow() + datetime.timedelta(hours=1)
22
+
23
+ # Define the payload
24
+ payload = {
25
+ "https://graphlit.io/jwt/claims": {
26
+ "x-graphlit-environment-id": self.environment_id,
27
+ "x-graphlit-organization-id": self.organization_id,
28
+ "x-graphlit-role": self.role,
29
+ },
30
+ "exp": expiration,
31
+ "iss": self.issuer,
32
+ "aud": self.audience,
33
+ }
34
+
35
+ # Sign the JWT
36
+ self.token = jwt.encode(payload, self.secret_key, algorithm="HS256")
37
+
38
+ def request(self, query, variables={}):
39
+ token = self.token
40
+ headers = {
41
+ "Authorization": f"Bearer {token}",
42
+ "Content-Type": "application/json"
43
+ }
44
+ payload = {
45
+ "query": query,
46
+ "variables": variables
47
+ }
48
+ response = requests.post(f"{self.base_url}/graphql", json=payload, headers=headers)
49
+ return response.json()
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.1
2
+ Name: graphlit-client
3
+ Version: 0.1.3
4
+ Summary: A package for creating tokens for Graphlit services
5
+ Home-page: https://github.com/graphlit/graphlit-client-python
6
+ Author: Graphlit
7
+ Author-email: questions@graphlit.com
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: PyJWT
11
+
12
+ # graphlit-client-python
13
+
14
+ ## Overview
15
+
16
+ The Graphlit Client for Python enables easy interaction with the Graphlit API, allowing developers to execute queries and mutations against the Graphlit service. This document outlines the setup process and provides a basic example of using the client.
17
+
18
+ ## Prerequisites
19
+
20
+ Before you begin, ensure you have the following:
21
+
22
+ - Python 3.x installed on your system.
23
+ - An active account on [graphlit.com](https://portal.graphlit.dev) with access to the API settings dashboard.
24
+
25
+ ## Installation
26
+
27
+ To install the Graphlit Client, use pip:
28
+
29
+ ```bash
30
+ pip install graphlit-client
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ The Graphlit Client requires three environment variables to be set for authentication and configuration:
36
+
37
+ - `ENVIRONMENT_ID`: Your environment ID.
38
+ - `ORGANIZATION_ID`: Your organization ID.
39
+ - `SECRET_KEY`: Your secret key for API access.
40
+
41
+ You can find these values in the API settings dashboard on [graphlit.com](https://portal.graphlit.dev).
42
+
43
+ ### Setting Environment Variables
44
+
45
+ To set these environment variables on your system, use the following commands, replacing `your_value` with the actual values from your account.
46
+
47
+ For Unix/Linux/macOS:
48
+
49
+ ```bash
50
+ export ENVIRONMENT_ID=your_environment_id_value
51
+ export ORGANIZATION_ID=your_organization_id_value
52
+ export SECRET_KEY=your_secret_key_value
53
+ ```
54
+
55
+ For Windows Command Prompt (CMD):
56
+
57
+ ```cmd
58
+ set ENVIRONMENT_ID=your_environment_id_value
59
+ set ORGANIZATION_ID=your_organization_id_value
60
+ set SECRET_KEY=your_secret_key_value
61
+ ```
62
+
63
+ For Windows PowerShell:
64
+
65
+ ```powershell
66
+ $env:ENVIRONMENT_ID="your_environment_id_value"
67
+ $env:ORGANIZATION_ID="your_organization_id_value"
68
+ $env:SECRET_KEY="your_secret_key_value"
69
+ ```
70
+
71
+ ## Usage Example
72
+
73
+ Here's a simple example of how to use the Graphlit Client to create a Feed.
74
+
75
+ ```python
76
+ from graphlit_client import Graphlit
77
+
78
+ # Initialize the client
79
+ client = Graphlit()
80
+
81
+ # Print the client token
82
+ print(client.token)
83
+
84
+ # Execute a query
85
+ response = client.request(query="""
86
+ mutation CreateFeed($feed: FeedInput!) {
87
+ createFeed(feed: $feed) {
88
+ id
89
+ name
90
+ state
91
+ type
92
+ }
93
+ }""", variables={
94
+ "feed": {
95
+ "type": "WEB",
96
+ "web": {
97
+ "uri": "https://openai.com/blog"
98
+ },
99
+ "name": "OpenAI Blog"
100
+ }
101
+ })
102
+
103
+ # Print the response
104
+ print(response)
105
+ ```
106
+
107
+ ## Support
108
+
109
+ For issues and support with the Graphlit Client or API,
110
+ Please refer to the [documentation](https://docs.graphlit.dev/) and
111
+ join our [Discord](https://discord.gg/ygFmfjy3Qx) community.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ graphlit_client/__init__.py
5
+ graphlit_client/client.py
6
+ graphlit_client.egg-info/PKG-INFO
7
+ graphlit_client.egg-info/SOURCES.txt
8
+ graphlit_client.egg-info/dependency_links.txt
9
+ graphlit_client.egg-info/requires.txt
10
+ graphlit_client.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ graphlit_client
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ # Read the content of your README file
4
+ with open("README.md", "r", encoding="utf-8") as fh:
5
+ long_description = fh.read()
6
+
7
+ setup(
8
+ name='graphlit_client',
9
+ version='0.1.3',
10
+ packages=find_packages(),
11
+ install_requires=[
12
+ 'PyJWT',
13
+ ],
14
+ author='Graphlit',
15
+ author_email='questions@graphlit.com',
16
+ description='A package for creating tokens for Graphlit services',
17
+ url='https://github.com/graphlit/graphlit-client-python',
18
+ long_description=long_description,
19
+ long_description_content_type="text/markdown",
20
+ )