Skip to content
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

inconsistency API on get, update and create #42

Open
ruivapps opened this issue Jul 26, 2018 · 0 comments
Open

inconsistency API on get, update and create #42

ruivapps opened this issue Jul 26, 2018 · 0 comments

Comments

@ruivapps
Copy link

please point me to the right documentation if I understand it incorrectly.
it seems some inconsistency on get_, update_ and create_ API
I am using "dashboard" as example

api/dashboard_api.py::get_ and update_ requires a parameter id.

def get_dashboard(self, id, **kwargs)

but for dashboard. it requires both id and url be unique
wavefront_api_client/models/dashboard.py

@id.setter
    def id(self, id):
        """Sets the id of this Dashboard.
        Unique identifier, also URL slug, of the dashboard  # noqa: E501
        :param id: The id of this Dashboard.  # noqa: E501
        :type: str
        """
        if id is None:
            raise ValueError("Invalid value for `id`, must not be `None`")  # noqa: E501

        self._id = id

@property
    def url(self):
        """Gets the url of this Dashboard.  # noqa: E501
        Unique identifier, also URL slug, of the dashboard  # noqa: E501
        :return: The url of this Dashboard.  # noqa: E501
        :rtype: str
        """
        return self._url

that creates a problem. when I need to create a new dashboard. How do I verify I am able to create the dashboard?

example:
currently I already have a dashboard on wavefront called: dashboard1 it has

  • id:dashboard1
  • url: dashboard1

and user defined a new text file dashboard2.txt. in dashboard2.txt defines

  • id: dashboard2
  • url: dashboard1

when I try to create new dashboard2, I can find "id" from dashboard2.txt, and check it via

api_instance.get_dashboard(id)

since dashboard2 has id "dashboard2", I will get 404 back from get_dashboard, then I assuming it's safe to create new dashboard2 by calling

api_instance.create_dashboard(body=content_of(dashboard2.txt))

but this will result in error

{"status":{"result":"ERROR","message":"Unable to create the dashboard. Perhaps a dashboard already exists at id dashboard1","code":400}}

it's similar for update_dashboard. if I have 2 dashboard on wavefront already, it has url: dashboard1 and dashboard2, and I am trying to update dashboard1 with url "dashboard2" it will result in similar error.

I understand I can call get_all_dashboard and iterate over to find all id/url or I can just use "try ... except" then try to do string match from error message, but wavefront should provide a better way to allow user to write predictable code. (try...except feels not that predictable). We migrate to wavefront this year (couple month ago) and currently we already have 438 pages of dashboard. (I think it's 25 per page) so iterate over all dashboard doesn't work well either.

if there's already code to empower user to do what I described above, then I would suggest to update documentation so users can easily find the answer. ( I didn't read the source, I was reading trying to only read Python SDK documentation linked from README.md)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant