Add profile support to /uploads/schedule/

Pass in the name of a profile in the `profile` field, or pass in
one-time use settings in the `settings` object.
This commit is contained in:
Brian C. Lane 2019-09-06 15:11:39 -07:00
parent fd2330c4b7
commit 0eda252d61

View File

@ -193,7 +193,7 @@ def v1_compose_start():
should look like this. The "upload" object is optional.
The upload object can specify either a pre-existing profile to use (as returned by
`/uploads/providers` or one-time use settings for the provider.
`/uploads/providers`) or one-time use settings for the provider.
Example with upload profile::
@ -575,7 +575,18 @@ def v1_compose_uploads_schedule(compose_uuid):
**POST /api/v1/uploads/schedule/<compose_uuid>**
Example request::
The body can specify either a pre-existing profile to use (as returned by
`/uploads/providers`) or one-time use settings for the provider.
Example with upload profile::
{
"image_name": "My Image",
"provider": "azure",
"profile": "production-azure-settings"
}
Example with upload settings::
{
"image_name": "My Image",
@ -610,7 +621,12 @@ def v1_compose_uploads_schedule(compose_uuid):
try:
image_name = parsed["image_name"]
provider_name = parsed["provider"]
settings = parsed["settings"]
if "profile" in parsed:
# Load a specific profile for this provider
profile = parsed["profile"]
settings = load_settings(api.config["COMPOSER_CFG"]["upload"], provider_name, profile)
else:
settings = parsed["settings"]
except KeyError as e:
error = {"id": UPLOAD_ERROR, "msg": f'Missing parameter {str(e)}!'}
return jsonify(status=False, errors=[error]), 400