-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding object-storage/transfer and /cancel endpoints (#242)
- Loading branch information
1 parent
13da5e5
commit f8402b0
Showing
22 changed files
with
266 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package linodego | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
// ObjectStorageTransfer is an object matching the response of object-storage/transfer | ||
type ObjectStorageTransfer struct { | ||
AmmountUsed int `json:"used"` | ||
} | ||
|
||
// CancelObjectStorage cancels and removes all object storage from the Account | ||
func (c *Client) CancelObjectStorage(ctx context.Context) error { | ||
e, err := c.ObjectStorage.Endpoint() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
req := c.R(ctx) | ||
|
||
e = fmt.Sprintf("%s/cancel", e) | ||
_, err = coupleAPIErrors(req.Post(e)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// GetObjectStorageTransfer returns the amount of outbound data transferred used by the Account | ||
func (c *Client) GetObjectStorageTransfer(ctx context.Context) (*ObjectStorageTransfer, error) { | ||
e, err := c.ObjectStorage.Endpoint() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
req := c.R(ctx) | ||
|
||
e = fmt.Sprintf("%s/transfer", e) | ||
r, err := coupleAPIErrors(req.SetResult(&ObjectStorageTransfer{}).Get(e)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return r.Result().(*ObjectStorageTransfer), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.