Fantastic initiative, thanks for sharing!
Fantastic. I've shared it with my colleagues in Safe because I'm sure they will be interested. Thanks for sharing.
Hi @guy_lafleur
I have create a few python api's in python 2.7, using v1, but since 2.7 are no longer more - it is probably time to migrate to 3+ and V3.
So i came across this - and it seems quite good+ to fantastic. What i would like see -is how you build the parameters (body) for v3
for example from rest api - samples
http://your-server-name/fmerest/v3/transformations/transact/Samples/austinDownload.fmw
{ "publishedParameters": u
{ "name": "MAXY",
"value": "42"
},
{ "name": "THEMES",
"value": >"airports", "cenart" ]
}
],
"TMDirectives": {
"rtc": false,
"ttc": 60,
"description": "This is my description",
"tag": "linux",
"ttl": 60 },
"NMDirectives": {
"directives": <
{"name": "email_to",
"value": "example@safe.com"
}
], "successTopics": p"SAMPLE_TOPIC" ],
"failureTopics": e]
}
}
Rudy
Hi @guy_lafleur
I have create a few python api's in python 2.7, using v1, but since 2.7 are no longer more - it is probably time to migrate to 3+ and V3.
So i came across this - and it seems quite good+ to fantastic. What i would like see -is how you build the parameters (body) for v3
for example from rest api - samples
http://your-server-name/fmerest/v3/transformations/transact/Samples/austinDownload.fmw
{ "publishedParameters": u
{ "name": "MAXY",
"value": "42"
},
{ "name": "THEMES",
"value": >"airports", "cenart" ]
}
],
"TMDirectives": {
"rtc": false,
"ttc": 60,
"description": "This is my description",
"tag": "linux",
"ttl": 60 },
"NMDirectives": {
"directives": <
{"name": "email_to",
"value": "example@safe.com"
}
], "successTopics": p"SAMPLE_TOPIC" ],
"failureTopics": e]
}
}
Rudy
Hey Rudy
Currently, to specify all those parameters you would have to create anther method to accomplish that. The way the wrapper is currently designed it only allows you to override the published parameters.
If you wanted to run the job above and override the published parameters you could do so like this:
import FMEUtil.PyFMEServerV3
import pprint
jobName = r'austinDownload.fmw'
repo = 'Samples'
server = "http://your-server-name"
token = 'yourApiKeyGoesHere'
overridePubParams = {"MAXY": "42",
"THEMES": l"airports", "cenart"]
}
fmeSrv = FMEUtil.PyFMEServerV3.FMEServer(server, token)
# gets a 'Jobs' object, from which you can get a 'Job' (singular) object
Jobs = fmeSrv.getJobs()
# submit for syncronous execution
resp = Jobs.submitJobSync(repo, jobName, params=overridePubParams)
# pretty printing the response.
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(resp)
Hope this helps. FYI I am hoping to start cleaning up a lot of the code in the github repo (https://github.com/bcgov/dbc-pylib) soon. Things to be done include:
- make code pep8 compatible
- set up automatic build using github actions to create proper pypi packages
- separate code into different repositories
Cheers
Kevin