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

How I can run api client.Server.List with ServerListOptions? #155

Open
hung0913208 opened this issue Feb 1, 2023 · 5 comments
Open

How I can run api client.Server.List with ServerListOptions? #155

hung0913208 opened this issue Feb 1, 2023 · 5 comments

Comments

@hung0913208
Copy link

The struct ServerListOptions parameters are set to be private, please public them or provide function to create ServerListOptions in detail.

Thanks
Hung Pham

@botranvan
Copy link
Contributor

To use the Server.List method with ServerListOptions in the github.com/bizflycloud/gobizfly package, you first need to import the package into your project:

import (
"github.com/bizflycloud/gobizfly"
)

Then, you can create a new Client instance and configure your ServerListOptions:

client := gobizfly.NewClient(nil)

opts := &gobizfly.ServerListOptions{
Tags: string{"Tag1", "Tag2"},
Size: 10,
Page: 1,
}

Finally, you can call the Server.List method to retrieve a list of servers from the Bizfly Cloud API:

servers, err := client.Servers.List(context.Background(), opts)
if err != nil {
// handle error
}

// use servers for whatever you need to do

@hung0913208
Copy link
Author

Sorry, are you sure about this example since here is the struct gobizfly.ServerListOptions is implemented like this.
Ảnh chụp Màn hình 2023-02-04 lúc 22 44 08

I have used your implementation and obviously fail at compiling. Here is the response of the go compiler
Ảnh chụp Màn hình 2023-02-04 lúc 22 50 01

@greatbn
Copy link
Contributor

greatbn commented Feb 7, 2023

Why do you pass unsupported fields into the ServerListOptions struct ? It does not support Tags, Size, Page field at this moment.

@greatbn
Copy link
Contributor

greatbn commented Feb 8, 2023

I think you can see this code here to have an example: https://github.com/bizflycloud/bizflyctl/blob/master/cmd/server.go#L134

@hung0913208
Copy link
Author

But I need detailed and fields, that's the reason for this ticket.

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

3 participants