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

Add fetch instance vnc details api in civigo library #213

Conversation

dipu989
Copy link

@dipu989 dipu989 commented Sep 25, 2024

Ticket link

Description -
This PR aims to introduce an API for fetching the VNC details of an instance. This API will be used internally in the command: civo instance vnc INSTANCE-ID/NAME, which will be implemented in future PRs.

Please note:
This is the first part of a broader workflow. I have submitted this PR to gather incremental feedback as I continue to work on the next phase, which involves integrating the command into the CLI tool.

@dipu989
Copy link
Author

dipu989 commented Sep 25, 2024

@alessandroargentieri @uzaxirr Please review this PR 👀

instance.go Outdated
@@ -380,3 +391,15 @@ func (c *Client) SetInstanceFirewall(id, firewallID string) (*SimpleResponse, er
response, err := c.DecodeSimpleResponse(resp)
return response, err
}

// GetInstanceVNCDetails gets the VNC details for an instance
func (c *Client) GetInstanceVNCDetails(id string) (*InstanceVNCDetails, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we name it like InitInstanceVNC?
Because it's a PUT and not really a get

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense now.
I was intrigued by the naming as it felt like it's an API that gives you the VNC details. (A fetch API hence the naming as GET)
But I guess in backend, it initiates -> then gives back the result I guess.
I will make these changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the comment 👍

Comment on lines +397 to +400
resp, err := c.SendPutRequest(fmt.Sprintf("/v2/instances/%s/vnc", id), "")
if err != nil {
return nil, decodeError(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you tested it locally without mocking the API?
I don't think it will work rather it would throw that instance not found in this region error i assume

@uzaxirr
Copy link
Member

uzaxirr commented Sep 26, 2024

I tested your code locally by pulling up your branch and building the SDK locally, and as i said it was not working and threw an Bad Request error, Refer to the screenshot below.

Screenshot 2024-09-26 at 10 46 16 AM

This happened bcz you didn't passed the region in request params. Thus the default region will always be considered as NYC1 even if the SDK Client is initialised with a different region.

I have raised a PR with correct code, please refer to this: https://github.com/civo/civogo/pull/214/files#diff-f4581317ccb65231765f0fa1aec4aa2bb1c08b09fe9dc1faf095d9039483e4fdR273-R276

@uzaxirr uzaxirr closed this Sep 26, 2024
@uzaxirr
Copy link
Member

uzaxirr commented Sep 26, 2024

@dipu989 if you are keen on contributing you can take a look at:

@dipu989
Copy link
Author

dipu989 commented Sep 26, 2024

@uzaxirr I only relied UTs for the test.
Thanks and will note this for my reference on how to test it in local 👍
Yup, I will start with one of the above.

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

Successfully merging this pull request may close these issues.

3 participants