softlayer-go | SoftLayer API Client for the Go Language | REST library
kandi X-RAY | softlayer-go Summary
kandi X-RAY | softlayer-go Summary
This library contains a complete implementation of the SoftLayer API for client application development in the Go programming language. Code for each API data type and service method is pre-generated, using the SoftLayer API metadata endpoint as input, thus ensuring 100% coverage of the API right out of the gate. It was designed to feel as natural as possible for programmers familiar with other popular SoftLayer SDKs, and attempts to minimize unnecessary boilerplate and type assertions where possible.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- SelectProductPricesByCategory filters product items by category code
- makeHTTPRequest makes an HTTP request
- New initializes a new session
- UpgradeVirtualGuestWithPreset upgrades a virtual guest to a virtual guest .
- generateAPI is used to generate the API code
- UpgradeVirtualGuest upgrades a virtual guest .
- VlanListCommand handles VlanList command
- VlanDetailCommand handles the detail of a VLAN .
- testHelpers is a test - spy implementation of test helpers
- Run executes the API call .
softlayer-go Key Features
softlayer-go Examples and Code Snippets
package main
import (
"fmt"
"log"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
"github.com/softlayer/softlayer-go/session"
"github.com/softlayer/softlayer-go/sl"
)
func main() {
sess := session.
accountService := services.GetAccountService(sess)
accountService.
Mask("id;hostname").
Filter(`{"virtualGuests":{"domain":{"operation":"example.com"}}}`).
GetObject()
accountServiceWithMaskAndFilter = accountService.Mask("id;hostname").
Filter
func main() {
// Create a session specifying an XML-RPC endpoint url.
sess := &session.Session{
Endpoint: "https://api.softlayer.com/xmlrpc/v3",
}
// Get a token from the api using your username and password
userServi
Community Discussions
Trending Discussions on softlayer-go
QUESTION
Using examples in Go SDK
with Username and apikey
returned
...{"error":"Access Denied. ","code":"SoftLayer_Exception_Public"}
ANSWER
Answered 2017-Dec-21 at 14:58I didn't have issues when running your code, I recommend to check the username and apikey you are sending. See the API Access Information section in your profile https://control.softlayer.com/account/user/profile
QUESTION
I am using the softlayer go client https://github.com/softlayer/softlayer-go
I am not able to close the softlayer session. How do I do that?
I have created the softlayer session using the Session.New()
API.
Reference:- https://github.com/softlayer/softlayer-go/blob/master/session/session.go
ANSWER
Answered 2019-Feb-14 at 15:29The https://github.com/softlayer/softlayer-go/blob/master/session/session.go basically configures the go-client by storing the username, apiKey, endpoint, timeout, etc., in variables, which are used every time do a request to the API.
If you review the SoftLayer API, it doesn't have any method that will create/close a session, so if you want to simulate something similar then I think you can try by sending blank values to Session.New()
and removing any value stored in ~/.softlayer
file
QUESTION
I am trying to fetch SnapshotCapacityGb
relational datatype in go. Here is what I have:
ANSWER
Answered 2018-Aug-22 at 20:56Some network storage devices have not a snapshot, so the snapshotCapacityGb value isn’t present in the response or it is null. Since you are able to retrieve that value by using REST, probably the go-client is using XML-RPC endpoint so I suggest trying with the REST endpoint:
QUESTION
I have the following piece of gloang code. ALthough this works I cannot see the relational property primaryRouter
in the result.
package main
...ANSWER
Answered 2018-Aug-22 at 14:25Try in your code with the REST endpoint, like this example:
QUESTION
I am having trouble with the GetLocations call. Every time I try to execute it I receive the error:
SoftLayer_Exception: Object does not exist to execute method on. (SoftLayer_Location_Group::getLocations) (HTTP 200)
This makes me think that there is something wrong with the locationService object I created but I don't understand what. Does anyone see the issue?
...ANSWER
Answered 2018-May-30 at 16:39The error that you got is because you need to use an identifier locationGroup ID.
Add this locationGroupId to you go code, like this example:
QUESTION
The api call
...ANSWER
Answered 2018-May-09 at 15:09The default endpoint is REST but in your environment you are using xmlrpc, which is probably due to the existence of the ~ / .softlayer file and in this it is configured as an XMLRPC enpoint.
For more information you can see the following documentation: https://github.com/softlayer/softlayer-go
This issue happens for the XMLRPC enpoint and you can report it in the go GitHub. https://github.com/softlayer/softlayer-go/issues/
Try in your code with the REST endpoint, like this example:
QUESTION
The api call I am using is: https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/257/getConfiguration The type returned from this call is an array of Product_Package_Order_Configuration: https://github.com/softlayer/softlayer-go/blob/master/datatypes/product.go#L1413
The issue I am seeing is that in the response, the ItemCategory field is always nil. I am not using a mask so I would think everything should be returned.
Is there some way I can modify this call to have it return ItemCategory as well?
...ANSWER
Answered 2018-May-08 at 15:13The itemCategory is a relational property and this belongs to another datatype, so you need to use object-masks over the getConfiguration method if you want to retrieve this data.
For more information you can see the following documentation:
QUESTION
When I run the below code I get the error SoftLayer_Exception_InvalidValue: Invalid value provided for 'blockDevices.device'. A device number must be provided for all block devices. (HTTP 200)
What is wrong with the way I initialize the block devices?
I see the fields, Id
and Uuid
for type Virtual_Disk_Image
, but no number. From the descriptions it sounds like these values are set post-creation.
https://github.com/softlayer/softlayer-go/blob/master/datatypes/virtual.go#L91
ANSWER
Answered 2018-May-02 at 19:39You just need to add the attribute ¨Device¨ for each Virtual_Guest_Block_Device object and the ¨ LocalDiskFlag ¨ attribute must be added once and not for each Virtual_Guest_Block_Device.
The same that this example:
QUESTION
When I add billingItemFlag to my mask and filter it is missing in the results. I am using the SoftLayer-go api from the SoftLayer GitHub account. Is my filter or mask wrong?
Please consider the following code:
...ANSWER
Answered 2018-Feb-19 at 23:49The code you posted works when using the default endpoint or any other REST endpoint. It seems an issue from API, I recommend to switch to the default endpoint or use:
https://api.softlayer.com/rest/v3.1
QUESTION
I am deploying CloudFoundry and internally calling SoftLayer API to create 250GB iSCSI disk but causes error as below.
In similar method, 500GB disk creation caused error, but 20GB or 1000GB creation were success.
Is it SoftLayer API issue or my environment changed some price list?
...ANSWER
Answered 2017-Mar-10 at 21:12The short answer is that you need to use 1000 instead 250 or 500 in this request if you wanna keep using the same filters:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install softlayer-go
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page