Hello
I was working on KVM via the Apigee X API, following instructions from the Github repo of @lalevee (https://github.com/g-lalevee/Apigee-X-GCP-Logging), and I noticed an issue related to environment (I guess it's a typo in the repo, but...)
Let me explain with a succession of curl calls:
$ AUTH=$(gcloud auth print-access-token)
$ # List existing ENV
$ curl -XGET -H "Authorization: Bearer $AUTH" \
https://apigee.googleapis.com/v1/organizations/myOrg/environments
[
"env1",
"env2"
]
$ # CREATE a KVM, BUT by indicating an exoting ENVIRONMENT
$ curl -X POST \
-H "Content-Type: aplication/json" \
-H "Authorization: Bearer $AUTH" \
https://apigee.googleapis.com/v1/organizations/myOrg/environments/arnaduga/keyvaluemaps \
-d '{"name":"TestArnaduga","encrypted":true}'
{
"name": "TestArnaduga",
"encrypted": true
}
$ # List KVM of an inexistant env
$ curl -X GET \
-H "Authorization: Bearer $AUTH" \
https://apigee.googleapis.com/v1/organizations/myOrg/environments/arnaduga/keyvaluemaps
[
"TestArnaduga"
]
$ # Inserting key
$ curl -X POST \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json" \
https://apigee.googleapis.com/v1/organizations/myOrg/environments/arnaduga/keyvaluemaps/TestArnaduga/entries \
-d '{"name":"testKey","value":"testValue"}'
{
"name": "testKey",
"value": "testValue"
}
$ # Listing keys
$ curl -X GET \
-H "Authorization: Bearer $AUTH" \
https://apigee.googleapis.com/v1/organizations/myOrg/environments/arnaduga/keyvaluemaps/TestArnaduga/entries
{
"keyValueEntries": [
{
"name": "testKey",
"value": "testValue"
}
],
"nextPageToken": ""
}
$
TL;DR
Is it a normal situation to be able to create KVM and Keys on a environments that does not exist?
Arnaduga
This behavior seems like a bug to me. I've filed b/242051575 documenting this. (That's an internal reference) The expected behavior is a 400 response on that last curl command.
Thanks for reporting it.
No problem.
@lalevee: you have a PR on your repo 😉