do_cosmos_op {AzureCosmosR}R Documentation

Carry out a Cosmos DB operation

Description

Carry out a Cosmos DB operation

Usage

do_cosmos_op(object, ...)

## S3 method for class 'cosmos_endpoint'
do_cosmos_op(object, ...)

## S3 method for class 'cosmos_database'
do_cosmos_op(object, path = "", resource_type = "dbs", resource_link = "", ...)

## S3 method for class 'cosmos_container'
do_cosmos_op(
  object,
  path = "",
  resource_type = "colls",
  resource_link = "",
  ...
)

## S3 method for class 'cosmos_document'
do_cosmos_op(
  object,
  path = "",
  resource_type = "docs",
  resource_link = "",
  headers = list(),
  ...
)

Arguments

object

A Cosmos DB endpoint, database, container or document object.

...

Arguments passed to lower-level functions.

path

The (partial) URL path for the operation.

resource_type

The type of resource. For most purposes, the default value should suffice.

resource_link

The resource link for authorization. For most purposes, the default value should suffice.

headers

Any optional HTTP headers to include in the API call.

Details

do_cosmos_op provides a higher-level interface to the Cosmos DB REST API than call_cosmos_endpoint. In particular, it sets the resource_type and resource_link arguments to sensible defaults, and fills in the beginning of the URL path for the REST call.

Value

The result of call_cosmos_endpoint: either a httr response object, or a list of such objects. Call process_cosmos_response to extract the result of the call.

Examples

## Not run: 

endp <- cosmos_endpoint("https://myaccount.documents.azure.com:443/", key="mykey")

db <- get_cosmos_database(endp, "mydatabase")
do_cosmos_op(db) %>%
    process_cosmos_response()

cont <- get_cosmos_container(db, "mycontainer")
do_cosmos_op(cont) %>%
    process_cosmos_response()


## End(Not run)

[Package AzureCosmosR version 1.0.0 Index]