aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@sap.com>2022-10-26 11:31:22 +0200
committerSandro Jäckel <sandro.jaeckel@sap.com>2022-10-26 14:05:42 +0200
commit04ce17415f25dbf10eba954212c8428ae630df88 (patch)
tree1aca7ceab052f17a44bb903fb5a8bd45202bd54c /account.go
parentfd6e57b6239655722884a49a86be0f051cc32bde (diff)
downloadgo-schwift-04ce17415f25dbf10eba954212c8428ae630df88.tar.gz
Format with go 1.19
Diffstat (limited to 'account.go')
-rw-r--r--account.go89
1 files changed, 44 insertions, 45 deletions
diff --git a/account.go b/account.go
index 85299df..9db952e 100644
--- a/account.go
+++ b/account.go
@@ -25,9 +25,9 @@ import (
"regexp"
)
-//Account represents a Swift account. Instances are usually obtained by
-//connecting to a backend (see package-level documentation), or by traversing
-//upwards from a container with Container.Account().
+// Account represents a Swift account. Instances are usually obtained by
+// connecting to a backend (see package-level documentation), or by traversing
+// upwards from a container with Container.Account().
type Account struct {
backend Backend
//URL parts
@@ -38,16 +38,16 @@ type Account struct {
caps *Capabilities
}
-//IsEqualTo returns true if both Account instances refer to the same account.
+// IsEqualTo returns true if both Account instances refer to the same account.
func (a *Account) IsEqualTo(other *Account) bool {
return other.baseURL == a.baseURL && other.name == a.name
}
var endpointURLRegexp = regexp.MustCompile(`^(.*/)v1/(.*)/$`)
-//InitializeAccount takes something that implements the Backend interface, and
-//returns the Account instance corresponding to the account/project that this
-//backend is connected to.
+// InitializeAccount takes something that implements the Backend interface, and
+// returns the Account instance corresponding to the account/project that this
+// backend is connected to.
func InitializeAccount(backend Backend) (*Account, error) {
match := endpointURLRegexp.FindStringSubmatch(backend.EndpointURL())
if match == nil {
@@ -60,13 +60,13 @@ func InitializeAccount(backend Backend) (*Account, error) {
}, nil
}
-//SwitchAccount returns a handle to a different account on the same server. Note
-//that you need reseller permissions to access accounts other than that where
-//you originally authenticated. This method does not check whether the account
-//actually exists.
+// SwitchAccount returns a handle to a different account on the same server. Note
+// that you need reseller permissions to access accounts other than that where
+// you originally authenticated. This method does not check whether the account
+// actually exists.
//
-//The account name is usually the Keystone project ID with an additional "AUTH_"
-//prefix.
+// The account name is usually the Keystone project ID with an additional "AUTH_"
+// prefix.
func (a *Account) SwitchAccount(accountName string) *Account {
newEndpointURL := a.baseURL + "v1/" + accountName + "/"
return &Account{
@@ -76,25 +76,25 @@ func (a *Account) SwitchAccount(accountName string) *Account {
}
}
-//Name returns the name of the account (usually the prefix "AUTH_" followed by
-//the Keystone project ID).
+// Name returns the name of the account (usually the prefix "AUTH_" followed by
+// the Keystone project ID).
func (a *Account) Name() string {
return a.name
}
-//Backend returns the backend which is used to make requests against this
-//account.
+// Backend returns the backend which is used to make requests against this
+// account.
func (a *Account) Backend() Backend {
return a.backend
}
-//Headers returns the AccountHeaders for this account. If the AccountHeaders
-//has not been cached yet, a HEAD request is issued on the account.
+// Headers returns the AccountHeaders for this account. If the AccountHeaders
+// has not been cached yet, a HEAD request is issued on the account.
//
-//This operation fails with http.StatusNotFound if the account does not exist.
+// This operation fails with http.StatusNotFound if the account does not exist.
//
-//WARNING: This method is not thread-safe. Calling it concurrently on the same
-//object results in undefined behavior.
+// WARNING: This method is not thread-safe. Calling it concurrently on the same
+// object results in undefined behavior.
func (a *Account) Headers() (AccountHeaders, error) {
if a.headers != nil {
return *a.headers, nil
@@ -117,19 +117,19 @@ func (a *Account) Headers() (AccountHeaders, error) {
return *a.headers, nil
}
-//Invalidate clears the internal cache of this Account instance. The next call
-//to Headers() on this instance will issue a HEAD request on the account.
+// Invalidate clears the internal cache of this Account instance. The next call
+// to Headers() on this instance will issue a HEAD request on the account.
//
-//WARNING: This method is not thread-safe. Calling it concurrently on the same
-//object results in undefined behavior.
+// WARNING: This method is not thread-safe. Calling it concurrently on the same
+// object results in undefined behavior.
func (a *Account) Invalidate() {
a.headers = nil
}
-//Update updates the account using a POST request. The headers in the headers
-//attribute take precedence over those in opts.Headers.
+// Update updates the account using a POST request. The headers in the headers
+// attribute take precedence over those in opts.Headers.
//
-//A successful POST request implies Invalidate() since it may change metadata.
+// A successful POST request implies Invalidate() since it may change metadata.
func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error {
_, err := Request{
Method: "POST",
@@ -142,10 +142,10 @@ func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error {
return err
}
-//Create creates the account using a PUT request. This operation is only
-//available to reseller admins, not to regular users.
+// Create creates the account using a PUT request. This operation is only
+// available to reseller admins, not to regular users.
//
-//A successful PUT request implies Invalidate() since it may change metadata.
+// A successful PUT request implies Invalidate() since it may change metadata.
func (a *Account) Create(opts *RequestOptions) error {
_, err := Request{
Method: "PUT",
@@ -159,34 +159,33 @@ func (a *Account) Create(opts *RequestOptions) error {
return err
}
-//Containers returns a ContainerIterator that lists the containers in this
-//account. The most common use case is:
+// Containers returns a ContainerIterator that lists the containers in this
+// account. The most common use case is:
//
// containers, err := account.Containers().Collect()
//
-//You can extend this by configuring the iterator before collecting the results:
+// You can extend this by configuring the iterator before collecting the results:
//
// iter := account.Containers()
// iter.Prefix = "test-"
// containers, err := iter.Collect()
//
-//Or you can use a different iteration method:
+// Or you can use a different iteration method:
//
// err := account.Containers().ForeachDetailed(func (ci ContainerInfo) error {
// log.Printf("container %s contains %d objects!\n",
// ci.Container.Name(), ci.ObjectCount)
// })
-//
func (a *Account) Containers() *ContainerIterator {
return &ContainerIterator{Account: a}
}
-//Capabilities queries the GET /info endpoint of the Swift server providing
-//this account. Capabilities are cached, so the GET request will only be sent
-//once during the first call to this method.
+// Capabilities queries the GET /info endpoint of the Swift server providing
+// this account. Capabilities are cached, so the GET request will only be sent
+// once during the first call to this method.
//
-//WARNING: This method is not thread-safe. Calling it concurrently on the same
-//object results in undefined behavior.
+// WARNING: This method is not thread-safe. Calling it concurrently on the same
+// object results in undefined behavior.
func (a *Account) Capabilities() (Capabilities, error) {
if a.caps != nil {
return *a.caps, nil
@@ -207,9 +206,9 @@ func (a *Account) Capabilities() (Capabilities, error) {
return caps, nil
}
-//RawCapabilities queries the GET /info endpoint of the Swift server providing
-//this account, and returns the response body. Unlike Account.Capabilities,
-//this method does not employ any caching.
+// RawCapabilities queries the GET /info endpoint of the Swift server providing
+// this account, and returns the response body. Unlike Account.Capabilities,
+// this method does not employ any caching.
func (a *Account) RawCapabilities() ([]byte, error) {
//This method is the only one in Schwift that bypasses struct Request since
//the request URL is not below the endpoint URL.