How can I get connection information of clusters in softlayer? I need public and private authentication urls for all clusters.
It seems that softlayer doesn't support the /v1/endpoints api of open stack api.
And I can see the getObjectStorageConnectionInformation api in Network Storage.. But don't know how to use it.
Try to use the following method:
SoftLayer_Network_Storage::getObjectStorageConnectionInformation, it will display the information of clusters and their endpoints (public and private)
To use this method, you need to provide an Object Storage's identifier, you can retrieve these identifiers (Object Storage identifiers), with the following REST request:
https://$username:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Account/getHubNetworkStorage
Method: Get
Note: Replace $username and $apiKey with your own information.
You will retrieve a result like this:
{
"accountId": 123456
"capacityGb": 5000
"createDate": "2015-01-20T16:21:02-04:00"
"guestId": null
"hardwareId": null
"hostId": null
"id": 41111111
"nasType": "HUB"
"password": ""
"serviceProviderId": 1
"storageTypeId": "15"
"upgradableFlag": true
"username": "SLOS123456-10"
...
Then, you can get object storage connection with the following Rest request (Use the "id" value from the previous request)
https://$username:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Network_Storage/41111111/getObjectStorageConnectionInformation
Method: Get
Note: Replace $username, $apiKey and 41111111 value with your own information
Some important references:
Managing SoftLayer Object Storage Through REST
APIs
An Introduction to Object
Storage
I'm using Advanced REST client for Chrome
Related
I am using PostMan as part of the testing regime for a WebAPI service development that I am working on. In order for external parties to gain access to our WebAPI service they first need to obtain an access token.
The POST request returns some JSON containing the required access token:
{
"access_token": "anencryptedaccesstoken",
"scope": "am_application_scope default",
"token_type": "Bearer",
"expires_in": 3218
}
I am putting together a series of integration tests which need to emulate the POST calls from POSTMAN. I am currently using System.Net.WebClient to achieve this. I am not sure what I need to do in order to achieve my goal. Here is a function that I am using to try and obtain the access token:
Public Shared Function GetAccessToken(ByVal endpoint As String, wc As WebClient) As String
Dim result As String = ""
Dim data As Byte() = Nothing
'Header information
wc.Headers.Add("Authorization", "Basic <alongencryptedstring>")
wc.Headers.Add("Content_Type", "application/x-www-form-urlencoded")
result = wc.UploadString(endpoint, "POST", "")
Return result
End Function
The 'Body' tab in PostMan contains the following entries:
grant_type - client_credentials
Content_Type - application%2Fx-www-form-urlencoded
In this instance as far as I am aware there is no 'data' element to the PostMan request hence the empty string in my use of UploadString. The function returns the following error:
"The remote server returned an error: (415) Unsupported Media Type."
I am new to web app development so please bear with me, I am finding it difficult to phrase what I think are meaningful question in the context of this post, I hope however that I have ssupplied sufficient information to convey the gist of my problem and for someone to be able to respond appropriately.
Kind Regards
Paul.
Question about security for POST method of HTTP:
I made a user called "MyAPP":
{
"userdef": [
"view",
"create"
],
"api_key": "dzn8k7hj2sdgddlvymfmefh1k2ddjl05",
"user_id": "MyAPP",
"name": "MyAPP",
"creator": "admin",
"edit": [],
"dbdef": [
"view",
"create"
],
"querydef": [
"view",
"create"
],
"databases": {
"Gaming": {
"dbuser": "mydbuser_here",
"dbpass": "mypass_here"
}
},
"password":
"$6$rounds=665736$x/Xp0k6Nj.5qzuM5$G.3w6Py1s.xZ83RHDU55qonNMpJe4Le8nD8PqjYKoOtgbab7T22knJPqwHspoT6BQxp.5gieLFuD0SdD9dyvi/",
"email": "",
"view": []
}
Then I wanted to issue a POST in order to execute a SQL Pass-thru
such as this:
http:///query/InsertBestScore/Score/99/ScreenName/GollyGolly.xml?apikey=dzn8k7hj2sdgddlvymfmefh1k2ddjl05
Where I built a query and named it "InsertBestScore":
insert into Gaming.Leaderboard
(ScreenName, Score)
values
(:ScreenName, :Score);
If I run this via POSTMAN using the POST method:
... then I get an access, 403 :
<?xml version="1.0" encoding="utf-8"?>
<SlashDB>
<http_code>403</http_code>
<description>Access was denied to this resource. Please log in with your username/password or resend your request with a valid API key.</description>
<url_template>/query/InsertBestScore/Score/{Score}/ScreenName/{ScreenName}.xml</url_template>
</SlashDB>
Also, I would be calling this POST (or PUT) request from an application, in my case a Python program running from within a AWS Lambda Function.
Now, I came across this in the documentation:
Two parameters API key
SlashDB also allows a two parameters credentials in this authentication method - app id and api key. This may come handy when integrating with API management systems like 3Scale. By default header and query string argument would be:
• appid - identifies certain application
• apikey - secret for the application
Request with API key in header - Access granted
... however in the example above, I don't see where the appid comes into play.
Can you tell me how one would call the SlashDB endpoint and pass a APIkey and assure that the userid is known as MyAPP.
So, to sum up, the Documentation mentions:
• Another application utilizes an API key to authenticate, which is sent with every request. The application is recognized as SlashDB user App2, which uses database login db_admin. Effectively this application can SELECT, UPDATE, INSERT and DELETE data.
So I want to actually, do just what is in that bullet: Identify myself as the user (instead of App2, I'm user MyAPP), and then use the dbuser and dbpass that was assigned to access that "Gaming" database.
Idea?
Make sure you've given user MyAPP permission to execute the query.
To do so:
login as admin,
go to Configure -> Queries,
open your query definition,
update field Execute. It accepts comma separated user ids.
OK, there are really two questions here:
Why was access denied?
What is the appid and how to use it.
Ad. 1: There are two authorization barriers that the request has to clear.
The first one is imposed by SlashDB in that the user executing the query must be listed in the Execute field on the query definition screen. This is done under Configure -> Queries -> "edit" button on your query.
The second barrier is imposed by the database. The SlashDB user who is executing your POST request must be mapped to a physical database user with INSERT privileges to the Gaming.Leaderboard table. It goes without saying that this database user must be associated with the database schema in which the table exists.
Ad. 2. To enable the appid the user api key must be composed out of two parts separated by colon ":". The first part will be interpreted as the appid and the second will be the apikey.
To do that, use Configuration -> Users -> 'edit' button for the user in question. Then simply add a colon at the beginning of the API key and type in your desired appid to the left of the colon. The app will have to supply both keys to execute the request. Note that the names of those keys (i.e. appid) are configurable in /etc/slashdb/slashdb.ini.
The reasoning behind this feature is to facilitate API Management platforms, which can help with key management, especially when API will be exposed to third party developers.
I control the softlayer resources(Server, Storage etc) by JAVA API.
I am verifying an upgrade to the Evault storage space ( 20GB => 40GB) via the API but the API returns an error message
"error": "EVault service already exists for the requested location (Seoul 1).",
"code": "SoftLayer_Exception_Public"
from the POST event
URL(POST) https://IBMxxxx:xxxxx#api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
Here is the attached request body
{"parameters":
[
{"complexType":"SoftLayer_Container_Product_Order"
,"orderContainers":[
{"complexType":"SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault"
,"location":"1555995"
,"packageId":0
,"quantity":1
,"virtualGuests":[
{"complexType":"SoftLayer_Virtual_Guest"
,"id":376047
}
],
"useHourlyPricing":false
,"prices":[
{"complexType":"SoftLayer_Product_Item_Price","id":66257}
]
}
]
}
]
}
What you are doing with that request is ordering an eVault storage, besides the itemId set is for a 60GB EVault Disk capacity and not 40 Gb.
UPDATE
Retrieve item prices only for eVault storage capacities.
https://IBMxxxx:xxxxx#api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/0/getItemPrices?objectMask=mask[id,locationGroupId,item[id,keyName,description],pricingLocationGroup[locations[id,name,longName]]]&objectFilter={"itemPrices":{"item": {"keyName":{"operation":"*=EVAULT"}}}}
Currently to perform an upgrade what you require is to use the method SoftLayer::upgradeVolumeCapacity, please see following request:
Perform capacity upgrade to an specific eVault storage:
(url POST) https://IBMxxxx:xxxxx#api.softlayer.com/rest/v3/SoftLayer_Network_Storage/eVaultId/upgradeVolumeCapacity
with the following request BODY:
{
"parameters":
[
559
]
}
Do not forget to change eVaultId on the request for your eVault storage, try this rest request to retrieve the specific eVault id:
Retrieve an account's associated EVault storage volumes:
https://IBMxxxx:xxxxx#api.softlayer.com/rest/v3/SoftLayer_Account/getEvaultNetworkStorage?objectMask=mask[id, serviceResourceName,guestId,billingItem[id,location]]
Once obtained, then you may specify an upgradeItem (e.g. "itemId": 559 that might be the itemId for 40 Gb evault disk).
To retrieve the upgrade itemId's for the different upgrade capacities allowed, use the following request:
https://IBMxxxx:xxxxx#api.softlayer.com/rest/v3/SoftLayer_Network_Storage/eVaultId/getObject?objectMask=mask[id, billingItem[id, upgradeItems[prices]]]
(don't forget to change the eVaultId).
Review the upgradeItems property and choose the capacity required, you should use the id value for the capacity you need on the method upgradeVolumeCapacity.
For more information about eVaults, see below:
Sample code to handle the upgrade of EVault?
How to find location of an EVault using SoftLayer API?
Sample code for ordering an EVault backup in SoftLayer
I have a question regarding the use of the getBandwidthDataByDate request using the SoftLayer REST API.
In the documentation it lists 3 parameters for this request, but it's a GET request. Does anyone know how to make this request and/or have an example?
https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/getBandwidthDataByDate/'device_id'.json
I'm not sure where to add the parameters here.(startDateTime, endDateTime, networkType)
And what does the dateTime object look like?
Thanks
This is a POST request, so you need to pass the parameters in "Payload" (I'm using Advanced REST client for Chrome).
Try the following REST request:
https://$user:$apiKey#api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/$device_id/getBandwidthDataByDate
Method: Post (Copy the below code in "Payload")
{
"parameters":[
"2016-03-10T00:00:00",
"2016-03-15T00:00:00",
"public"
]
}
Note: Replace $user, $apiKey and $device_id with your own information
References:
SoftLayer_Virtual_Guest::getBandwidthDataByDate
I'm trying the built-in Authentication of ServiceStack. My approach is 'OrmLiteAuthRepository' so users' information are stored in Sql Server instead of the default in memory storage. I use Postman to test the endpoints.
My target is receiving user rows, updating user information, creating users, deleting an user row. Those are the endpoints I found in Postman after importing (I didn't create those endpoints):
GET 'http://localhost:47391/api/register',
PUT 'http://localhost:47391/api/json/reply/Register'
POST 'http://localhost:47391/api/json/reply/Register'
I tested POST, Sql Server automatically created the tables to store user data. And the data could be written into Sql Server so I have no problem with POST.
But with PUT, isn't it for updating the existing row? I append '/{id}' to the end. But it created a new row in the database instead of updating the existing one. How does it work?
With GET, I got no implementation error.
{
"ResponseStatus": {
"ErrorCode": "NotImplementedException",
"Message": "Could not find method named Get(Register) or Any(Register) on Service RegisterService",
"StackTrace": " at ServiceStack.Host.ServiceExec`1.Execute(IRequest request, Object instance, Object requestDto, String requestName)\r\n at ServiceStack.Host.ServiceRequestExec`2.Execute(IRequest requestContext, Object instance, Object request)\r\n at ServiceStack.Host.ServiceController.<>c__DisplayClass11.<>c__DisplayClass13.<RegisterServiceExecutor>b__10(IRequest reqCtx, Object req)\r\n at ServiceStack.Host.ServiceController.ManagedServiceExec(ServiceExecFn serviceExec, IService service, IRequest request, Object requestDto)\r\n at ServiceStack.Host.ServiceController.<>c__DisplayClass11.<RegisterServiceExecutor>b__f(IRequest requestContext, Object dto)\r\n at ServiceStack.Host.ServiceController.Execute(Object requestDto, IRequest req)\r\n at ServiceStack.HostContext.ExecuteService(Object request, IRequest httpReq)\r\n at ServiceStack.Host.RestHandler.GetResponse(IRequest request, Object requestDto)\r\n at ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)"
}
}
How to implement it? I assume I consider the user a normal Web Service entity? and create 'UserService', and requests like:
[Route("/register")]
public class User : IReturn<UserResponse>
{
...
}
BUT there isn't a model class like 'User' due to the tables are created by ServiceStack itself, how to solve this?
Or is there something I am not aware of. Thanks.
The error message:
Could not find method named Get(Register) or Any(Register) on Service RegisterService
Is saying you're trying to call the built-in ServiceStack Register Service instead of your Service. But the Register Services isn't enabled by default, your AuthFeature likely explicitly enables it, either with:
Plugins.Add(new RegistrationFeature());
Or on the AuthFeature:
Plugins.Add(new AuthFeature(...) {
IncludeRegistrationService = true
});
If you don't want to enable ServiceStack's built-in Register Service you'll need to remove the registration where it's enabled.
If you instead want the Register Service registered at a different path, you can specify a different route with:
Plugins.Add(new RegistrationFeature {
AtRestPath = "/servicestack-register"
});