Cloudflare.Queue (Cloudflare v0.5.0)

Copy Markdown View Source

Queue

Create Event Subscription

POST /accounts/{account_id}/event_subscriptions/subscriptions

Create a new event subscription for a queue

Responses

200 Successfully created event subscription

Data is at body["result"]

{
  "created_at": "*string*",
  "destination": {},
  "enabled": "*boolean*",
  "events": [
    "*string*"
  ],
  "id": "*string*",
  "modified_at": "*string*",
  "name": "*string*",
  "source": {}
}
400 Invalid request body or validation errors
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
404 Queue does not exist or resource not found on source
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
405 Multiple subscriptions on same resource not supported
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

List Event Subscriptions

GET /accounts/{account_id}/event_subscriptions/subscriptions

Get a paginated list of event subscriptions with optional sorting and filtering

Responses

200 List of event subscriptions

Data is at body["result"]

[
  {
    "created_at": "*string*",
    "destination": {},
    "enabled": "*boolean*",
    "events": [
      "*string*"
    ],
    "id": "*string*",
    "modified_at": "*string*",
    "name": "*string*",
    "source": {}
  }
]
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Update Event Subscription

PATCH /accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}

Update an existing event subscription

Responses

200 Successfully created event subscription

Data is at body["result"]

{
  "created_at": "*string*",
  "destination": {},
  "enabled": "*boolean*",
  "events": [
    "*string*"
  ],
  "id": "*string*",
  "modified_at": "*string*",
  "name": "*string*",
  "source": {}
}
400 Invalid request body or validation errors
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
404 Queue does not exist or resource not found on source
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Get Event Subscription

GET /accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}

Get details about an existing event subscription

Responses

200 Details about an event subscription

Data is at body["result"]

{
  "created_at": "*string*",
  "destination": {},
  "enabled": "*boolean*",
  "events": [
    "*string*"
  ],
  "id": "*string*",
  "modified_at": "*string*",
  "name": "*string*",
  "source": {}
}
404 Event subscription does not exist
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Delete Event Subscription

DELETE /accounts/{account_id}/event_subscriptions/subscriptions/{subscription_id}

Delete an existing event subscription

Responses

200 Successfully created event subscription

Data is at body["result"]

{
  "created_at": "*string*",
  "destination": {},
  "enabled": "*boolean*",
  "events": [
    "*string*"
  ],
  "id": "*string*",
  "modified_at": "*string*",
  "name": "*string*",
  "source": {}
}

Create Queue

POST /accounts/{account_id}/queues

Create a new queue

Responses

200 Created Queue

Data is at body["result"]

