vultr / whmcs-vultr

Vultr Module for WHMCS
Apache License 2.0
95 stars 52 forks source link

[Feature] - Transition to API v2 #104

Open digitalforex opened 3 years ago

digitalforex commented 3 years ago

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?

shoquebd commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

meramsey commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Discord onessa#8165

Matrix @onessa:matrix.org

digitalforex commented 3 years ago

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

meramsey commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

https://github.com/whattheserver/whmcs-vultr/commit/55a535a62b119d7407b9ee3085e59cc9645f4153#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.