clappform

Clappform Python API wrapper

class clappform.GrpcBase(target, token, location, credentials_fn=<function ssl_channel_credentials>, options_fn=<function default_options>, compression_fn=None)[source]

Bases: object

Base class for gRPC connections.

Parameters:
  • target (str) – The target server address.

  • token (str) – The authentication token.

  • location (str) – The client location (subdomain).

  • credentials_fn (Optional[Callable[[], grpc.ChannelCredentials]], optional) – A callable that returns gRPC channel credentials, defaults to grpc.ssl_channel_credentials.

  • options_fn (Optional[Callable[[], GrpcChannelOptions]]) – A callable that returns gRPC channel options, defaults to clappform.utils.default_options().

  • compression_fn (Optional[Callable[[], grpc.Compression]]) – A callable that returns gRPC compression options, defaults to None.

Variables:
  • channel (grpc.Channel) – The gRPC channel.

  • metadata (GrpcMetadata) – The metadata for gRPC calls.

class clappform.Data(token, location, target='data.clappform.com:50051', credentials_fn=<function ssl_channel_credentials>, options_fn=<function default_options>, compression_fn=None)[source]

Bases: GrpcBase

Data class for interacting with gRPC services.

Inherits from GrpcBase.

Parameters:
  • token (str) – The authentication token.

  • location (str) – The client location (subdomain).

  • target (str, optional) – The target server address, defaults to “data.clappform.com:50051”.

  • credentials_fn (Optional[Callable[[], grpc.ChannelCredentials]]) – A callable that returns gRPC channel credentials, defaults to grpc.ssl_channel_credentials.

  • options_fn (Optional[Callable[[], GrpcChannelOptions]]) – A callable that returns gRPC channel options, defaults to clappform.utils.default_options().

  • compression_fn (Optional[Callable[[], grpc.Compression]]) – A callable that returns gRPC compression options, defaults to None.

Variables:
aggregate(request, **kwargs)[source]

Sends an aggregate request to the gRPC service and yields responses.

Parameters:

request (AggregateStreamRequest) – The aggregate request to be sent.

Returns:

An iterator over aggregate responses.

Return type:

Iterator[AggregateResponse]

Raises:

grpc.RpcError – If an RPC error occurs

This method sends an aggregate request to the gRPC service via the AggregateStream method of the AggregateManagementStub. The responses from the service are yielded one by one.

Example usage:

from clappform.proto.clappform.data.v1 import aggregate_pb2

# Create an instance of the Data class
data_instance = Data(token="your_token", location="your_location")

# Create an AggregateStreamRequest
request = aggregate_pb2.AggregateStreamRequest(
    # Fill in the request details
)

# Iterate over the responses
for response in data_instance.aggregate(request):
    print(response)

Note

Ensure that the clappform.proto.clappform.data.v1.aggregate_pb2 module is imported and available in your code to use the AggregateStreamRequest and AggregateResponse classes.

insert_many(request_iterator)[source]

Sends multiple insert requests to the gRPC service and yields responses.

Parameters:

request_iterator (Iterator[InsertRequest]) – An iterator over insert requests.

Returns:

An iterator over insert responses.

Return type:

Iterator[InsertResponse]

Raises:

grpc.RpcError – If an RPC error occurs

This method sends multiple insert requests to the gRPC service via the InsertMany method of the InsertManagementStub. The responses from the service are yielded one by one.

Example usage:

import clappform
from clappform.proto.clappform.data.v1 import insert_pb2

# Create an instance of the Data class
d = clappform.Data(token="your_token", location="your_location")

# Create an iterator of InsertRequest
request_iterator = iter([
    insert_pb2.InsertRequest(
        # Fill in the request details
    ),
    # Add more requests as needed
])

# Iterate over the responses
for response in d.insert_many(request_iterator):
    print(response)

Note

Ensure that the clappform.proto.clappform.data.v1.insert_pb2 module is imported and available in your code to use the InsertRequest and InsertResponse classes.

delete_many_by_oids(request)[source]

Sends a delete request to the gRPC service to delete multiple items by OIDs.

Parameters:

request (DeleteRequestOids) – The delete request containing OIDs.

Returns:

A message indicating the result of the delete operation.

Return type:

Message

Raises:

grpc.RpcError – If an RPC error occurs

This method sends a delete request to the gRPC service via the DeleteManyByOids method of the DeleteManagementStub. The response from the service indicates the result of the operation.

Example usage:

import clappform
from clappform.proto.clappform.data.v1 import delete_pb2