{
  "consumers": [
    {}
  ],
  "consumers_total_count": "*number*",
  "created_on": "*string*",
  "modified_on": "*string*",
  "producers": [
    {}
  ],
  "producers_total_count": "*number*",
  "queue_id": "*string*",
  "queue_name": "*string*",
  "settings": {
    "delivery_delay": "*number*",
    "delivery_paused": "*boolean*",
    "message_retention_period": "*number*"
  }
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

List Queues

GET /accounts/{account_id}/queues

Returns the queues owned by an account.

Responses

200 List of all Queues that belong to this account

Data is at body["result"]

[
  {
    "consumers": [
      {}
    ],
    "consumers_total_count": "*number*",
    "created_on": "*string*",
    "modified_on": "*string*",
    "producers": [
      {}
    ],
    "producers_total_count": "*number*",
    "queue_id": "*string*",
    "queue_name": "*string*",
    "settings": {
      "delivery_delay": "*number*",
      "delivery_paused": "*boolean*",
      "message_retention_period": "*number*"
    }
  }
]
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Update Queue

PUT /accounts/{account_id}/queues/{queue_id}

Updates a Queue. Note that this endpoint does not support partial updates. If successful, the Queue's configuration is overwritten with the supplied configuration.

Responses

200 Updated Queue

Data is at body["result"]

{
  "consumers": [
    {}
  ],
  "consumers_total_count": "*number*",
  "created_on": "*string*",
  "modified_on": "*string*",
  "producers": [
    {}
  ],
  "producers_total_count": "*number*",
  "queue_id": "*string*",
  "queue_name": "*string*",
  "settings": {
    "delivery_delay": "*number*",
    "delivery_paused": "*boolean*",
    "message_retention_period": "*number*"
  }
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Update Queue

PATCH /accounts/{account_id}/queues/{queue_id}

Updates a Queue.

Responses

200 Updated Queue

Data is at body["result"]

{
  "consumers": [
    {}
  ],
  "consumers_total_count": "*number*",
  "created_on": "*string*",
  "modified_on": "*string*",
  "producers": [
    {}
  ],
  "producers_total_count": "*number*",
  "queue_id": "*string*",
  "queue_name": "*string*",
  "settings": {
    "delivery_delay": "*number*",
    "delivery_paused": "*boolean*",
    "message_retention_period": "*number*"
  }
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Get Queue

GET /accounts/{account_id}/queues/{queue_id}

Get details about a specific queue.

Responses

200 Details of the requested Queue

Data is at body["result"]

{
  "consumers": [
    {}
  ],
  "consumers_total_count": "*number*",
  "created_on": "*string*",
  "modified_on": "*string*",
  "producers": [
    {}
  ],
  "producers_total_count": "*number*",
  "queue_id": "*string*",
  "queue_name": "*string*",
  "settings": {
    "delivery_delay": "*number*",
    "delivery_paused": "*boolean*",
    "message_retention_period": "*number*"
  }
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Delete Queue

DELETE /accounts/{account_id}/queues/{queue_id}

Deletes a queue

Responses

200 Successful delete

Data is at body["result"]

{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Create a Queue Consumer

POST /accounts/{account_id}/queues/{queue_id}/consumers

Creates a new consumer for a Queue

Responses

200 Create Queue Consumer response.

Data is at body["result"]

{}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

List Queue Consumers

GET /accounts/{account_id}/queues/{queue_id}/consumers

Returns the consumers for a Queue

Responses

200 All consumers attached to this Queue

Data is at body["result"]

[
  {}
]
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Update Queue Consumer

PUT /accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}

Updates the consumer for a queue, or creates one if it does not exist.

Responses

200 Update Queue Consumer response.

Data is at body["result"]

{}
4XX Update Queue Consumer response failure.
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Get Queue Consumer

GET /accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}

Fetches the consumer for a queue by consumer id

Responses

200 Get Queue Consumer response.

Data is at body["result"]

{}
4XX Get Queue Consumer response failure.
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Delete Queue Consumer

DELETE /accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}

Deletes the consumer for a queue.

Responses

200 Successful consumer delete

Data is at body["result"]

{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Push Message

POST /accounts/{account_id}/queues/{queue_id}/messages

Push a message to a Queue

Responses

200 Successful message ingestion

Data is at body["result"]

{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Acknowledge + Retry Queue Messages

POST /accounts/{account_id}/queues/{queue_id}/messages/ack

Acknowledge + Retry messages from a Queue

Responses

200 Details of ACKs and retries

Data is at body["result"]

{
  "ackCount": "*number*",
  "retryCount": "*number*",
  "warnings": [
    "*string*"
  ]
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Push Message Batch

POST /accounts/{account_id}/queues/{queue_id}/messages/batch

Push a batch of message to a Queue

Responses

200 Successful batch ingestion

Data is at body["result"]

{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Pull Queue Messages

POST /accounts/{account_id}/queues/{queue_id}/messages/pull

Pull a batch of messages from a Queue

Responses

200 A batch of messages in the Queue

Data is at body["result"]

{
  "message_backlog_count": "*number*",
  "messages": [
    {
      "attempts": "*number*",
      "body": "*string*",
      "id": "*string*",
      "lease_id": "*string*",
      "metadata": {},
      "timestamp_ms": "*number*"
    }
  ]
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Purge Queue

POST /accounts/{account_id}/queues/{queue_id}/purge

Deletes all messages from the Queue.

Responses

200 Updated Queue

Data is at body["result"]

{
  "consumers": [
    {}
  ],
  "consumers_total_count": "*number*",
  "created_on": "*string*",
  "modified_on": "*string*",
  "producers": [
    {}
  ],
  "producers_total_count": "*number*",
  "queue_id": "*string*",
  "queue_name": "*string*",
  "settings": {
    "delivery_delay": "*number*",
    "delivery_paused": "*boolean*",
    "message_retention_period": "*number*"
  }
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Get Queue Purge Status

GET /accounts/{account_id}/queues/{queue_id}/purge

Get details about a Queue's purge status.

Responses

200 Details of the requested Queue

Data is at body["result"]

{
  "completed": "*string*",
  "started_at": "*string*"
}
4XX Failure response
{
  "errors": [
    {
      "code": "*integer*",
      "message": "*string*"
    }
  ],
  "messages": [
    "*string*"
  ],
  "success": "*boolean*"
}

Summary

Functions

client(opts \\ [])

consumers(id, opts \\ [])

Lists consumers for a Queue.

create(body, opts \\ [])

@spec create(
  body :: Restlax.Resource.action_body(),
  opts :: Restlax.Resource.action_options()
) ::
  {:ok, map()} | {:error, term()}

create!(body, opts \\ [])

@spec create!(
  body :: Restlax.Resource.action_body(),
  opts :: Restlax.Resource.action_options()
) ::
  map() | no_return()

create_consumer(id, body, opts \\ [])

Creates a new consumer for a Queue.

delete(id, opts \\ [])

@spec delete(id :: term(), opts :: Restlax.Resource.action_options()) ::
  {:ok, map()} | {:error, term()}

delete!(id, opts \\ [])

@spec delete!(id :: term(), opts :: Restlax.Resource.action_options()) ::
  map() | no_return()

index(opts \\ [])

@spec index(opts :: Restlax.Resource.action_options()) ::
  {:ok, map()} | {:error, term()}

index!(opts \\ [])

@spec index!(opts :: Restlax.Resource.action_options()) :: map() | no_return()

path_for(id, opts \\ [])

@spec path_for(term(), [{:action, String.t()}]) :: String.t()

push_message(id, body, opts \\ [])

Pushes a message to a Queue.

show(id, opts \\ [])

@spec show(id :: term(), opts :: Restlax.Resource.action_options()) ::
  {:ok, map()} | {:error, term()}

show!(id, opts \\ [])

@spec show!(id :: term(), opts :: Restlax.Resource.action_options()) ::
  map() | no_return()

update(id, body, opts \\ [])

@spec update(
  id :: term(),
  body :: Restlax.Resource.action_body(),
  opts :: Restlax.Resource.action_options()
) :: {:ok, map()} | {:error, term()}

update!(id, body, opts \\ [])

@spec update!(
  id :: term(),
  body :: Restlax.Resource.action_body(),
  opts :: Restlax.Resource.action_options()
) :: map() | no_return()