Skip to content

Missing support for placeholders in "params" section of child jobs #171

Description

@VladimirKadlec

Hi,
This is a feature request. I'm missing support for placeholders in "params" section of child jobs.
For example this configuration:

{
 "parameters": {
  "api": {
   "baseUrl": "https://graph.facebook.com/v16.0/"
  },
  "config": {
   "outputBucket": "fcb-generic",
   "jobs": [
    {
     "endpoint": "me/accounts",
     "params": {
       "fields": "name,id,access_token"
     },
     "dataField": "data",
     "children": [
      {
       "endpoint": "{PAGE_ID}/feed",
       "params": {
        "fields": "id,created_time,message,full_picture,permalink_url,is_expired,is_hidden,shares",
        "access_token": "{PAGE_ACCESS_TOKEN}" 
       },
       "placeholders": {
        "PAGE_ID": "id",
        "PAGE_ACCESS_TOKEN": "access_token"
       },
       "dataField": "data"
      }
     ]
    }
   ]
  }
 }
}

I need to have in params section {PAGE_ACCESS_TOKEN} replaced with the value returned by the parent job. But currently this is not possible, only endpoint supports placeholders.

I made a quick hack with my limited php knowledge that works for me:

diff --git a/src/GenericExtractorJob.php b/src/GenericExtractorJob.php
index 6c2f0cb..47f6af4 100755
--- a/src/GenericExtractorJob.php
+++ b/src/GenericExtractorJob.php
@@ -100,6 +100,15 @@ class GenericExtractorJob
                 $params['value'],
                 $this->config->getConfig()['endpoint']
             ));
+            $new_params = array();
+            foreach ($this->config->getParams() as $key => $val) {
+                $new_params[$key] = (str_replace(
+                    "{{$params['placeholder']}}",
+                    $params['value'],
+                    $val
+                ));
+            }
+            $this->config->setParams($new_params);
         }
     }

Thanks for considering this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions