func main() {

	fmt.Println("hello there")

	// Create a connection
	c := swift.Connection{
		UserName:    "******",
		ApiKey:      "password",
		AuthUrl:     "auth-url",
		Domain:      "domain", // Name of the domain
		AuthVersion: 3,
		TenantId:    "tenantId", // Id of the tenant/project
	}

	// Authenticate
	err := c.Authenticate()
	if err != nil {
		panic(err)
	}

	// List all containers
	containers, err := c.ContainerNamesAll(nil)
	if err != nil {
		panic(err)
	}
	fmt.Println("Containers: ")
	fmt.Println(containers)

	// Create new container
	err1 := c.ContainerCreate("testContainer", nil)
	if err1 != nil {
		panic(err1)
	}
	fmt.Println("Container created")

	// List objects
	object, headers, err := c.Object(CONTAINER, OBJECT)
	if err != nil {
		panic(err)
	}
	fmt.Println("Object Info: ")
	fmt.Println(object.Name)
	fmt.Println(headers.ObjectMetadata())

	// Account info
	info, headers, err := c.Account()
	if err != nil {
		panic(err)
	}
	fmt.Println("Account Info: ")
	fmt.Println(info)
	fmt.Println(headers)

}
Esempio n. 2
0
func GetHistory(ren render.Render, r *http.Request, cf *swift.Connection) {
	opts := swift.ObjectsOpts{}
	opts.Prefix = "cfpaste-"
	opts.Limit = 10
	objects, err := cf.ObjectNames("go-cfpaste", &opts)
	pastes := make([]string, 10)
	for i := range objects {
		object, headers, err := cf.Object("go-cfpaste", objects[i])
		PanicIf(err)
		log.Println(object.Name)
		pastes = append(pastes, headers["X-Object-Meta-Pasteid"])
	}
	PanicIf(err)
	ren.HTML(200, "history", pastes)
	return
}