Categorygithub.com/ncw/swift/v2
modulepackage
2.0.3
Repository: https://github.com/ncw/swift.git
Documentation: pkg.go.dev

# README

Swift

This package provides an easy to use library for interfacing with Swift / Openstack Object Storage / Rackspace cloud files from the Go Language

Build Status Go Reference

Install

Use go to install the library

go get github.com/ncw/swift/v2

Usage

See here for full package docs

Here is a short example from the docs

import "github.com/ncw/swift/v2"

// Create a connection
c := swift.Connection{
UserName: "user",
ApiKey:   "key",
AuthUrl:  "auth_url",
Domain:   "domain", // Name of the domain (v3 auth only)
Tenant:   "tenant", // Name of the tenant (v2 auth only)
}
// Authenticate
err := c.Authenticate()
if err != nil {
panic(err)
}
// List all the containers
containers, err := c.ContainerNames(nil)
fmt.Println(containers)
// etc...

Migrating from v1

The library has current major version v2. If you want to migrate from the first version of library github.com/ncw/swift you have to explicitly add the /v2 suffix to the imports.

Most of the exported functions were added a new context.Context parameter in the v2, which you will have to provide when migrating.

Additions

The rs sub project contains a wrapper for the Rackspace specific CDN Management interface.

Testing

To run the tests you can either use an embedded fake Swift server either use a real Openstack Swift server or a Rackspace Cloud files account.

When using a real Swift server, you need to set these environment variables before running the tests

export SWIFT_API_USER='user'
export SWIFT_API_KEY='key'
export SWIFT_AUTH_URL='https://url.of.auth.server/v1.0'

And optionally these if using v2 authentication

export SWIFT_TENANT='TenantName'
export SWIFT_TENANT_ID='TenantId'

And optionally these if using v3 authentication

export SWIFT_TENANT='TenantName'
export SWIFT_TENANT_ID='TenantId'
export SWIFT_API_DOMAIN_ID='domain id'
export SWIFT_API_DOMAIN='domain name'

And optionally these if using v3 trust

export SWIFT_TRUST_ID='TrustId'

And optionally this if you want to skip server certificate validation

export SWIFT_AUTH_INSECURE=1

And optionally this to configure the connect channel timeout, in seconds

export SWIFT_CONNECTION_CHANNEL_TIMEOUT=60

And optionally this to configure the data channel timeout, in seconds

export SWIFT_DATA_CHANNEL_TIMEOUT=60

Then run the tests with go test

License

This is free software under the terms of MIT license (check COPYING file included in this package).

Contact and support

The project website is at:

There you can file bug reports, ask for help or contribute patches.

Authors

Contributors

# Packages

No description provided by the author
This implements a very basic Swift server Everything is stored in memory This comes from the https://github.com/mitchellh/goamz and was adapted for Swift.

# Functions

No description provided by the author
FloatStringToTime converts a floating point number string to a time.Time The string is floating point number of seconds since the epoch (Unix time).
No description provided by the author
TimeToFloatString converts a time.Time object to a floating point string The string is floating point number of seconds since the epoch (Unix time).

# Constants

Default number of retries on token expiry.
Default user agent.
Values that ObjectType can take.
Use admin URL as storage URL.
Use internal URL as storage URL.
Use public URL as storage URL.
No description provided by the author
Values that ObjectType can take.
Values that ObjectType can take.
Python date format for json replies parsed as UTC.
Data format specifier for Connection.BulkUpload().
Data format specifier for Connection.BulkUpload().
Data format specifier for Connection.BulkUpload().

# Variables

No description provided by the author
No description provided by the author
Mappings for container errors.
No description provided by the author
No description provided by the author
No description provided by the author
NotLargeObject is returned if an operation is performed on an object which isn't large.
Specific Errors you might want to check for equality.
No description provided by the author
No description provided by the author
No description provided by the author
SLONotSupported is returned as an error when Static Large Objects are not supported.
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Account contains information about this account.
BulkDeleteResult stores results of BulkDelete().
BulkUploadResult stores results of BulkUpload().
Connection holds the details of the connection to the swift server.
Container contains information about a container.
ContainersOpts is options for Containers() and ContainerNames().
DynamicLargeObjectCreateFile represents an open static large object.
Error - all errors generated by this package are of this type.
LargeObjectOpts describes how a large object should be created.
Object contains information about an object.
ObjectCreateFile represents a swift object open for writing.
ObjectOpenFile represents a swift object open for reading.
ObjectOpts is options for Objects() and ObjectNames().
RequestOpts contains parameters for Connection.storage.
StaticLargeObjectCreateFile represents an open static large object.

# Interfaces

Auth defines the operations needed to authenticate with swift This encapsulates the different authentication schemes in use.
No description provided by the author
Expireser is an optional interface to read the expiration time of the token.
No description provided by the author

# Type aliases

No description provided by the author
Headers stores HTTP headers (can only have one of each header like Swift).
Metadata stores account, container or object metadata.
A closure defined by the caller to iterate through all objects Call Objects or ObjectNames from here with the context.Context and *ObjectOpts passed in Do whatever is required with the results then return them.
ObjectType is the type of the swift object, regular, static large, or dynamic large.
SwiftInfo contains the JSON object returned by Swift when the /info route is queried.