Skip to content

Commit

Permalink
New Version! (1.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGamingYT committed Jan 12, 2024
1 parent d073b58 commit 891f1fc
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 12 deletions.
2 changes: 1 addition & 1 deletion envhub/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_var(name: str) -> str:
if r.status_code == 200:
return r.json()["value"]
else:
raise ConnectionError(r.json())
raise ConnectionError("An error occured with the API. Status Code: " + r.status_code + " Message: " + r.text)

def set_var(name: str, value: str) -> str:
"""
Expand Down
12 changes: 11 additions & 1 deletion package/EnvHub.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Metadata-Version: 2.1
Name: EnvHub
Version: 1.0
Version: 1.1
Summary: UNKNOWN
Home-page: https://github.com/RyanBaig/EnvHub-Python
Author: RyanBaig
License: UNKNOWN
Description:
# EnvHub Python SDK
## Hello, This is the **official** Python SDK for [EnvHub](https://envhub.ryanbaig.vercel.app).

Platform: UNKNOWN
Description-Content-Type: text/markdown
6 changes: 3 additions & 3 deletions package/EnvHub.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LICENSE
README.md
setup.py
EnvHub.egg-info/PKG-INFO
EnvHub.egg-info/SOURCES.txt
EnvHub.egg-info/dependency_links.txt
EnvHub.egg-info/top_level.txt
envhub/__init__.py
envhub/api.py
EnvHub.egg-info/top_level.txt
2 changes: 1 addition & 1 deletion package/EnvHub.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
envhub

42 changes: 36 additions & 6 deletions package/build/lib/envhub/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,51 @@
import requests
from requests.exceptions import ConnectionError

def get_var(name):
def get_var(name: str) -> str:
"""
Retrieves the value of a variable from the EnvHub API.
Parameters:
name (str): The name of the variable to retrieve.
Returns:
str: The value of the variable.
Raises:
ConnectionError: If the API request fails or returns an error.
"""
r = requests.get('https://envhub.ryanbaig.vercel.app/api/vars?varName=' + name)
r = requests.get('https://envhub.ryanbaig.vercel.app/api/vars/get?varName=' + name)
if r.status_code == 200:
return r.json()["value"]
else:
raise ConnectionError(r.json())
raise ConnectionError("An error occured with the API. Status Code: " + r.status_code + " Message: " + r.text)

def set_var(name: str, value: str) -> str:
"""
Sends a POST request to the 'https://envhub.ryanbaig.vercel.app/api/vars/set' endpoint to set a variable in the environment hub.
Args:
name (str): The name of the variable.
value (str): The value of the variable.
Returns:
str: The new value of the variable as returned by the API.
Raises:
ConnectionError: If there is a connection error or if the API response indicates an error.
"""

body = {
"varName": name,
"varValue": value,
}


r = requests.post('https://envhub.ryanbaig.vercel.app/api/vars/set', json=body)
if r.status_code == 200 and r.json()["statusCode"] == 200:
# I should return what in this scenario? ans: the new value
return r.json()
else:
raise ConnectionError(r.json())


Binary file removed package/dist/EnvHub-1.0-py3-none-any.whl
Binary file not shown.
Binary file removed package/dist/EnvHub-1.0.tar.gz
Binary file not shown.
Binary file added package/dist/EnvHub-1.1-py3-none-any.whl
Binary file not shown.
Binary file added package/dist/EnvHub-1.1.tar.gz
Binary file not shown.

0 comments on commit 891f1fc

Please sign in to comment.