API w/ Java
import static java.lang.System.out;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
public class OpenStackSample {
public static void main(String[] args) {
Client client = ClientBuilder.newClient();
Response res = client.target("https://host/v1/sampleAccount/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).head();
if (res.getStatus() == 200)
res.getHeaders().forEach((k, v) -> out.println(k + " = " + v));
client.close();
}
}
API w/ Go
package main
import (
"fmt"
"gopkg.in/resty.v1"
)
func main() {
res, _ := resty.R().SetHeader("X-Auth-Token", ...).Head("https://host/v1/sampleAccount/sampleBucket/sampleObject")
if res.StatusCode() == 200 {
for k, v := range res.Header() {
fmt.Printf("%v = %v\n", k, v)
}
}
}
API w/ Node.js
const https = require('https')
var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'HEAD', path: '/v1/sampleAccount/sampleBucket/sampleObject' }, (res) => {
if (res.statusCode === 200)
for (k in res.headers)
console.log(k + ' = ' + res.headers[k])
})
req.end()
API w/ Python
import requests
res = requests.head('https://host/v1/sampleAccount/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... })
if res.ok:
for k, v in res.headers.items():
print k + ' = ' + v + '\n'[/sourcecode]
API w/ Ruby
require 'rest-client'
res = RestClient.head 'https://host/v1/sampleAccount/sampleBucket/sampleObject', :x_auth_token => ...
if res.code == 200
res.headers.each {|k, v| puts "#{k} = #{v}" }
end
CLI
1) Setup the CLI:
export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleuser
export ST_KEY=samplepassword
2) Run the following command:
swift stat samplebucket sampleobject
Client
from swiftclient.service import SwiftService
service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleUser', 'key': 'samplePassword' })
for res in service.stat('sampleBucket', [ 'sampleObject' ]):
print res
Terraform Provider
N/A.