Skip to content

Commit 8bc0fd7

Browse files
authored
Merge pull request #52 from dataiku/feature/add-rss-decoding
Feature/add rss decoding
2 parents 47e189d + b1a2408 commit 8bc0fd7

8 files changed

Lines changed: 46 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Version 1.2.4](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.4) - Feature and bugfix release - 2025-02-18
4+
5+
- Fix xml decoding for content type application/rss+xml
6+
- Let use the *Other credentials* stored in the user's profile
7+
- Prevent recipe from inferring its input data types
8+
39
## [Version 1.2.3](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.3) - Feature and bugfix release - 2024-11-25
410

511
- Fix xml decoding for content type application/atom+xml

custom-recipes/api-connect/recipe.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
"parameterSetId": "secure-basic",
6666
"visibilityCondition": "model.auth_type == 'secure_basic'"
6767
},
68+
{
69+
"name": "should_use_user_secrets",
70+
"label": "User 'Other credentials'",
71+
"description": "If checked, secrets under Profile > My account > Other credentials, are available to use as {{variables}}",
72+
"type": "BOOLEAN",
73+
"defaultValue": false
74+
},
6875
{
6976
"type": "SEPARATOR",
7077
"label": "API call parameters"

custom-recipes/api-connect/recipe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dataiku.customrecipe import get_input_names_for_role, get_recipe_config, get_output_names_for_role
44
import pandas as pd
55
from safe_logger import SafeLogger
6-
from dku_utils import get_dku_key_values, get_endpoint_parameters, get_secure_credentials
6+
from dku_utils import get_dku_key_values, get_endpoint_parameters, get_secure_credentials, get_user_secrets
77
from rest_api_recipe_session import RestApiRecipeSession
88
from dku_constants import DKUConstants
99

@@ -45,12 +45,14 @@ def get_partitioning_keys(id_list, dku_flow_variables):
4545
raise ValueError("There is no parameter column selected.")
4646
parameter_renamings = get_dku_key_values(config.get("parameter_renamings", {}))
4747
custom_key_values = get_dku_key_values(config.get("custom_key_values", {}))
48+
user_secrets = get_user_secrets(config)
49+
custom_key_values.update(user_secrets)
4850
display_metadata = config.get("display_metadata", False)
4951
maximum_number_rows = config.get("maximum_number_rows", -1)
5052
input_parameters_dataset = dataiku.Dataset(input_A_names[0])
5153
partitioning_keys = get_partitioning_keys(input_parameters_dataset, dku_flow_variables)
5254
custom_key_values.update(partitioning_keys)
53-
input_parameters_dataframe = input_parameters_dataset.get_dataframe()
55+
input_parameters_dataframe = input_parameters_dataset.get_dataframe(infer_with_pandas=False)
5456

5557
recipe_session = RestApiRecipeSession(
5658
custom_key_values,

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "api-connect",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"meta": {
55
"label": "API Connect",
66
"description": "Retrieve data from any REST API",

python-connectors/api-connect_dataset/connector.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
"parameterSetId": "secure-basic",
4545
"visibilityCondition": "model.auth_type == 'secure_basic'"
4646
},
47+
{
48+
"name": "should_use_user_secrets",
49+
"label": " ",
50+
"description": "Use profile's 'other credentials'",
51+
"type": "BOOLEAN",
52+
"defaultValue": false
53+
},
4754
{
4855
"type": "SEPARATOR",
4956
"label": "API call parameters"

python-connectors/api-connect_dataset/connector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dku_utils import (
66
get_dku_key_values, get_endpoint_parameters,
77
parse_keys_for_json, get_value_from_path, get_secure_credentials,
8-
decode_csv_data, decode_bytes
8+
decode_csv_data, decode_bytes, get_user_secrets
99
)
1010
from dku_constants import DKUConstants
1111
import json
@@ -24,6 +24,8 @@ def __init__(self, config, plugin_config):
2424
secure_credentials = get_secure_credentials(config)
2525
credential = config.get("credential", {})
2626
custom_key_values = get_dku_key_values(config.get("custom_key_values", {}))
27+
user_secrets = get_user_secrets(config)
28+
custom_key_values.update(user_secrets)
2729
self.client = RestAPIClient(credential, secure_credentials, endpoint_parameters, custom_key_values)
2830
extraction_key = endpoint_parameters.get("extraction_key", None)
2931
self.extraction_key = extraction_key or ''

python-lib/dku_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ class DKUConstants(object):
22
API_RESPONSE_KEY = "api_response"
33
FORBIDDEN_KEYS = ["token", "password", "api_key_value", "secure_token"]
44
FORM_DATA_BODY_FORMAT = "FORM_DATA"
5-
PLUGIN_VERSION = "1.2.3"
5+
PLUGIN_VERSION = "1.2.4-beta.2"
66
RAW_BODY_FORMAT = "RAW"
77
REPONSE_ERROR_KEY = "dku_error"

python-lib/dku_utils.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def extract_key_using_json_path(json_dictionary, json_path):
126126
def is_reponse_xml(response):
127127
content_types = response.headers.get("Content-Type", "").split(";")
128128
for content_type in content_types:
129-
if content_type in ["text/xml", "application/soap+xml", "application/xml", "application/atom+xml"]:
129+
if content_type in ["text/xml", "application/soap+xml", "application/xml", "application/atom+xml", "application/rss+xml"]:
130130
return True
131131
return False
132132

@@ -167,3 +167,19 @@ def decode_bytes(content):
167167
if isinstance(content, bytes):
168168
content = content.decode()
169169
return content
170+
171+
172+
def get_user_secrets(configuration):
173+
should_use_user_secrets = configuration.get("should_use_user_secrets", False)
174+
if should_use_user_secrets:
175+
import dataiku
176+
logger.info("Using user's secrets:")
177+
client = dataiku.api_client()
178+
auth_info = client.get_auth_info(with_secrets=True)
179+
secrets = auth_info.get("secrets", [])
180+
user_secrets = {}
181+
for secret in secrets:
182+
logger.info("\t-'{}'".format(secret.get("key")))
183+
user_secrets[secret.get("key")] = secret.get("value")
184+
return user_secrets
185+
return {}

0 commit comments

Comments
 (0)