-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* unique project helper * Rest api call helper Co-authored-by: John Myers <john@gretel.ai> Co-authored-by: Drew Newberry <drew@gretel.ai> GitOrigin-RevId: 6a2771c913c515a0c06cef16d49f282d7c8043cc
- Loading branch information
1 parent
a393d7f
commit b475304
Showing
10 changed files
with
367 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# gretel_client.rest.UsersApi | ||
|
||
All URIs are relative to *https://api-dev.gretel.cloud* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**users_me**](UsersApi.md#users_me) | **GET** /users/me | | ||
|
||
|
||
# **users_me** | ||
> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} users_me() | ||
|
||
|
||
### Example | ||
|
||
* Api Key Authentication (ApiKey): | ||
```python | ||
import time | ||
import gretel_client.rest | ||
from gretel_client.rest.api import users_api | ||
from pprint import pprint | ||
# Defining the host is optional and defaults to https://api-dev.gretel.cloud | ||
# See configuration.py for a list of all supported configuration parameters. | ||
configuration = gretel_client.rest.Configuration( | ||
host = "https://api-dev.gretel.cloud" | ||
) | ||
|
||
# The client must configure the authentication and authorization parameters | ||
# in accordance with the API server security policy. | ||
# Examples for each auth method are provided below, use the example that | ||
# satisfies your auth use case. | ||
|
||
# Configure API key authorization: ApiKey | ||
configuration.api_key['ApiKey'] = 'YOUR_API_KEY' | ||
|
||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed | ||
# configuration.api_key_prefix['ApiKey'] = 'Bearer' | ||
|
||
# Enter a context with an instance of the API client | ||
with gretel_client.rest.ApiClient(configuration) as api_client: | ||
# Create an instance of the API class | ||
api_instance = users_api.UsersApi(api_client) | ||
|
||
# example, this endpoint has no required or optional parameters | ||
try: | ||
api_response = api_instance.users_me() | ||
pprint(api_response) | ||
except gretel_client.rest.ApiException as e: | ||
print("Exception when calling UsersApi->users_me: %s\n" % e) | ||
``` | ||
|
||
|
||
### Parameters | ||
This endpoint does not need any parameter. | ||
|
||
### Return type | ||
|
||
**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | ||
|
||
### Authorization | ||
|
||
[ApiKey](../README.md#ApiKey) | ||
|
||
### HTTP request headers | ||
|
||
- **Content-Type**: Not defined | ||
- **Accept**: application/json | ||
|
||
|
||
### HTTP response details | ||
| Status code | Description | Response headers | | ||
|-------------|-------------|------------------| | ||
**200** | Get my user | - | | ||
|
||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
""" | ||
Gretel Api | ||
Gretel api definitions # noqa: E501 | ||
The version of the OpenAPI document: dev | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
|
||
import re # noqa: F401 | ||
import sys # noqa: F401 | ||
|
||
from gretel_client.rest.api_client import ApiClient | ||
from gretel_client.rest.api_client import Endpoint as _Endpoint | ||
from gretel_client.rest.model_utils import ( # noqa: F401 | ||
check_allowed_values, | ||
check_validations, | ||
date, | ||
datetime, | ||
file_type, | ||
none_type, | ||
validate_and_convert_types, | ||
) | ||
|
||
|
||
class UsersApi(object): | ||
"""NOTE: This class is auto generated by OpenAPI Generator | ||
Ref: https://openapi-generator.tech | ||
Do not edit the class manually. | ||
""" | ||
|
||
def __init__(self, api_client=None): | ||
if api_client is None: | ||
api_client = ApiClient() | ||
self.api_client = api_client | ||
|
||
def __users_me(self, **kwargs): | ||
"""users_me # noqa: E501 | ||
This method makes a synchronous HTTP request by default. To make an | ||
asynchronous HTTP request, please pass async_req=True | ||
>>> thread = api.users_me(async_req=True) | ||
>>> result = thread.get() | ||
Keyword Args: | ||
_return_http_data_only (bool): response data without head status | ||
code and headers. Default is True. | ||
_preload_content (bool): if False, the urllib3.HTTPResponse object | ||
will be returned without reading/decoding response data. | ||
Default is True. | ||
_request_timeout (float/tuple): timeout setting for this request. If one | ||
number provided, it will be total request timeout. It can also | ||
be a pair (tuple) of (connection, read) timeouts. | ||
Default is None. | ||
_check_input_type (bool): specifies if type checking | ||
should be done one the data sent to the server. | ||
Default is True. | ||
_check_return_type (bool): specifies if type checking | ||
should be done one the data received from the server. | ||
Default is True. | ||
_host_index (int/None): specifies the index of the server | ||
that we want to use. | ||
Default is read from the configuration. | ||
async_req (bool): execute request asynchronously | ||
Returns: | ||
{str: (bool, date, datetime, dict, float, int, list, str, none_type)} | ||
If the method is called asynchronously, returns the request | ||
thread. | ||
""" | ||
kwargs["async_req"] = kwargs.get("async_req", False) | ||
kwargs["_return_http_data_only"] = kwargs.get( | ||
"_return_http_data_only", True | ||
) | ||
kwargs["_preload_content"] = kwargs.get("_preload_content", True) | ||
kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) | ||
kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) | ||
kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) | ||
kwargs["_host_index"] = kwargs.get("_host_index") | ||
return self.call_with_http_info(**kwargs) | ||
|
||
self.users_me = _Endpoint( | ||
settings={ | ||
"response_type": ( | ||
{ | ||
str: ( | ||
bool, | ||
date, | ||
datetime, | ||
dict, | ||
float, | ||
int, | ||
list, | ||
str, | ||
none_type, | ||
) | ||
}, | ||
), | ||
"auth": ["ApiKey"], | ||
"endpoint_path": "/users/me", | ||
"operation_id": "users_me", | ||
"http_method": "GET", | ||
"servers": None, | ||
}, | ||
params_map={ | ||
"all": [], | ||
"required": [], | ||
"nullable": [], | ||
"enum": [], | ||
"validation": [], | ||
}, | ||
root_map={ | ||
"validations": {}, | ||
"allowed_values": {}, | ||
"openapi_types": {}, | ||
"attribute_map": {}, | ||
"location_map": {}, | ||
"collection_format_map": {}, | ||
}, | ||
headers_map={ | ||
"accept": ["application/json"], | ||
"content_type": [], | ||
}, | ||
api_client=api_client, | ||
callable=__users_me, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
High level API for interacting with the Gretel Users API | ||
""" | ||
from gretel_client.config import get_session_config | ||
from gretel_client.rest.api.users_api import UsersApi | ||
|
||
|
||
def get_me(as_dict: bool = True) -> dict: | ||
""" | ||
Retrieve current user's profile from Gretel Cloud. | ||
Returns: | ||
A dictionary with the current user's profile information. | ||
Params: | ||
as_dict: If true, will return a raw dictionary of the user's data. This is currently | ||
the only option available. | ||
""" | ||
api = get_session_config().get_api(UsersApi) | ||
resp = api.users_me() | ||
if as_dict: | ||
return resp.get("data", {}).get("me") | ||
|
||
raise NotImplementedError("Simple dict access to profile available only") |
Oops, something went wrong.