blpapi.Service
- class blpapi.Service(handle, sessions)
Defines a service which provides access to API data.
A
Serviceobject is obtained from aSessionand contains theOperations (each of which contains its own schema) and the schema forEvents which thisServicemay produce. AServiceobject is also used to createRequestobjects used with aSessionto issue requests.Provider services are created to generate API data and must be registered before use.
The
Serviceobject is a handle to the underlying data which is owned by theSession. Once aServicehas been succesfully opened in aSessionit remains accessible until theSessionis terminated.- authorizationServiceName()
Get the authorization service name.
- Return type
- Returns
The name of the
Servicewhich must be used in order to authorize access to restricted operations on thisService. If no authorization is required to access operations on this service an empty string is returned.
Authorization services never require authorization to use.
- createAdminEvent()
-
Use an
EventFormatterto addMessages to theEventand set fields.DEPRECATED Use
Service.createPublishEvent().
- createAuthorizationRequest(authorizationOperation=None)
Create an empty
Requestobject forauthorizationOperation.- Parameters
authorizationOperation (
Optional[str]) – A valid operation on this service- Return type
- Returns
An empty request for the specified
authorizationOperation.- Raises
Exception – If
authorizationOperationdoes not identify a valid operation in theService
An application must populate the
Requestbefore issuing it usingSession.sendAuthorizationRequest().
- createPublishEvent()
-
Use an
EventFormatterto addMessages to theEventand set fields.
- createRequest(operation)
Create an empty Request object for the specified
operation.- Parameters
operation (
str) – A valid operation on this service- Return type
- Returns
An empty request for the specified
operation.- Raises
Exception – If
operationdoes not identify a valid operation in theService
An application must populate the
Requestbefore issuing it usingSession.sendRequest().
- createResponseEvent(correlationId)
Create a
RESPONSEEventto answer the request.- Parameters
correlationId – Correlation id to associate with the created event
- Returns
The created response event.
Use an
EventFormatterto addMessages to theEventand set fields.
- eventDefinitions()
- Return type
- Returns
An iterator over unsolicited events defined by this
Service.
- getEventDefinition(nameOrIndex)
Get the definition of a specified event.
- Parameters
nameOrIndex (
Union[str,Name,bytes,int]) – Name or index of the event- Return type
- Returns
Object describing the element identified by the specified
nameOrIndex.- Raises
NotFoundException – If
nameOrIndexis a string andhasEventDefinition(nameOrIndex) != TrueIndexOutOfRangeException – If
nameOrIndexis an integer andnameOrIndex >= numEventDefinitions()
- getOperation(nameOrIndex)
- hasEventDefinition(name)
- hasOperation(name)
- numEventDefinitions()
- operations()
- toString(level=0, spacesPerLevel=4)
Convert this
Serviceschema to a string.- Parameters
- Return type
- Returns
This object formatted as a string
If
levelis negative, suppress indentation of the first line. IfspacesPerLevelis negative, format the entire output on one line, suppressing all but the initial indentation (as governed bylevel).