-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unified api and add session invalidation handling
* Move to backward compatible 3.x API * If you're using Quobyte 2.x refer to 2.x management API definitions, not supported fields by 2.x are ignored by API server. * Add session cookies to improve API performance * Currently, each request is authenticated with username and password. The authentication is expensive and could block requests if there are many concurrent requests. With session cookies solves this problem.
- Loading branch information
Showing
20 changed files
with
5,469 additions
and
9,711 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,59 @@ | ||
# Quobyte API | ||
# Quobyte API Clients | ||
|
||
* User documentation | ||
* [For 2.x API](./v2/README.md) | ||
* [For 3.x API](./v3/README.md) | ||
* Developer documentation (./docs/) | ||
Get the Quobyte api client | ||
|
||
```bash | ||
go get github.com/quobyte/api | ||
``` | ||
|
||
## Usage | ||
|
||
`Note:` Create below example in separate project outside of the api repository to avoid circular `go mod` dependencies. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
quobyte_api "github.com/quobyte/api/quobyte" | ||
) | ||
|
||
func main() { | ||
url := flag.String("url", "", "URL of Quobyte API") | ||
username := flag.String("username", "", "username") | ||
password := flag.String("password", "", "password") | ||
flag.Parse() | ||
|
||
if *url == "" || *username == "" || *password == "" { | ||
flag.PrintDefaults() | ||
os.Exit(1) | ||
} | ||
|
||
client := quobyte_api.NewQuobyteClient(*url, *username, *password) | ||
client.SetAPIRetryPolicy(quobyte_api.RetryInfinitely) // Default quobyte_api.RetryInteractive | ||
req := &quobyte_api.CreateVolumeRequest{ | ||
Name: "MyVolume", | ||
TenantId: "32edb36d-badc-affe-b44a-4ab749af4d9a", | ||
RootUserId: "root", | ||
RootGroupId: "root", | ||
ConfigurationName: "BASE", | ||
Label: []*quobyte_api.Label{ | ||
{Name: "label1", Value: "value1"}, | ||
{Name: "label2", Value: "value2"}, | ||
}, | ||
} | ||
|
||
response, err := client.CreateVolume(req) | ||
if err != nil { | ||
log.Fatalf("Error: %v", err) | ||
} | ||
|
||
capactiy := int64(1024 * 1024 * 1024) | ||
err = client.SetVolumeQuota(response.VolumeUuid, capactiy) | ||
if err != nil { | ||
log.Fatalf("Error: %v", err) | ||
} | ||
|
||
log.Printf("%s", response.VolumeUuid) | ||
} | ||
``` |
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,19 @@ | ||
# Developer notes | ||
|
||
## Releasing new version | ||
|
||
* `go.mod` files must be present at the root level of the project | ||
* Each major release beyond V1 (such =v2[+].a.b) must provide unique import path such as `github.com/quobyte/api/vX` | ||
* To get around this issue, we always use v1.x.x (**NEVER** make v2 release) | ||
* Further, each `*.go` file must have a `package XYZ` statement as the first line and must be placed into `XZY` | ||
directory. (It seems go mod ignores .go file that is not placed in declared package directory!!) | ||
* For local testing of edited module, | ||
* Create a standalone project with the `testing or main.go` and `go mod init` inside the project root. | ||
The `go mod init` fetches the depedencies required by code. | ||
* Replace Quobyte API with updated API `go mod edit -replace github.com/quobyte/api=</path/to/local/quobyte/api>` | ||
* Publishing change must always have highest minor version of all the published tags (even if the tag is deleted, | ||
the new version must have the higher version than deleted tag). | ||
|
||
Note: go mod updates dependency to the highest minor version available. Even if the version is deleted from the tags, | ||
go-git gets it from the deleted references (Uhhh!!). The only way out is to create a new higher minor | ||
version with the changes. |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
module github.com/quobyte/api | ||
|
||
go 1.14 |
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 @@ | ||
|
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
File renamed without changes.
Oops, something went wrong.