# Create an instance of the Data class
d = clappform.Data(token="your_token", location="your_location")

# Create a DeleteRequestOids
request = delete_pb2.DeleteRequestOids(
    # Fill in the request details
)

# Send the delete request and get the response
response = d.delete_many_by_oids(request)
print(response)

Note

Ensure that the clappform.proto.clappform.data.v1.delete_pb2 and clappform.proto.clappform.data.v1.commons_pb2 modules are imported and available in your code to use the DeleteRequestOids and Message classes.

update_replace_many(request)[source]

Sends an update request to the gRPC service to replace multiple items.

Parameters:

request (UpdateRequestByOid) – The update request.

Returns:

The update request response.

Return type:

UpdateRequest

Raises:

grpc.RpcError – If an RPC error occurs

This method sends an update request to the gRPC service via the ReplaceMany method of the UpdateManagementStub. The response from the service contains the updated request.

Example usage:

import clappform
from clappform.proto.clappform.data.v1 import update_pb2

# Create an instance of the Data class
d = clappform.Data(token="your_token", location="your_location")

# Create an UpdateRequestByOid
request = update_pb2.UpdateRequestByOid(
    # Fill in the request details
)

# Send the update request and get the response
response = d.update_replace_many(request)
print(response)

Note

Ensure that the clappform.proto.clappform.data.v1.update_pb2 module is imported and available in your code to use the UpdateRequestByOid and UpdateRequest classes.

class clappform.Client(token, location, target='data.clappform.com:50051', credentials_fn=<function ssl_channel_credentials>, options_fn=<function default_options>, compression_fn=None)[source]

Bases: GrpcBase

Client class for interfacing with various gRPC services provided by Clappform.

Inherits from GrpcBase.

Parameters:
  • token (str) – The authentication token.

  • location (str) – The client location (subdomain).

  • target (str, optional) – The target server address, defaults to “data.clappform.com:50051”.

  • credentials_fn (Optional[Callable[[], grpc.ChannelCredentials]]) – A callable that returns gRPC channel credentials, defaults to grpc.ssl_channel_credentials.

  • options_fn (Optional[Callable[[], GrpcChannelOptions]]) – A callable that returns gRPC channel options, defaults to clappform.utils.default_options().

  • compression_fn (Optional[Callable[[], grpc.Compression]]) – A callable that returns gRPC compression options, defaults to None.

Variables:
actionflow_start(request)[source]

Starts an actionflow using the gRPC service.

Parameters:

request (StartActionflow) – The start actionflow request.

Returns:

The response for starting an actionflow.

Return type:

StartActionflowResponse

Raises:

grpc.RpcError – If an RPC error occurs

Example

import clappform
from clappform.proto.clappform.data.v1 import actionflow_pb2

# Create an instance of the Data class
c = clappform.Client(token="your-token", location="your-location")

# Create an StartActionflow
request = actionflow_pb2.StartActionflow(...)

# Send the start request and get the response
response = c.actionflow_start(request)
print(response)

Note

Ensure that the clappform.proto.clappform.client.v1.actionflow_pb2 module is imported and available in your code to use the StartActionflow and StartActionflowResponse classes.

collection_get(request)[source]

Gets a collection using the gRPC service.

Parameters:

request (Read) – The read request for the collection.

Returns:

The collection response.

Return type:

Collection

Raises:

grpc.RpcError – If an RPC error occurs

Example

import clappform
from clappform.proto.clappform.v1 import commons_pb2

# Create an instance of the Data class
c = clappform.Client(token="your-token", location="your-location")

# Create a Read
request = commons_pb2.Read(...)

# Send the read request and get the response
response = c.collection_get(request)
print(response)

Note

Ensure that the clappform.proto.clappform.client.v1.collection_pb2 and clappform.proto.clappform.v1.commons_pb2 module is imported and available in your code to use the Read and Collection classes.

query_get(request)[source]

Gets a query using the gRPC service.

Parameters:

request (Read) – The read request for the query.

Returns:

The query response.

Return type:

Query

Raises:

grpc.RpcError – If an RPC error occurs

Example

import clappform
from clappform.proto.clappform.v1 import commons_pb2

# Create an instance of the Data class
c = clappform.Client(token="your-token", location="your-location")

# Create a Read
request = commons_pb2.Read(...)

# Send the read request and get the response
response = c.query_get(request)
print(response)
Note:

Ensure that the clappform.proto.clappform.client.v1.query_pb2 and clappform.proto.clappform.v1.commons_pb2 module is imported and available in your code to use the Read and Query classes.