|
77 | 77 | description: "Leverage the `cache` and `branch` nodes to conditionally store or retrieve cache items." |
78 | 78 | - usecase: "[Transform XML into JSON, or JSON into XML](/plugins/datakit/examples/convert-json-to-xml-and-back/)" |
79 | 79 | description: "Transform JSON requests into XML so you can send the data to a SOAP service, then transform the resulting XML back into JSON." |
| 80 | + - usecase: "[Third-party auth with dynamic url](/plugins/datakit/examples/authenticate-third-party-with-dynamic-url/)" |
| 81 | + description: Dynamically resolve an internal authentication endpoint and inject the necessary request headers prior to proxying the request. |
80 | 82 | {% endtable %} |
81 | 83 | <!--vale on--> |
82 | 84 |
|
@@ -520,6 +522,11 @@ rows: |
520 | 522 | * `body`: Request body |
521 | 523 | * `headers`: Request headers |
522 | 524 | * `query`: Key-value pairs to encode as the request query string |
| 525 | + * `url`: The request URL resolved at runtime |
| 526 | + * `https_proxy`: The HTTPS proxy URL to use for the request |
| 527 | + * `http_proxy`: The HTTP proxy URL to use for the request |
| 528 | + * `proxy_auth_username`: The username to authenticate with the proxy |
| 529 | + * `proxy_auth_password`: The password to authenticate with the proxy |
523 | 530 | outputs: | |
524 | 531 | * `body`: The response body |
525 | 532 | * `headers`: The response headers |
@@ -655,13 +662,26 @@ Send a POST request with a JSON body: |
655 | 662 | name: Datakit |
656 | 663 | ``` |
657 | 664 |
|
| 665 | +Perform a request through a proxy server: |
| 666 | + |
| 667 | +```yaml |
| 668 | +- name: CALL |
| 669 | + type: call |
| 670 | + url: https://example.com/foo |
| 671 | + inputs: |
| 672 | + https_proxy: http://my-proxy.example.com:8080 |
| 673 | + proxy_auth_username: my-username |
| 674 | + proxy_auth_password: my-password |
| 675 | +``` |
| 676 | + |
658 | 677 | Call nodes are used in most datakit workflows. For complete examples, see: |
659 | 678 | * [Third-party auth](/plugins/datakit/examples/authenticate-third-party/) |
660 | 679 | * [Request multiplexing](/plugins/datakit/examples/combine-two-apis-into-one-response/) |
661 | 680 | * [Manipulate request headers](/plugins/datakit/examples/manipulate-request-headers/) |
662 | 681 | * [Authentication with Vault secrets](/plugins/datakit/examples/authenticate-with-vault-secret/) |
663 | 682 | * [Conditionally fetch or store cache data](/plugins/datakit/examples/conditionally-store-cached-items/) |
664 | 683 | * [Transform XML into JSON, or JSON into XML](/plugins/datakit/examples/convert-json-to-xml-and-back/) |
| 684 | +* [Third-party auth with dynamic url](/plugins/datakit/examples/authenticate-third-party-with-dynamic-url/) |
665 | 685 |
|
666 | 686 | #### Automatic JSON body handling |
667 | 687 |
|
@@ -707,6 +727,32 @@ the endpoint returns a non-2xx status code. It will also fail if the endpoint |
707 | 727 | returns a JSON mime-type in the `Content-Type` header if the response body is |
708 | 728 | not valid JSON. |
709 | 729 |
|
| 730 | +#### Resolve URL at runtime |
| 731 | + |
| 732 | +A `call` node defines its `url` statically during configuration. To substitute a different endpoint at runtime, pass a value via the `url` input. If the input is `nil`, Datakit automatically reverts to the configured static URL. |
| 733 | + |
| 734 | +For example: |
| 735 | + |
| 736 | +```yaml |
| 737 | +- name: DYNAMIC_URL |
| 738 | + type: call |
| 739 | + url: https://example.com/default |
| 740 | + inputs: |
| 741 | + url: request.body |
| 742 | +``` |
| 743 | + |
| 744 | +#### Proxy options |
| 745 | +The `call` node supports performing requests via a proxy server. This is controlled by proxy options. See above example for more details. |
| 746 | + |
| 747 | +#### Request body encoding |
| 748 | +Call node supports following content types for request body encoding: |
| 749 | +* `application/json` |
| 750 | +* `application/x-www-form-urlencoded` |
| 751 | + |
| 752 | +By default, if the body input is an object, it will be encoded as JSON. To override this behavior and use `application/x-www-form-urlencoded`, set the `Content-Type` header accordingly in the `headers` input for the call node. |
| 753 | + |
| 754 | +See [Third-party auth](/plugins/datakit/examples/authenticate-third-party/) for an example of using `application/x-www-form-urlencoded` request body encoding. |
| 755 | + |
710 | 756 | #### Limitations |
711 | 757 |
|
712 | 758 | Due to platform limitations, the `call` node can't be executed after proxying a |
@@ -1019,6 +1065,7 @@ For more detailed examples, see: |
1019 | 1065 | * [Request multiplexing](/plugins/datakit/examples/combine-two-apis-into-one-response/) |
1020 | 1066 | * [Manipulate request headers](/plugins/datakit/examples/manipulate-request-headers/) |
1021 | 1067 | * [Authentication with Vault secrets](/plugins/datakit/examples/authenticate-with-vault-secret/) |
| 1068 | +* [Third-party auth with dynamic url](/plugins/datakit/examples/authenticate-third-party-with-dynamic-url/) |
1022 | 1069 |
|
1023 | 1070 | ### Exit node |
1024 | 1071 |
|
@@ -1374,6 +1421,7 @@ For more detailed examples, see: |
1374 | 1421 | * [Third-party auth](/plugins/datakit/examples/authenticate-third-party/) |
1375 | 1422 | * [Authentication with Vault secrets](/plugins/datakit/examples/authenticate-with-vault-secret/) |
1376 | 1423 | * [Conditionally fetch or store cache data](/plugins/datakit/examples/conditionally-store-cached-items/) |
| 1424 | +* [Third-party auth with dynamic url](/plugins/datakit/examples/authenticate-third-party-with-dynamic-url/) |
1377 | 1425 |
|
1378 | 1426 | ### XML to JSON node {% new_in 3.13 %} |
1379 | 1427 |
|
|
0 commit comments