Skip to content

Commit

Permalink
PLAT-1030: Add an endpoint for fetching credentials for accessing the…
Browse files Browse the repository at this point in the history
… private models bucket

GitOrigin-RevId: 0214949fa59bf0cc5e630e293c8dd84ad346ce53
  • Loading branch information
misberner committed Aug 25, 2023
1 parent 31627e5 commit 0769919
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 0 deletions.
85 changes: 85 additions & 0 deletions docs/rest/OptApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Method | HTTP request | Description
------------- | ------------- | -------------
[**get_container_login**](OptApi.md#get_container_login) | **GET** /opt/containers/get_login | Get Gretel container Docker login credentials
[**get_licenses**](OptApi.md#get_licenses) | **GET** /opt/licenses | Get Gretel Backend/Worker licenses
[**get_model_credentials**](OptApi.md#get_model_credentials) | **GET** /opt/models/get_credentials | Get Gretel models fetching credentials


# **get_container_login**
Expand Down Expand Up @@ -146,3 +147,87 @@ This endpoint does not need any parameter.

[[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)

# **get_model_credentials**
> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} get_model_credentials(uid)
Get Gretel models fetching credentials

### Example

* Api Key Authentication (ApiKey):
```python
import time
import gretel_client.rest
from gretel_client.rest.api import opt_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 = opt_api.OptApi(api_client)
uid = "uid_example" # str |
type = "train" # str | (optional)

# example passing only required values which don't have defaults set
try:
# Get Gretel models fetching credentials
api_response = api_instance.get_model_credentials(uid)
pprint(api_response)
except gretel_client.rest.ApiException as e:
print("Exception when calling OptApi->get_model_credentials: %s\n" % e)

# example passing only required values which don't have defaults set
# and optional values
try:
# Get Gretel models fetching credentials
api_response = api_instance.get_model_credentials(uid, type=type)
pprint(api_response)
except gretel_client.rest.ApiException as e:
print("Exception when calling OptApi->get_model_credentials: %s\n" % e)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**uid** | **str**| |
**type** | **str**| | [optional]

### 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** | Models fetching credentials | - |

[[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)

115 changes: 115 additions & 0 deletions src/gretel_client/rest/api/opt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,118 @@ def __get_licenses(self, **kwargs):
api_client=api_client,
callable=__get_licenses,
)

def __get_model_credentials(self, uid, **kwargs):
"""Get Gretel models fetching credentials # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_model_credentials(uid, async_req=True)
>>> result = thread.get()
Args:
uid (str):
Keyword Args:
type (str): [optional]
_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")
kwargs["uid"] = uid
return self.call_with_http_info(**kwargs)

self.get_model_credentials = _Endpoint(
settings={
"response_type": (
{
str: (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
none_type,
)
},
),
"auth": ["ApiKey"],
"endpoint_path": "/opt/models/get_credentials",
"operation_id": "get_model_credentials",
"http_method": "GET",
"servers": None,
},
params_map={
"all": [
"uid",
"type",
],
"required": [
"uid",
],
"nullable": [],
"enum": [
"type",
],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {
("type",): {"TRAIN": "train", "RUN": "run"},
},
"openapi_types": {
"uid": (str,),
"type": (str,),
},
"attribute_map": {
"uid": "uid",
"type": "type",
},
"location_map": {
"uid": "query",
"type": "query",
},
"collection_format_map": {},
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
callable=__get_model_credentials,
)

0 comments on commit 0769919

Please sign in to comment.