-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improved error messages for cloud- or oss-only commands #140
Conversation
api/templates/api.mustache
Outdated
func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}Api{{operationId}}Request) OnlyCloud() {{#structPrefix}}{{&classname}}{{/structPrefix}}Api{{operationId}}Request { | ||
r.isOnlyCloud = true | ||
return r | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote to keep things simple for now and have the OSS-vs-Cloud toggle at the API level, and not per-request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Should make it easier to keep track of what has been flagged for a specific server type for sure.
38b6293
to
712edc7
Compare
Closes #129
Note for future readers: As the review discussion indicates, we ended up only implementing chaining the
OnlyOSS()
/OnlyCloud()
methods off of API services, rather than individual requests. The original PR description is below in its entirety for reference.This PR adds the ability to set properties on individual API requests or all requests in a particular API service by chaining methods called
OnlyOSS()
orOnlyCloud()
when the requests or services are created. I also tweaked the generic "undefined response type" output to be a little more descriptive.If the request fails, the resulting error will be changed from something like this:
...to something like this:
As part of this, I set
BackupApi
andRestoreApi
to be "OnlyOSS", and theGetHealth
request of thePing
command to be "OnlyOSS" as well. We could set the entireHealthApi
to be "OnlyOSS" - I did this for demonstration purposes more than anything...and there is actually a working/ping
endpoint on cloud so maybe we'll want to use that someday.For cloud-only endpoints, the
BucketsSchemaApi
was set to "OnlyCloud", which changes the error message when trying to use the command on an OSS server:...becomes:
Future work, which is currently blocked by influxdata/influxdb#20224 (& the equivalent cloud issue), could explicitly check the
X-Influxdb-Version
based on these properties and return a more specific error message. This could even include a pre-flight check of some kind to make sure the server supports the command if they are flagged as being cloud- or oss-only before trying to execute the requests. I'll create an additional issue to document this further work when we merge this PR.