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

Filter multiple machines with the similar name #334

Closed
agusmakmun opened this issue Dec 5, 2023 · 1 comment
Closed

Filter multiple machines with the similar name #334

agusmakmun opened this issue Dec 5, 2023 · 1 comment

Comments

@agusmakmun
Copy link

agusmakmun commented Dec 5, 2023

Feature Request

For example I have many devsecops-box machines such as devsecops-box-123, devsecops-box-456, etc.

import requests

token = "xxx"
headers = {"Authorization": "Bearer " + token}
url = "https://api.hetzner.cloud/v1/servers"

params = {
    "name": "devsecops-box",
}

r = requests.get(url, headers=headers, params=params)
r.json()["servers"]

While trying above code, it's give me empty result because the filter by name need to be exactly same.

Based on documentation, there is no way for doing it. Unless we don't use filter.
https://docs.hetzner.cloud/#servers-get-all-servers

@jooola
Copy link
Member

jooola commented Dec 11, 2023

Hi @agusmakmun

I understand the need for such feature, but changing this on the API side might be a breaking change. So I am afraid this will not be implemented.

As alternative, I recommend you to use labels to query "groups" of servers. For example, you could set the group=devsecops-box label on your servers, and use params = { "label_selector": "group=devsecops-box" } to only retrieve the server you need.

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

2 participants