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

[Feature] - Transition to API v2 #104

Open
digitalforex opened this issue Jan 28, 2021 · 12 comments
Open

[Feature] - Transition to API v2 #104

digitalforex opened this issue Jan 28, 2021 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@digitalforex
Copy link

I am using "Vultr Module for WHMCS" which was coded by ModulesGarden. Additionally, you made some small modification in that module for me. I got this message from Vultt today:

Support Information for API v1
API v2 has become the default API to use when interacting with Vultr. While we will continue to maintain API v1 and are not announcing an End of Life (EOL) date today, we intend to deprecate this endpoint in the future and provide a minimum of 6 months notice prior to EOL. We strongly urge everyone currently using API v1 to begin the transition process to API v2. Do note that v1 has been updated to include the v2 IDs to help during the transition process.

Can you code the transition to API v2? what will be price?

@digitalforex digitalforex added the enhancement New feature or request label Jan 28, 2021
@shoquebd
Copy link

Hello

I have got the same problem here too. Old server ID's were numeric only like '123456' but new ID's using alphanumeric value like '4d6e-8bd8-289ea70a11e8'. Can we expect a new update of this very useful module soon? API V2 docs can be found here https://www.vultr.com/api/

Thanks

@meramsey
Copy link

meramsey commented Feb 2, 2021

i'm very interested in this as well as was just looking into the feasibility of this.

@ddymko
The real question is if they will accept PR/MR if we do go ahead and updated it to support API v2?

@digitalforex
Copy link
Author

Is v2.0.4 already built on API v2? Does anybody know?

@meramsey
Copy link

meramsey commented Feb 3, 2021

its definitely not v2 like it should be :(

If you want to help im trying to fork and port it to v2
https://github.com/whattheserver/whmcs-vultr/blob/master/servers/vultr/vendor/VultrAPI2.php

using the new reference.
https://www.vultr.com/api/#operation/update-instance

Unfortunately not everything is a 1:1 match function wise.

Feel free to help and submit MR/PR on it if interested.

I noticed a new VPS i created is using the new UUID and it does NOT work with the v1 API like they said it does.
image

@digitalforex
Copy link
Author

its definitely not v2 like it should be :(

If you want to help im trying to fork and port it to v2
https://github.com/whattheserver/whmcs-vultr/blob/master/servers/vultr/vendor/VultrAPI2.php

using the new reference.
https://www.vultr.com/api/#operation/update-instance

Unfortunately not everything is a 1:1 match function wise.

Feel free to help and submit MR/PR on it if interested.

I noticed a new VPS i created is using the new UUID and it does NOT work with the v1 API like they said it does.
image

Thanks for your help. Can we discuss details on skype or telegram? if yes, what is your ID?

@meramsey
Copy link

meramsey commented Feb 3, 2021

@digitalforex i have neither of those. I do have a discord or matrix id

Discord
onessa#8165

Matrix
@onessa:matrix.org

@digitalforex
Copy link
Author

I just sent you a friendship request on discord. You got it?

@meramsey
Copy link

meramsey commented Feb 3, 2021

so for anyone else having issues. You can use the v1 api list to get the sub_id which is the old style id to use in whmcs to regain controls of the new VPS's, but you cannot find the sub_id from the v2 api lol.

So you can reverse lookup the old style id from v1 api and manually enter it into the Virtual machine ID custom field so it works in the current plugin as a temporary measure for new server orders being received.

https://www.vultr.com/api/v1/#server_server_list

curl -H 'API-Key: YOURKEY' "https://api.vultr.com/v1/server/list"

Filter the output or paste into notepad editor find by the new uuid which is in v2_id field or hostname
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "label=server.domain.tld" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "main_ip=1.1.1.1" "https://api.vultr.com/v1/server/list"

new apiv2 is based on instances
https://www.vultr.com/api/#operation/list-instances

@Ocean-2021
Copy link

Hello

I also use the Vultr module, but I have no programming experience what so ever. Will this be released as a new release once its been fixed. Is there anyone that can help me get my existing module working as it was fine up until the API change

I would really appreciate it

Thanks in advance

@taufiqshovon
Copy link

so for anyone else having issues. You can use the v1 api list to get the sub_id which is the old style id to use in whmcs to regain controls of the new VPS's, but you cannot find the sub_id from the v2 api lol.

So you can reverse lookup the old style id from v1 api and manually enter it into the Virtual machine ID custom field so it works in the current plugin as a temporary measure for new server orders being received.

https://www.vultr.com/api/v1/#server_server_list

curl -H 'API-Key: YOURKEY' "https://api.vultr.com/v1/server/list"

Filter the output or paste into notepad editor find by the new uuid which is in v2_id field or hostname
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "label=server.domain.tld" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "main_ip=1.1.1.1" "https://api.vultr.com/v1/server/list"

new apiv2 is based on instances
https://www.vultr.com/api/#operation/list-instances

mate are you get's any solution for this problem?

@meramsey
Copy link

so for anyone else having issues. You can use the v1 api list to get the sub_id which is the old style id to use in whmcs to regain controls of the new VPS's, but you cannot find the sub_id from the v2 api lol.
So you can reverse lookup the old style id from v1 api and manually enter it into the Virtual machine ID custom field so it works in the current plugin as a temporary measure for new server orders being received.
https://www.vultr.com/api/v1/#server_server_list
curl -H 'API-Key: YOURKEY' "https://api.vultr.com/v1/server/list"
Filter the output or paste into notepad editor find by the new uuid which is in v2_id field or hostname
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "label=server.domain.tld" "https://api.vultr.com/v1/server/list"
apikey='YOURKEY'; curl -H "API-Key: ${apikey}" -G --data "main_ip=1.1.1.1" "https://api.vultr.com/v1/server/list"
new apiv2 is based on instances
https://www.vultr.com/api/#operation/list-instances

mate are you get's any solution for this problem?

Not got any help from anyone on the new module and been busy so have not had much time to work on it. What i posted above does let you identify the old style id to manually add any newly created servers to the existing module so the controls work.

if you want to help feel free to submit MR/PR on the fork of this repo with the API2
https://github.com/whattheserver/whmcs-vultr

It will require reworking alot of stuff so that the new api functions responses are usable in the existing one

@meramsey
Copy link

I made some more progress on the V2 API class and actually ran through all the methods manually to confirm they work with a test vps and domains for stuff. I also looked for obvious changes in the format of the responses and tried to normalize it back to what the current module expects despite being from v2 API. It's possible i missed something but I did find and fix alot of stuff i had missed on my first pass through in porting the class to v2.

meramsey@55a535a#diff-c6af820745a34805dc426e20720fa27ab8c92221f5716abdcfc47124f84e1486

The UI as some of you are probably aware is kinda long overdue for an upgrade being like bootstrap 3.2 and jquery old... So if someone comfortable with updating the UI aspect to the new bootstrap v4 style stuff built into whmcs 8.1.x that would be super helpful.

Things left to do.

  • Try swapping in the V2 API class for the V1 API class and see what's broken.
  • Code a function to read all the SUBIDs from old format customfields and then lookup their new v2_id and save that in the same spot as the subid...... Alternatively we could add a new custom field in the version bump for v2_id and that would leave the old value as a fallback till old v1 api is truly unusable but makes things messier in the database.
  • Update the UI (NOT my area of expertise but will be needed so )

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

No branches or pull requests

6 participants