Skip to contents

The arc_gp_job class is used to interact with Geoprocessing Services in ArcGIS Online and Enterprise.

Usage

new_gp_job(base_url, params = list(), token = arc_token())

Arguments

base_url

the URL of the job service (without /submitJob)

params

a named list where each element is a scalar character

token

default arc_token(). The token to be used with the job.

Value

An object of class arc_gp_job.

Details

The arc_gp_job uses S7 classes for the job request parameters and job status via arc_form_params() and arc_job_status() respectively. Importantly, arc_form_params() ensures that parameters provided to a geoprocessing service are all character scalars as required by the form body.

See also

Other geoprocessing: arc_form_params(), arc_job_status(), gp_params

Public fields

base_url

the URL of the job service (without /submitJob)

id

the ID of the started job. NULL self$start() has not been called.

Active bindings

params

returns an S7 object of class arc_form_params (see arc_form_params()) the list can be accessed via self$params@params.

status

returns the status of the geoprocessing job as an S7 object of class gp_job_status (see arc_job_status()) by querying the /jobs/{job-id} endpoint.

results

returns the current results of the job by querying the /jobs/{job-id}/results endpoint.

Methods


Method new()

Usage

arc_gp_job$new(
  base_url,
  params = list(),
  result_fn = NULL,
  token = arc_token(),
  error_call = rlang::caller_call()
)

Arguments

base_url

the URL of the job service (without /submitJob)

params

a named list where each element is a scalar character

result_fn

Default NULL. An optional function to apply to the results JSON. By default parses results using RcppSimdJson::fparse().

token

default arc_token(). The token to be used with the job.

error_call

default rlang::caller_call() the calling environment.


Method start()

Starts the job by calling the /submitJob endpoint. This also sets the public field id.

Usage

arc_gp_job$start()


Method cancel()

Cancels a job by calling the /cancel endpoint.

Usage

arc_gp_job$cancel()


Method clone()

The objects of this class are cloneable with this method.

Usage

arc_gp_job$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

url <- paste0(
  "https://logistics.arcgis.com/arcgis/",
  "rest/services/World/ServiceAreas/",
  "GPServer/GenerateServiceAreas"
)
job <- new_gp_job(url, list(f = "json"))
job
#> <arc_gp_job>
#> Job ID: not initiated
#> Status: not started
#> Resource: /GenerateServiceAreas
#> Params:
#> • f

# extract params S7 class
params <- job$params
params
#> <arcgisutils::arc_form_params>
#>  @ params:List of 1
#>  .. $ f: chr "json"

# view underlying list
params@params
#> $f
#> [1] "json"
#>