leaseweb / leaseweb-go-sdk Goto Github PK
View Code? Open in Web Editor NEWThe Golang SDK for Leaseweb API
Home Page: https://developer.leaseweb.com
License: Apache License 2.0
The Golang SDK for Leaseweb API
Home Page: https://developer.leaseweb.com
License: Apache License 2.0
CreateNewAbuseReportMessage should be renamed to CreateAbuseReportMessage in abuse.
Documentation should be renamed aswell.
We need to have documentation for the private networking, I would suggest keeping the documentation in the current repo in Wiki section.
We need to have documentation for the dedicated network equipment, I would suggest keeping the documentation in the current repo in Wiki section.
As a User, I want to be able to use Leaseweb dedicated network equipment functionality within the SDK.
Dedicated network equipment API gives you the ability to fully manage your dedicated network equipment.
Leaseweb dedicated network equipment:
https://developer.leaseweb.com/api-docs/dedicatednetworkequipments_v2.html
We need to have documentation for the private cloud, I would suggest keeping the documentation in the current repo in Wiki section.
DedicatedServerNullRoutes can be replaced by NullRoutes in shared types.
documentation should be updated aswell.
We need to have documentation for the abuse, I would suggest keeping the documentation in the current repo in Wiki section.
GetCredentials should be renamed to GetCredential in Private Cloud API. (s
should be removed)
Documentation should be changed aswell.
The following files got large, and it's difficult to read. It would be good to separate functionality into the multiple files.
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/dedicated_server.go
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/dedicated_server_test.go
Instead of using GET, POST, DELETE, PUT constants in rest.go, use net/http constant.
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/rest.go#L13
We need to have documentation for the IP management, I would suggest keeping the documentation in the current repo in Wiki section.
As a User, I want to have GetAbuseReportAttachments
functionality in abuse.
As a User, I want to have GetAbuseReportMessageAttachments
functionality in abuse.
We need to have documentation for the virtual servers, I would suggest keeping the documentation in the current repo in Wiki section.
We need to have documentation for the hosting, I would suggest keeping the documentation in the current repo in Wiki section.
As a User, I want to be able to use Leaseweb private networking functionality within the SDK.
Private networking API gives you the ability to create private networks, add and remove servers.
Leaseweb private networking API:
https://developer.leaseweb.com/api-docs/privatenetworks_v2.html
For dedicated server test cases, we check API key and method for each request. It would be good to check these condition for abuse
, customer_account
, floating_ip
, invoice
, private_cloud
, remote_management
tests cases.
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/dedicated_server_test.go#L13
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/dedicated_server_test.go#L14
For example for DedicatedServerApi
List
function, instead of returning (*DedicatedServers, error)
it would be better to return ([]DedicatedServer, Metadata, error)
. Then it's very clear that List
return a list of DedicatedServer
.
It is unexpected from the name to have a DedicatedServers
struct contains some metadata from the response.
We need to have documentation for the services, I would suggest keeping the documentation in the current repo in Wiki section.
As a User, I want to have GetProfile
functionality in remote management.
we noticed that the DedicatedServerApi List function in the provided code is inconsistently handling its input arguments. Specifically, the function accepts multiple arguments of different types and lengths, but it does not provide any clear guidelines on how to use these arguments, and it does not handle them consistently.
To address this issue, I suggest using a struct to store the input options for the List function, as shown in the provided code workaround. This approach provides a more structured and flexible way of handling input options and avoids the issues of inconsistently handling input arguments.
I believe this change will improve the clarity and maintainability of the code and make it easier for developers to use the List function. I welcome any feedback or suggestions on this approach and would appreciate it if the project maintainers could review and consider this change.
Thank you.
+type ListOptions struct {
+ Offset int
+ Limit int
+ IP string
+ MacAddress string
+ Site string
+ PrivateRackID string
+ PrivateNetworkCapable bool
+ PrivateNetworkEnabled bool
+}
+
func (dsa DedicatedServerApi) getPath(endpoint string) string {
return "/bareMetals/" + DEDICATED_SERVER_API_VERSION + endpoint
}
-func (dsa DedicatedServerApi) List(args ...interface{}) (*DedicatedServers, error) {
+func (dsa DedicatedServerApi) List(opts ...ListOptions) (*DedicatedServers, error) {
v := url.Values{}
- if len(args) >= 1 {
- v.Add("offset", fmt.Sprint(args[0]))
- }
- if len(args) >= 2 {
- v.Add("limit", fmt.Sprint(args[1]))
- }
- if len(args) >= 3 {
- v.Add("ip", fmt.Sprint(args[2]))
- }
- if len(args) >= 4 {
- v.Add("macAddress", fmt.Sprint(args[3]))
- }
- if len(args) >= 5 {
- v.Add("site", fmt.Sprint(args[4]))
- }
- if len(args) >= 6 {
- v.Add("privateRackId", fmt.Sprint(args[5]))
- }
- if len(args) >= 7 {
- v.Add("privateNetworkCapable", fmt.Sprint(args[6]))
- }
- if len(args) >= 8 {
- v.Add("privateNetworkEnabled", fmt.Sprint(args[7]))
+ if len(opts) > 0 {
+ opt := opts[0]
+ if opt.Offset > 0 {
+ v.Add("offset", fmt.Sprint(opt.Offset))
+ }
+ if opt.Limit > 0 {
+ v.Add("limit", fmt.Sprint(opt.Limit))
+ }
+ if opt.IP != "" {
+ v.Add("ip", opt.IP)
+ }
+ if opt.MacAddress != "" {
+ v.Add("macAddress", opt.MacAddress)
+ }
+ if opt.Site != "" {
+ v.Add("site", opt.Site)
+ }
+ if opt.PrivateRackID != "" {
+ v.Add("privateRackId", opt.PrivateRackID)
+ }
+ if opt.PrivateNetworkCapable {
+ v.Add("privateNetworkCapable", "true")
+ }
+ if opt.PrivateNetworkEnabled {
+ v.Add("privateNetworkEnabled", "true")
+ }
}
As a User, I want to be able to use Leaseweb hosting functionality within the SDK.
Hosting API gives you the ability to manage your domain DNS records and e-mail addresses, aliases and more.
Leaseweb hosting API:
https://developer.leaseweb.com/api-docs/domains_v2.html
As a User, I want to be able to use Leaseweb virtual server functionality within the SDK.
Virtual server API gives you the ability to control your virtual servers.
Leaseweb virtual server API:
https://developer.leaseweb.com/api-docs/virtualservers_v2.html
We need to have documentation for the invoice, I would suggest keeping the documentation in the current repo in Wiki section.
This way we could monitor in the API logs the usage of the SDK (see how much usage there is, which API are used the most, etc...)
See https://github.com/hetznercloud/hcloud-go/blob/main/hcloud/client.go#L340 buildUserAgent
for inspiration
We need to have documentation for the dedicated rack, I would suggest keeping the documentation in the current repo in Wiki section.
Currently to use the SDK one needs to call InitLeasewebClient
which initializes the private leasewebClient
struct as a global variable which is then used by other structs like DedicatedServerApi
to execute requests.
This approach makes it hard to work with multiple accounts (and API keys) as from my understanding, I would need to call InitLeasewebClient
each time I want to switch the API key used, which makes unnecessary initialization of a new HTTP client each time.
Furthermore given that it is a global variable it prevents any concurrency usage across different accounts' API requests.
Make it possible to initialize LeasewebClient
from the outside instead of relying on a global variable. This would require some changes to all APIs clients as now those would need to reference an instance of LeasewebClient
. For ease of use for some people globally initialized client can be a default (it is a pattern a lot of libraries follow).
We need to have documentation for the customer account, I would suggest keeping the documentation in the current repo in Wiki section.
As a User, I want to be able to use Leaseweb dedicated server functionality within the SDK.
Dedicated server API gives you the ability to fully manage your dedicated servers.
Leaseweb dedicated server API:
https://developer.leaseweb.com/api-docs/dedicatedservers_v2.html
As a User, I want to be able to use Leaseweb services functionality within the SDK.
Services API gives you the ability to get an overview of all your services. you can also cancel services.
Leaseweb services API:
https://developer.leaseweb.com/api-docs/services_v1.html
Parameters of list function in DedicatedNetworkEquipmentApi needs to convert to map
Documentation should be changed as well.
As a User, I want to be able to use Leaseweb IP management functionality within the SDK.
IP management API gives you the ability to get information about your assigned IPs and manage them.
Leaseweb IP management API:
https://developer.leaseweb.com/api-docs/ips_v2.html
GetAbuseReportMessages should be renamed to ListAbuseReportMessages in abuse
Documentation should be changed aswell.
We need to have documentation for the floating IP, I would suggest keeping the documentation in the current repo in Wiki section.
SetVersion
function from leasewebApi
is not used within the SDK, and it is redundant. please merge it with getPath
function and remove it from existing API structs.
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/rest.go#L28
https://developer.leaseweb.com/api-docs/services_v1.html#tag/Services
we need to implement filters functionality, currently we receive only offset and limit.
Documentation should be changed as well.
Parameters of listIps function in DedicatedNetworkEquipmentApi needs to convert to map.
Documentations should change as well.
Currently, we can only connect to leaseweb API by setting x-lsw-auth
in header. We need to connect to leaseweb API using OAuth as well.
We need to have documentation for the dedicated Server, I would suggest keeping the documentation in the current repo in Wiki section.
I want to be able to retrieve Attributes
within service.
https://developer.leaseweb.com/api-docs/services_v1.html#operation/services-list-get
https://github.com/majidkarimizadeh/leaseweb-go-sdk/blob/master/services.go#L22
Instead of letting each user of the SDK rewrite their own loop based on the pagination metadata to fetch a complete list, maybe this could be implemented inside the SDK in a generic way.
See https://github.com/hetznercloud/hcloud-go/blob/main/hcloud/server.go#L281 All
and AllWithOpts
for inspiration (it's also available in other files for other API endpoints)
As a User, I want to be able to use Leaseweb Dedicated rack functionality within the SDK.
Dedicated rack API gives you the ability to manage your dedicated racks.
Leaseweb dedicated rack API:
https://developer.leaseweb.com/api-docs/dedicatedRacks_v2.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.