Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
427 changes: 422 additions & 5 deletions docs/swagger/swagger.yaml

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions internal/apiserver/route_get_token_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ import (

var getTokenAccounts = &oapispec.Route{
Name: "getTokenAccounts",
Path: "namespaces/{ns}/tokens/{type}/pools/{name}/accounts",
Path: "namespaces/{ns}/tokens/accounts",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "type", Description: i18n.MsgTBD},
{Name: "name", Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: database.TokenAccountQueryFactory,
Expand All @@ -42,6 +40,6 @@ var getTokenAccounts = &oapispec.Route{
JSONOutputValue: func() interface{} { return []*fftypes.TokenAccount{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return filterResult(r.Or.Assets().GetTokenAccounts(r.Ctx, r.PP["ns"], r.PP["type"], r.PP["name"], r.Filter))
return filterResult(r.Or.Assets().GetTokenAccounts(r.Ctx, r.PP["ns"], r.Filter))
},
}
47 changes: 47 additions & 0 deletions internal/apiserver/route_get_token_accounts_by_pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http"

"github.com/hyperledger/firefly/internal/config"
"github.com/hyperledger/firefly/internal/i18n"
"github.com/hyperledger/firefly/internal/oapispec"
"github.com/hyperledger/firefly/pkg/database"
"github.com/hyperledger/firefly/pkg/fftypes"
)

var getTokenAccountsByPool = &oapispec.Route{
Name: "getTokenAccountsByPool",
Path: "namespaces/{ns}/tokens/{type}/pools/{name}/accounts",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "type", Description: i18n.MsgTBD},
{Name: "name", Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: database.TokenAccountQueryFactory,
Description: i18n.MsgTBD,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return []*fftypes.TokenAccount{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return filterResult(r.Or.Assets().GetTokenAccountsByPool(r.Ctx, r.PP["ns"], r.PP["type"], r.PP["name"], r.Filter))
},
}
42 changes: 42 additions & 0 deletions internal/apiserver/route_get_token_accounts_by_pool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/assetmocks"
"github.com/hyperledger/firefly/pkg/fftypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestGetTokenAccountsByPool(t *testing.T) {
o, r := newTestAPIServer()
mam := &assetmocks.Manager{}
o.On("Assets").Return(mam)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/tok1/pools/pool1/accounts", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mam.On("GetTokenAccountsByPool", mock.Anything, "ns1", "tok1", "pool1", mock.Anything).
Return([]*fftypes.TokenAccount{}, nil, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}
4 changes: 2 additions & 2 deletions internal/apiserver/route_get_token_accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestGetTokenAccounts(t *testing.T) {
o, r := newTestAPIServer()
mam := &assetmocks.Manager{}
o.On("Assets").Return(mam)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/tok1/pools/pool1/accounts", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/accounts", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mam.On("GetTokenAccounts", mock.Anything, "ns1", "tok1", "pool1", mock.Anything).
mam.On("GetTokenAccounts", mock.Anything, "ns1", mock.Anything).
Return([]*fftypes.TokenAccount{}, nil, nil)
r.ServeHTTP(res, req)

Expand Down
44 changes: 44 additions & 0 deletions internal/apiserver/route_get_token_connectors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http"

"github.com/hyperledger/firefly/internal/config"
"github.com/hyperledger/firefly/internal/i18n"
"github.com/hyperledger/firefly/internal/oapispec"
"github.com/hyperledger/firefly/pkg/fftypes"
)

var getTokenConnectors = &oapispec.Route{
Name: "getTokenConnectors",
Path: "namespaces/{ns}/tokens/connectors",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: nil,
Description: i18n.MsgTBD,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return []*fftypes.TokenConnector{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return r.Or.Assets().GetTokenConnectors(r.Ctx, r.PP["ns"])
},
}
42 changes: 42 additions & 0 deletions internal/apiserver/route_get_token_connectors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/assetmocks"
"github.com/hyperledger/firefly/pkg/fftypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestGetTokenConnectors(t *testing.T) {
o, r := newTestAPIServer()
mam := &assetmocks.Manager{}
o.On("Assets").Return(mam)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/connectors", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mam.On("GetTokenConnectors", mock.Anything, "ns1", mock.Anything).
Return([]*fftypes.TokenConnector{}, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}
5 changes: 2 additions & 3 deletions internal/apiserver/route_get_token_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import (

var getTokenPools = &oapispec.Route{
Name: "getTokenPools",
Path: "namespaces/{ns}/tokens/{type}/pools",
Path: "namespaces/{ns}/tokens/pools",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "type", Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: database.TokenPoolQueryFactory,
Expand All @@ -41,6 +40,6 @@ var getTokenPools = &oapispec.Route{
JSONOutputValue: func() interface{} { return []*fftypes.TokenPool{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return filterResult(r.Or.Assets().GetTokenPools(r.Ctx, r.PP["ns"], r.PP["type"], r.Filter))
return filterResult(r.Or.Assets().GetTokenPools(r.Ctx, r.PP["ns"], r.Filter))
},
}
46 changes: 46 additions & 0 deletions internal/apiserver/route_get_token_pools_by_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http"

"github.com/hyperledger/firefly/internal/config"
"github.com/hyperledger/firefly/internal/i18n"
"github.com/hyperledger/firefly/internal/oapispec"
"github.com/hyperledger/firefly/pkg/database"
"github.com/hyperledger/firefly/pkg/fftypes"
)

var getTokenPoolsByType = &oapispec.Route{
Name: "getTokenPoolsByType",
Path: "namespaces/{ns}/tokens/{type}/pools",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "type", Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: database.TokenPoolQueryFactory,
Description: i18n.MsgTBD,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return []*fftypes.TokenPool{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return filterResult(r.Or.Assets().GetTokenPoolsByType(r.Ctx, r.PP["ns"], r.PP["type"], r.Filter))
},
}
42 changes: 42 additions & 0 deletions internal/apiserver/route_get_token_pools_by_type_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2021 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/assetmocks"
"github.com/hyperledger/firefly/pkg/fftypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestGetTokenPoolsByType(t *testing.T) {
o, r := newTestAPIServer()
mam := &assetmocks.Manager{}
o.On("Assets").Return(mam)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/tok1/pools", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mam.On("GetTokenPoolsByType", mock.Anything, "ns1", "tok1", mock.Anything).
Return([]*fftypes.TokenPool{}, nil, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}
4 changes: 2 additions & 2 deletions internal/apiserver/route_get_token_pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestGetTokenPools(t *testing.T) {
o, r := newTestAPIServer()
mam := &assetmocks.Manager{}
o.On("Assets").Return(mam)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/tok1/pools", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/ns1/tokens/pools", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mam.On("GetTokenPools", mock.Anything, "ns1", "tok1", mock.Anything).
mam.On("GetTokenPools", mock.Anything, "ns1", mock.Anything).
Return([]*fftypes.TokenPool{}, nil, nil)
r.ServeHTTP(res, req)

Expand Down
8 changes: 3 additions & 5 deletions internal/apiserver/route_get_token_transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ import (

var getTokenTransfers = &oapispec.Route{
Name: "getTokenTransfers",
Path: "namespaces/{ns}/tokens/{type}/pools/{name}/transfers",
Path: "namespaces/{ns}/tokens/transfers",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "type", Description: i18n.MsgTBD},
{Name: "name", Description: i18n.MsgTBD},
},
QueryParams: nil,
FilterFactory: database.TokenTransferQueryFactory,
Description: i18n.MsgTBD,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return []*fftypes.TokenAccount{} },
JSONOutputValue: func() interface{} { return []*fftypes.TokenTransfer{} },
JSONOutputCodes: []int{http.StatusOK},
JSONHandler: func(r *oapispec.APIRequest) (output interface{}, err error) {
return filterResult(r.Or.Assets().GetTokenTransfers(r.Ctx, r.PP["ns"], r.PP["type"], r.PP["name"], r.Filter))
return filterResult(r.Or.Assets().GetTokenTransfers(r.Ctx, r.PP["ns"], r.Filter))
},
}
Loading