Skip to content

Commit

Permalink
Merge pull request #65 from croomes/dev-v2
Browse files Browse the repository at this point in the history
Initial v2 api
  • Loading branch information
croomes authored Mar 11, 2020
2 parents 9358f09 + beb9105 commit c68d7a4
Show file tree
Hide file tree
Showing 77 changed files with 16,186 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.10
- image: circleci/golang:1.13

#### TEMPLATE_NOTE: go expects specific checkout path representing url
#### expecting it in the form of
Expand All @@ -20,3 +20,9 @@ jobs:
- run: go get -v -t -d ./...
- run: go vet -v $(go list ./... | grep -v /vendor/)
- run: go test -v -race $(go list ./... | grep -v /vendor/)

workflows:
version: 2
build_and_test:
jobs:
- build
6 changes: 6 additions & 0 deletions netutil/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func AddressesFromNodes(nodes []string) ([]string, error) {
return nil, newInvalidNodeError(errInvalidHostName)
}

// Given input like "http://localhost:8080:8383", url.Parse() will
// return host as "localhost:8000", which isn't a vaild DNS name.
if strings.Contains(host, ":") {
return nil, newInvalidNodeError(errInvalidHostName)
}

port := url.Port()
if port == "" {
port = DefaultDialPort
Expand Down
24 changes: 24 additions & 0 deletions v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof
23 changes: 23 additions & 0 deletions v2/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
1 change: 1 addition & 0 deletions v2/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.3.0-SNAPSHOT
8 changes: 8 additions & 0 deletions v2/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go

install:
- go get -d -v .

script:
- go build -v ./

22 changes: 22 additions & 0 deletions v2/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2015-2020 StorageOS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

31 changes: 31 additions & 0 deletions v2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
VERSION ?= 2.0.0-rc1
GIT_USER_ID ?= storageos
GIT_REPO_ID ?= go-api

.DEFAULT_GOAL:=help

.PHONY: help customise

help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-13s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

build: generate customise ## Re-generates the API from openapi.yaml.

generate: ## Runs the openapi-generator on openapi.yaml.
docker run --rm -v `pwd`:/local -u `id -u ${USER}`:`id -g ${USER}` \
openapitools/openapi-generator-cli:latest generate \
--strict-spec=true \
--additional-properties enumClassPrefix=true \
--additional-properties packageName=api \
--additional-properties packageVersion=$(VERSION) \
-i /local/openapi.yaml -g go -o /local

customise: ## Applies customisations to the generated API.
sed -i 's/\[]map/map/ig' *.go
sed -i "s#module github.com/GIT_USER_ID/GIT_REPO_ID#module github.com/${GIT_USER_ID}/${GIT_REPO_ID}/v2#g" go.mod

clean: ## Removes generated files.
rm -f .openapi-generator-ignore .gitignore git_push.sh .travis.yml *.go go.mod go.sum
rm -rf .openapi-generator/ api/ docs/


131 changes: 131 additions & 0 deletions v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Go API client for api

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 2.0.0
- Package version: 2.0.0-rc1
- Build package: org.openapitools.codegen.languages.GoClientCodegen
For more information, please visit [https://storageos.com](https://storageos.com)

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional
```

Put the package under your project folder and add the following in import:

```golang
import "./api"
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**AttachVolume**](docs/DefaultApi.md#attachvolume) | **Post** /namespaces/{namespaceID}/volumes/{id}/attach | Attach a volume to the given node
*DefaultApi* | [**AuthenticateUser**](docs/DefaultApi.md#authenticateuser) | **Post** /auth/login | Authenticate a user
*DefaultApi* | [**CreateNamespace**](docs/DefaultApi.md#createnamespace) | **Post** /namespaces | Create a new namespace
*DefaultApi* | [**CreatePolicyGroup**](docs/DefaultApi.md#createpolicygroup) | **Post** /policies | Create a new policy group
*DefaultApi* | [**CreateUser**](docs/DefaultApi.md#createuser) | **Post** /users | Create a new user
*DefaultApi* | [**CreateVolume**](docs/DefaultApi.md#createvolume) | **Post** /namespaces/{namespaceID}/volumes | Create a new Volume in the specified namespace
*DefaultApi* | [**DeleteAuthenticatedUser**](docs/DefaultApi.md#deleteauthenticateduser) | **Delete** /users/self | Delete the authenticated user
*DefaultApi* | [**DeleteAuthenticatedUserSessions**](docs/DefaultApi.md#deleteauthenticatedusersessions) | **Delete** /users/self/sessions | Invalidate the logged in user&#39;s sessions
*DefaultApi* | [**DeleteNamespace**](docs/DefaultApi.md#deletenamespace) | **Delete** /namespaces/{id} | Delete a namespace
*DefaultApi* | [**DeleteNode**](docs/DefaultApi.md#deletenode) | **Delete** /nodes/{id} | Delete a node
*DefaultApi* | [**DeletePolicyGroup**](docs/DefaultApi.md#deletepolicygroup) | **Delete** /policies/{id} | Delete a policy group
*DefaultApi* | [**DeleteSessions**](docs/DefaultApi.md#deletesessions) | **Delete** /users/{id}/sessions | Invalidate login sessions
*DefaultApi* | [**DeleteUser**](docs/DefaultApi.md#deleteuser) | **Delete** /users/{id} | Delete a user
*DefaultApi* | [**DeleteVolume**](docs/DefaultApi.md#deletevolume) | **Delete** /namespaces/{namespaceID}/volumes/{id} | Delete a volume
*DefaultApi* | [**DetachVolume**](docs/DefaultApi.md#detachvolume) | **Delete** /namespaces/{namespaceID}/volumes/{id}/attach | Detach the given volume
*DefaultApi* | [**GetAuthenticatedUser**](docs/DefaultApi.md#getauthenticateduser) | **Get** /users/self | Get the currently authenticated user&#39;s information
*DefaultApi* | [**GetCluster**](docs/DefaultApi.md#getcluster) | **Get** /cluster | Retrieves the cluster&#39;s global configuration settings
*DefaultApi* | [**GetDiagnostics**](docs/DefaultApi.md#getdiagnostics) | **Get** /diagnostics | Retrieves a diagnostics bundle from the target node
*DefaultApi* | [**GetNamespace**](docs/DefaultApi.md#getnamespace) | **Get** /namespaces/{id} | Fetch a namespace
*DefaultApi* | [**GetNode**](docs/DefaultApi.md#getnode) | **Get** /nodes/{id} | Fetch a node
*DefaultApi* | [**GetPolicyGroup**](docs/DefaultApi.md#getpolicygroup) | **Get** /policies/{id} | Fetch a policy group
*DefaultApi* | [**GetUser**](docs/DefaultApi.md#getuser) | **Get** /users/{id} | Fetch a user
*DefaultApi* | [**GetVolume**](docs/DefaultApi.md#getvolume) | **Get** /namespaces/{namespaceID}/volumes/{id} | Fetch a volume
*DefaultApi* | [**ListNamespaces**](docs/DefaultApi.md#listnamespaces) | **Get** /namespaces | Fetch the list of namespaces
*DefaultApi* | [**ListNodes**](docs/DefaultApi.md#listnodes) | **Get** /nodes | Fetch the list of nodes
*DefaultApi* | [**ListPolicyGroups**](docs/DefaultApi.md#listpolicygroups) | **Get** /policies | Fetch the list of policy groups
*DefaultApi* | [**ListUsers**](docs/DefaultApi.md#listusers) | **Get** /users | Fetch the list of users
*DefaultApi* | [**ListVolumes**](docs/DefaultApi.md#listvolumes) | **Get** /namespaces/{namespaceID}/volumes | Fetch the list of volumes in the given namespace
*DefaultApi* | [**RefreshJwt**](docs/DefaultApi.md#refreshjwt) | **Post** /auth/refresh | Refresh the JWT
*DefaultApi* | [**Spec**](docs/DefaultApi.md#spec) | **Get** /openapi | Serves this openapi spec file
*DefaultApi* | [**UpdateAuthenticatedUser**](docs/DefaultApi.md#updateauthenticateduser) | **Put** /users/self | Update the authenticated user&#39;s information
*DefaultApi* | [**UpdateCluster**](docs/DefaultApi.md#updatecluster) | **Put** /cluster | Update the cluster&#39;s global configuration settings
*DefaultApi* | [**UpdateNamespace**](docs/DefaultApi.md#updatenamespace) | **Put** /namespaces/{id} | Update a namespace
*DefaultApi* | [**UpdateNode**](docs/DefaultApi.md#updatenode) | **Put** /nodes/{id} | Update a node
*DefaultApi* | [**UpdatePolicyGroup**](docs/DefaultApi.md#updatepolicygroup) | **Put** /policies/{id} | Update a policy group
*DefaultApi* | [**UpdateUser**](docs/DefaultApi.md#updateuser) | **Put** /users/{id} | Update a user
*DefaultApi* | [**UpdateVolume**](docs/DefaultApi.md#updatevolume) | **Put** /namespaces/{namespaceID}/volumes/{id} | Update a volume


## Documentation For Models

- [AcceptedMessage](docs/AcceptedMessage.md)
- [AttachVolumeData](docs/AttachVolumeData.md)
- [AuthUserData](docs/AuthUserData.md)
- [Cluster](docs/Cluster.md)
- [CreateNamespaceData](docs/CreateNamespaceData.md)
- [CreatePolicyGroupData](docs/CreatePolicyGroupData.md)
- [CreateUserData](docs/CreateUserData.md)
- [CreateVolumeData](docs/CreateVolumeData.md)
- [DeploymentInfo](docs/DeploymentInfo.md)
- [Error](docs/Error.md)
- [FsType](docs/FsType.md)
- [Health](docs/Health.md)
- [Licence](docs/Licence.md)
- [LogFormat](docs/LogFormat.md)
- [LogLevel](docs/LogLevel.md)
- [Namespace](docs/Namespace.md)
- [Node](docs/Node.md)
- [PoliciesSpecs](docs/PoliciesSpecs.md)
- [PolicyGroup](docs/PolicyGroup.md)
- [PolicyGroupUsers](docs/PolicyGroupUsers.md)
- [UpdateAuthenticatedUserData](docs/UpdateAuthenticatedUserData.md)
- [UpdateClusterData](docs/UpdateClusterData.md)
- [UpdateNamespaceData](docs/UpdateNamespaceData.md)
- [UpdateNodeData](docs/UpdateNodeData.md)
- [UpdatePolicyGroupData](docs/UpdatePolicyGroupData.md)
- [UpdateUserData](docs/UpdateUserData.md)
- [UpdateVolumeData](docs/UpdateVolumeData.md)
- [User](docs/User.md)
- [Volume](docs/Volume.md)


## Documentation For Authorization



## jwt

- **Type**: HTTP basic authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
```



## Author

[email protected]

Loading

0 comments on commit c68d7a4

Please sign in to comment.