Skip to content

Commit 3445132

Browse files
authored
Merge pull request #1509 from kaleido-io/multiparty-status
Add multiparty status API
2 parents 261ff1b + 72a4525 commit 3445132

File tree

23 files changed

+1392
-52
lines changed

23 files changed

+1392
-52
lines changed

doc-site/docs/swagger/swagger.yaml

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27377,6 +27377,149 @@ paths:
2737727377
description: ""
2737827378
tags:
2737927379
- Non-Default Namespace
27380+
/namespaces/{ns}/status/multiparty:
27381+
get:
27382+
description: Gets the registration status of this organization and node on the
27383+
configured multiparty network
27384+
operationId: getStatusMultipartyNamespace
27385+
parameters:
27386+
- description: The namespace which scopes this request
27387+
in: path
27388+
name: ns
27389+
required: true
27390+
schema:
27391+
example: default
27392+
type: string
27393+
- description: Server-side request timeout (milliseconds, or set a custom suffix
27394+
like 10s)
27395+
in: header
27396+
name: Request-Timeout
27397+
schema:
27398+
default: 2m0s
27399+
type: string
27400+
responses:
27401+
"200":
27402+
content:
27403+
application/json:
27404+
schema:
27405+
properties:
27406+
contracts:
27407+
description: Information about the active and terminated multi-party
27408+
smart contracts configured for this namespace
27409+
properties:
27410+
active:
27411+
description: The currently active FireFly smart contract
27412+
properties:
27413+
firstEvent:
27414+
description: A blockchain specific string, such as a block
27415+
number, to start listening from. The special strings
27416+
'oldest' and 'newest' are supported by all blockchain
27417+
connectors
27418+
type: string
27419+
index:
27420+
description: The index of this contract in the config
27421+
file
27422+
type: integer
27423+
info:
27424+
description: Additional info about the current status
27425+
of the multi-party contract
27426+
properties:
27427+
finalEvent:
27428+
description: The identifier for the final blockchain
27429+
event received from this contract before termination
27430+
type: string
27431+
subscription:
27432+
description: The backend identifier of the subscription
27433+
for the FireFly BatchPin contract
27434+
type: string
27435+
version:
27436+
description: The version of this multiparty contract
27437+
type: integer
27438+
type: object
27439+
location:
27440+
description: A blockchain specific contract identifier.
27441+
For example an Ethereum contract address, or a Fabric
27442+
chaincode name and channel
27443+
status:
27444+
description: The status of the contract listener. One
27445+
of 'syncing', 'synced', or 'unknown'
27446+
type: string
27447+
type: object
27448+
terminated:
27449+
description: Previously-terminated FireFly smart contracts
27450+
items:
27451+
description: Previously-terminated FireFly smart contracts
27452+
properties:
27453+
firstEvent:
27454+
description: A blockchain specific string, such as a
27455+
block number, to start listening from. The special
27456+
strings 'oldest' and 'newest' are supported by all
27457+
blockchain connectors
27458+
type: string
27459+
index:
27460+
description: The index of this contract in the config
27461+
file
27462+
type: integer
27463+
info:
27464+
description: Additional info about the current status
27465+
of the multi-party contract
27466+
properties:
27467+
finalEvent:
27468+
description: The identifier for the final blockchain
27469+
event received from this contract before termination
27470+
type: string
27471+
subscription:
27472+
description: The backend identifier of the subscription
27473+
for the FireFly BatchPin contract
27474+
type: string
27475+
version:
27476+
description: The version of this multiparty contract
27477+
type: integer
27478+
type: object
27479+
location:
27480+
description: A blockchain specific contract identifier.
27481+
For example an Ethereum contract address, or a Fabric
27482+
chaincode name and channel
27483+
type: object
27484+
type: array
27485+
type: object
27486+
enabled:
27487+
description: Whether multi-party mode is enabled for this namespace
27488+
type: boolean
27489+
node:
27490+
description: Details of the local node
27491+
properties:
27492+
pendingRegistrationMessageId:
27493+
description: The ID of the pending message that broadcast
27494+
the identity claim to the network
27495+
format: uuid
27496+
type: string
27497+
status:
27498+
description: The status of the node registration, one of 'unregistered',
27499+
'registering', 'registered', and 'unknown'
27500+
type: string
27501+
type: object
27502+
org:
27503+
description: Details of the root organization identity registered
27504+
for this namespace on the local node
27505+
properties:
27506+
pendingRegistrationMessageId:
27507+
description: The ID of the pending message that broadcast
27508+
the identity claim to the network
27509+
format: uuid
27510+
type: string
27511+
status:
27512+
description: The status of the organization registration,
27513+
one of 'unregistered', 'registering', 'registered', and
27514+
'unknown'
27515+
type: string
27516+
type: object
27517+
type: object
27518+
description: Success
27519+
default:
27520+
description: ""
27521+
tags:
27522+
- Non-Default Namespace
2738027523
/namespaces/{ns}/subscriptions:
2738127524
get:
2738227525
description: Gets a list of subscriptions
@@ -36535,6 +36678,142 @@ paths:
3653536678
description: ""
3653636679
tags:
3653736680
- Default Namespace
36681+
/status/multiparty:
36682+
get:
36683+
description: Gets the registration status of this organization and node on the
36684+
configured multiparty network
36685+
operationId: getStatusMultiparty
36686+
parameters:
36687+
- description: Server-side request timeout (milliseconds, or set a custom suffix
36688+
like 10s)
36689+
in: header
36690+
name: Request-Timeout
36691+
schema:
36692+
default: 2m0s
36693+
type: string
36694+
responses:
36695+
"200":
36696+
content:
36697+
application/json:
36698+
schema:
36699+
properties:
36700+
contracts:
36701+
description: Information about the active and terminated multi-party
36702+
smart contracts configured for this namespace
36703+
properties:
36704+
active:
36705+
description: The currently active FireFly smart contract
36706+
properties:
36707+
firstEvent:
36708+
description: A blockchain specific string, such as a block
36709+
number, to start listening from. The special strings
36710+
'oldest' and 'newest' are supported by all blockchain
36711+
connectors
36712+
type: string
36713+
index:
36714+
description: The index of this contract in the config
36715+
file
36716+
type: integer
36717+
info:
36718+
description: Additional info about the current status
36719+
of the multi-party contract
36720+
properties:
36721+
finalEvent:
36722+
description: The identifier for the final blockchain
36723+
event received from this contract before termination
36724+
type: string
36725+
subscription:
36726+
description: The backend identifier of the subscription
36727+
for the FireFly BatchPin contract
36728+
type: string
36729+
version:
36730+
description: The version of this multiparty contract
36731+
type: integer
36732+
type: object
36733+
location:
36734+
description: A blockchain specific contract identifier.
36735+
For example an Ethereum contract address, or a Fabric
36736+
chaincode name and channel
36737+
status:
36738+
description: The status of the contract listener. One
36739+
of 'syncing', 'synced', or 'unknown'
36740+
type: string
36741+
type: object
36742+
terminated:
36743+
description: Previously-terminated FireFly smart contracts
36744+
items:
36745+
description: Previously-terminated FireFly smart contracts
36746+
properties:
36747+
firstEvent:
36748+
description: A blockchain specific string, such as a
36749+
block number, to start listening from. The special
36750+
strings 'oldest' and 'newest' are supported by all
36751+
blockchain connectors
36752+
type: string
36753+
index:
36754+
description: The index of this contract in the config
36755+
file
36756+
type: integer
36757+
info:
36758+
description: Additional info about the current status
36759+
of the multi-party contract
36760+
properties:
36761+
finalEvent:
36762+
description: The identifier for the final blockchain
36763+
event received from this contract before termination
36764+
type: string
36765+
subscription:
36766+
description: The backend identifier of the subscription
36767+
for the FireFly BatchPin contract
36768+
type: string
36769+
version:
36770+
description: The version of this multiparty contract
36771+
type: integer
36772+
type: object
36773+
location:
36774+
description: A blockchain specific contract identifier.
36775+
For example an Ethereum contract address, or a Fabric
36776+
chaincode name and channel
36777+
type: object
36778+
type: array
36779+
type: object
36780+
enabled:
36781+
description: Whether multi-party mode is enabled for this namespace
36782+
type: boolean
36783+
node:
36784+
description: Details of the local node
36785+
properties:
36786+
pendingRegistrationMessageId:
36787+
description: The ID of the pending message that broadcast
36788+
the identity claim to the network
36789+
format: uuid
36790+
type: string
36791+
status:
36792+
description: The status of the node registration, one of 'unregistered',
36793+
'registering', 'registered', and 'unknown'
36794+
type: string
36795+
type: object
36796+
org:
36797+
description: Details of the root organization identity registered
36798+
for this namespace on the local node
36799+
properties:
36800+
pendingRegistrationMessageId:
36801+
description: The ID of the pending message that broadcast
36802+
the identity claim to the network
36803+
format: uuid
36804+
type: string
36805+
status:
36806+
description: The status of the organization registration,
36807+
one of 'unregistered', 'registering', 'registered', and
36808+
'unknown'
36809+
type: string
36810+
type: object
36811+
type: object
36812+
description: Success
36813+
default:
36814+
description: ""
36815+
tags:
36816+
- Default Namespace
3653836817
/subscriptions:
3653936818
get:
3654036819
description: Gets a list of subscriptions
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright © 2024 Kaleido, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package apiserver
18+
19+
import (
20+
"net/http"
21+
22+
"github.com/hyperledger/firefly-common/pkg/ffapi"
23+
"github.com/hyperledger/firefly/internal/coremsgs"
24+
"github.com/hyperledger/firefly/pkg/core"
25+
)
26+
27+
var getStatusMultiparty = &ffapi.Route{
28+
Name: "getStatusMultiparty",
29+
Path: "status/multiparty",
30+
Method: http.MethodGet,
31+
PathParams: nil,
32+
QueryParams: nil,
33+
Description: coremsgs.APIEndpointsGetMultipartyStatus,
34+
JSONInputValue: nil,
35+
JSONOutputValue: func() interface{} { return &core.NamespaceMultipartyStatus{} },
36+
JSONOutputCodes: []int{http.StatusOK},
37+
Extensions: &coreExtensions{
38+
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
39+
output, err = cr.or.GetMultipartyStatus(cr.ctx)
40+
return output, err
41+
},
42+
},
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright © 2024 Kaleido, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package apiserver
18+
19+
import (
20+
"net/http/httptest"
21+
"testing"
22+
23+
"github.com/hyperledger/firefly/pkg/core"
24+
"github.com/stretchr/testify/assert"
25+
"github.com/stretchr/testify/mock"
26+
)
27+
28+
func TestGetMultipartyStatus(t *testing.T) {
29+
o, r := newTestAPIServer()
30+
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
31+
req := httptest.NewRequest("GET", "/api/v1/status/multiparty", nil)
32+
req.Header.Set("Content-Type", "application/json; charset=utf-8")
33+
res := httptest.NewRecorder()
34+
35+
o.On("GetMultipartyStatus", mock.Anything).
36+
Return(&core.NamespaceMultipartyStatus{}, nil)
37+
r.ServeHTTP(res, req)
38+
39+
assert.Equal(t, 200, res.Result().StatusCode)
40+
}

internal/apiserver/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ var routes = append(
107107
getOps,
108108
getPins,
109109
getStatus,
110+
getStatusMultiparty,
110111
getStatusBatchManager,
111112
getSubscriptionByID,
112113
getSubscriptions,

0 commit comments

Comments
 (0)