Categorygithub.com/redhat-cne/rest-api
modulepackage
2.0.0+incompatible
Repository: https://github.com/redhat-cne/rest-api.git
Documentation: pkg.go.dev

# README

Rest API

go-doc Go Report Card LICENSE

Available routes


POST /api/ocloudNotifications/v1/subscriptions
POST /api/ocloudNotifications/v1/publishers
GET /api/ocloudNotifications/v1/subscriptions
GET /api/ocloudNotifications/v1/publishers
GET /api/ocloudNotifications/v1/subscriptions/$subscriptionid
GET /api/ocloudNotifications/v1/publishers/$publisherid
GET /api/ocloudNotifications/v1/health
POST /api/ocloudNotifications/v1/log
POST /api/ocloudNotifications/v1/create/event

Pub/Sub Rest API

Rest API spec .

Version: 1.0.0

/publishers/

POST

Summary

Creates a new publisher.

Description

If publisher creation is success(or if already exists), publisher will be returned with Created (201).

Parameters
NameLocated inDescriptionRequiredSchema
publisherbodypublisher to add to the list of pubPubSub
Responses
CodeDescriptionSchema
201publisher/subscription data modelPubSub
400Error Bad Requestobject

/subscriptions/

POST

Summary

Creates a new subscription.

Description

If subscription creation is success(or if already exists), subscription will be returned with Created (201).

Parameters
NameLocated inDescriptionRequiredSchema
subscriptionbodysubscription to add to the list of subscriptionsyesPubSub
Responses
CodeDescriptionSchema
201publisher/subscription data modelPubSub
400Error Bad Requestobject

/create/event/

POST

Summary

Creates a new event.

Description

If publisher is present for the event, then event creation is success and be returned with Accepted (202).

Parameters
NameLocated inDescriptionRequiredSchema
eventbodyevent along with publisher idYesEvent
Responses
CodeDescriptionSchema
202Acceptedobject
400Error Bad Requestobject

/subscriptions/status/{subscriptionid}

PUT

Summary

Creates a new status ping request.

Description

If a subscription is present for the request, then status request is success and be returned with Accepted (202).

Parameters
NameLocated inDescriptionRequiredSchema
subscriptionidrequestsubscription idYes
Responses
CodeDescriptionSchema
202Acceptedobject
400Error Bad Requestobject

Models

Data

Data ... cloud native events' data Json payload is as follows,


{
"version": "v1.0",
"values": [{
"resource": "/cluster/node/ptp",
"dataType": "notification",
"valueType": "enumeration",
"value": "ACQUIRING-SYNC"
}, {
"resource": "/cluster/node/clock",
"dataType": "metric",
"valueType": "decimal64.3",
"value": 100.3
}]
}
NameTypeDescriptionRequired
values[ DataValue ]Yes
versionstringYes

DataType

NameTypeDescriptionRequired
DataTypestringYes

DataValue

DataValue Json payload is as follows,


{
"resource": "/cluster/node/ptp",
"dataType": "notification",
"valueType": "enumeration",
"value": "ACQUIRING-SYNC"
}
NameTypeDescriptionRequired
dataTypeDataTypeyes
resourcestringyes
valueobjectyes
valueTypeValueTypeyes

Event

Event Json payload is as follows,


{
"id": "5ce55d17-9234-4fee-a589-d0f10cb32b8e",
"type": "event.synchronization-state-chang",
"time": "2021-02-05T17:31:00Z",
"data": {
"version": "v1.0",
"values": [{
"resource": "/cluster/node/ptp",
"dataType": "notification",
"valueType": "enumeration",
"value": "ACQUIRING-SYNC"
}, {
"resource": "/cluster/node/clock",
"dataType": "metric",
"valueType": "decimal64.3",
"value": 100.3
}]
}
}

Event request model

NameTypeDescriptionRequired
dataDatayes
dataContentTypestringDataContentType - the Data content type +requiredyes
dataSchemaURINo
idstringID of the event; must be non-empty and unique within the scope of the producer. +requiredyes
timeTimestampyes
typestringType - The type of the occurrence which has happened. +requiredyes

PubSub

PubSub Json request payload is as follows,


{
"id": "789be75d-7ac3-472e-bbbc-6d62878aad4a",
"endpointUri": "http://localhost:9090/ack/event",
"uriLocation":  "<http://localhost:8080/api/ocloudNotifications/v1/publishers/{publisherid>}",
"resource":  "/east-edge-10/vdu3/o-ran-sync/sync-group/sync-status/sync-state"
}

PubSub request model

NameTypeDescriptionRequired
endpointUriURIyes
resourcestringResource - The type of the Resource. +requiredyes

Timestamp

Timestamp wraps time.Time to normalize the time layout to RFC3339. It is intended to enforce compliance with the Cloud Native events spec for their definition of Timestamp. Custom marshal methods are implemented to ensure the outbound Timestamp is a string in the RFC3339 layout.

NameTypeDescriptionRequired
TimestampobjectTimestamp wraps time.Time to normalize the time layout to RFC3339. It is intended to enforce compliance with the Cloud Native events spec for their definition of Timestamp. Custom marshal methods are implemented to ensure the outbound Timestamp is a string in the RFC3339 layout.

URI

URI is a wrapper to url.URL. It is intended to enforce compliance with the Cloud Native Events spec for their definition of URI. Custom marshal methods are implemented to ensure the outbound URI object is a flat string.

ValueType

NameTypeDescriptionRequired
ValueTypeENUMENUMERATION,DECIMALyes

Collecting metrics with Prometheus

Cloud native events rest API comes with following metrics collectors .

  1. Number of events published by the rest api.
  2. Number of active subscriptions.
  3. Number of active publishers.

Metrics details

# Packages

No description provided by the author
Package restapi Pub/Sub Rest API.

# Functions

InitServer is used to supply configurations for rest routes server.

# Constants

No description provided by the author

# Variables

ServerInstance ..

# Structs

Server defines rest routes server object.