akamai / cli-cloudlets

Akamai CLI for Cloudlets allows you to work with cloudlets from the Command Line
Apache License 2.0
3 stars 9 forks source link

CLI update module does not support the json downloaded with retrieve #9

Closed ralvarezrivero closed 1 year ago

ralvarezrivero commented 1 year ago

Working on an issue for a client trying to use the Cloudlets CLI module, I noticed that in order to proceed with the update command, we need to have a json file to specify in the --file flag. Having downloaded the json with the --only-match-rules flag of the retrieve option, I tried to upload the file in the following manner:

Retrieve:
akamai cloudlets --edgerc ~/.edgerc --section default retrieve --policy-id 61218 --only-match-rules > cloudlet_61218

Update:
ralvarez@sjo-lpr8l447:~$ akamai cloudlets --edgerc ~/.edgerc --section default update --policy-id 61218 --notes 'ralvarez_test_new_version' --file cloudlet_61218 
...searching for cloudlet policy-id 61218
...found policy-id 61218
Updating policy www_assurancewireless_com_request_control_policy
ERROR: Unable to update policy
{
    "errorCode": -1,
    "detail": "Validation against json-schema failed.\nSchema Location: /cloudlets/api/v2/schemas/create-nimbus_policy_version-IG-1.0.json\nErrors:\n   /matchRules/0 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/1 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/2 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/3 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/4 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/5 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/6 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/7 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/8 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/9 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n",
    "instance": "b183646d3ee522b7",
    "status": 400,
    "title": "Validation Error",
    "type": "/cloudlets/error-types/validation-error",
    "errorMessage": "Validation against json-schema failed.\nSchema Location: /cloudlets/api/v2/schemas/create-nimbus_policy_version-IG-1.0.json\nErrors:\n   /matchRules/0 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/1 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/2 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/3 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/4 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/5 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/6 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/7 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/8 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n   /matchRules/9 : object instance has properties which are not allowed by the schema: [\"matchURL\"]\n"
}

Now, I find it odd that the json produced to retrieve would not be good enough for the update directive. I instructed our client to use the PowerShell module for now, because we don't know what the update command expects. We would think this is a bug and hence I am reporting this. I would say that the code generated by one directive would be good enough for another directive in the same command, otherwise, this is not useful, easy to use or intuitive in any form or fashion.

Thanks for your help on this.

pwongcha commented 1 year ago

This is an issue only for Request Control (IG). Include a fix as part of Shared policy branch.