Skip to content

Commit

Permalink
Merge pull request #1509 from kaleido-io/multiparty-status
Browse files Browse the repository at this point in the history
Add multiparty status API
  • Loading branch information
EnriqueL8 authored May 28, 2024
2 parents 261ff1b + 72a4525 commit 3445132
Show file tree
Hide file tree
Showing 23 changed files with 1,392 additions and 52 deletions.
279 changes: 279 additions & 0 deletions doc-site/docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27377,6 +27377,149 @@ paths:
description: ""
tags:
- Non-Default Namespace
/namespaces/{ns}/status/multiparty:
get:
description: Gets the registration status of this organization and node on the
configured multiparty network
operationId: getStatusMultipartyNamespace
parameters:
- description: The namespace which scopes this request
in: path
name: ns
required: true
schema:
example: default
type: string
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
name: Request-Timeout
schema:
default: 2m0s
type: string
responses:
"200":
content:
application/json:
schema:
properties:
contracts:
description: Information about the active and terminated multi-party
smart contracts configured for this namespace
properties:
active:
description: The currently active FireFly smart contract
properties:
firstEvent:
description: A blockchain specific string, such as a block
number, to start listening from. The special strings
'oldest' and 'newest' are supported by all blockchain
connectors
type: string
index:
description: The index of this contract in the config
file
type: integer
info:
description: Additional info about the current status
of the multi-party contract
properties:
finalEvent:
description: The identifier for the final blockchain
event received from this contract before termination
type: string
subscription:
description: The backend identifier of the subscription
for the FireFly BatchPin contract
type: string
version:
description: The version of this multiparty contract
type: integer
type: object
location:
description: A blockchain specific contract identifier.
For example an Ethereum contract address, or a Fabric
chaincode name and channel
status:
description: The status of the contract listener. One
of 'syncing', 'synced', or 'unknown'
type: string
type: object
terminated:
description: Previously-terminated FireFly smart contracts
items:
description: Previously-terminated FireFly smart contracts
properties:
firstEvent:
description: A blockchain specific string, such as a
block number, to start listening from. The special
strings 'oldest' and 'newest' are supported by all
blockchain connectors
type: string
index:
description: The index of this contract in the config
file
type: integer
info:
description: Additional info about the current status
of the multi-party contract
properties:
finalEvent:
description: The identifier for the final blockchain
event received from this contract before termination
type: string
subscription:
description: The backend identifier of the subscription
for the FireFly BatchPin contract
type: string
version:
description: The version of this multiparty contract
type: integer
type: object
location:
description: A blockchain specific contract identifier.
For example an Ethereum contract address, or a Fabric
chaincode name and channel
type: object
type: array
type: object
enabled:
description: Whether multi-party mode is enabled for this namespace
type: boolean
node:
description: Details of the local node
properties:
pendingRegistrationMessageId:
description: The ID of the pending message that broadcast
the identity claim to the network
format: uuid
type: string
status:
description: The status of the node registration, one of 'unregistered',
'registering', 'registered', and 'unknown'
type: string
type: object
org:
description: Details of the root organization identity registered
for this namespace on the local node
properties:
pendingRegistrationMessageId:
description: The ID of the pending message that broadcast
the identity claim to the network
format: uuid
type: string
status:
description: The status of the organization registration,
one of 'unregistered', 'registering', 'registered', and
'unknown'
type: string
type: object
type: object
description: Success
default:
description: ""
tags:
- Non-Default Namespace
/namespaces/{ns}/subscriptions:
get:
description: Gets a list of subscriptions
Expand Down Expand Up @@ -36535,6 +36678,142 @@ paths:
description: ""
tags:
- Default Namespace
/status/multiparty:
get:
description: Gets the registration status of this organization and node on the
configured multiparty network
operationId: getStatusMultiparty
parameters:
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
name: Request-Timeout
schema:
default: 2m0s
type: string
responses:
"200":
content:
application/json:
schema:
properties:
contracts:
description: Information about the active and terminated multi-party
smart contracts configured for this namespace
properties:
active:
description: The currently active FireFly smart contract
properties:
firstEvent:
description: A blockchain specific string, such as a block
number, to start listening from. The special strings
'oldest' and 'newest' are supported by all blockchain
connectors
type: string
index:
description: The index of this contract in the config
file
type: integer
info:
description: Additional info about the current status
of the multi-party contract
properties:
finalEvent:
description: The identifier for the final blockchain
event received from this contract before termination
type: string
subscription:
description: The backend identifier of the subscription
for the FireFly BatchPin contract
type: string
version:
description: The version of this multiparty contract
type: integer
type: object
location:
description: A blockchain specific contract identifier.
For example an Ethereum contract address, or a Fabric
chaincode name and channel
status:
description: The status of the contract listener. One
of 'syncing', 'synced', or 'unknown'
type: string
type: object
terminated:
description: Previously-terminated FireFly smart contracts
items:
description: Previously-terminated FireFly smart contracts
properties:
firstEvent:
description: A blockchain specific string, such as a
block number, to start listening from. The special
strings 'oldest' and 'newest' are supported by all
blockchain connectors
type: string
index:
description: The index of this contract in the config
file
type: integer
info:
description: Additional info about the current status
of the multi-party contract
properties:
finalEvent:
description: The identifier for the final blockchain
event received from this contract before termination
type: string
subscription:
description: The backend identifier of the subscription
for the FireFly BatchPin contract
type: string
version:
description: The version of this multiparty contract
type: integer
type: object
location:
description: A blockchain specific contract identifier.
For example an Ethereum contract address, or a Fabric
chaincode name and channel
type: object
type: array
type: object
enabled:
description: Whether multi-party mode is enabled for this namespace
type: boolean
node:
description: Details of the local node
properties:
pendingRegistrationMessageId:
description: The ID of the pending message that broadcast
the identity claim to the network
format: uuid
type: string
status:
description: The status of the node registration, one of 'unregistered',
'registering', 'registered', and 'unknown'
type: string
type: object
org:
description: Details of the root organization identity registered
for this namespace on the local node
properties:
pendingRegistrationMessageId:
description: The ID of the pending message that broadcast
the identity claim to the network
format: uuid
type: string
status:
description: The status of the organization registration,
one of 'unregistered', 'registering', 'registered', and
'unknown'
type: string
type: object
type: object
description: Success
default:
description: ""
tags:
- Default Namespace
/subscriptions:
get:
description: Gets a list of subscriptions
Expand Down
43 changes: 43 additions & 0 deletions internal/apiserver/route_get_status_multiparty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright © 2024 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-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/pkg/core"
)

var getStatusMultiparty = &ffapi.Route{
Name: "getStatusMultiparty",
Path: "status/multiparty",
Method: http.MethodGet,
PathParams: nil,
QueryParams: nil,
Description: coremsgs.APIEndpointsGetMultipartyStatus,
JSONInputValue: nil,
JSONOutputValue: func() interface{} { return &core.NamespaceMultipartyStatus{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
output, err = cr.or.GetMultipartyStatus(cr.ctx)
return output, err
},
},
}
40 changes: 40 additions & 0 deletions internal/apiserver/route_get_status_multiparty_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright © 2024 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/pkg/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestGetMultipartyStatus(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
req := httptest.NewRequest("GET", "/api/v1/status/multiparty", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

o.On("GetMultipartyStatus", mock.Anything).
Return(&core.NamespaceMultipartyStatus{}, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}
1 change: 1 addition & 0 deletions internal/apiserver/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ var routes = append(
getOps,
getPins,
getStatus,
getStatusMultiparty,
getStatusBatchManager,
getSubscriptionByID,
getSubscriptions,
Expand Down
Loading

0 comments on commit 3445132

Please sign in to comment.