| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 | --:api: put-job:request: PutJobRequest:response: PutJobResponse--[id="{upid}-{api}"]=== Put Job APIThe Put Job API can be used to create a new {ml} jobin the cluster. The API accepts a +{request}+ objectas a request and returns a +{response}+.[id="{upid}-{api}-request"]==== Put Job RequestA +{request}+ requires the following argument:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-request]--------------------------------------------------<1> The configuration of the {ml} job to create as a `Job`[id="{upid}-{api}-config"]==== Job ConfigurationThe `Job` object contains all the details about the {ml} jobconfiguration.A `Job` requires the following arguments:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-config]--------------------------------------------------<1> The job ID<2> An analysis configuration<3> A data description<4> Optionally, a human-readable description[id="{upid}-{api}-analysis-config"]==== Analysis ConfigurationThe analysis configuration of the {ml} job is defined in the `AnalysisConfig`.`AnalysisConfig` reflects all the configurationsettings that can be defined using the REST API.Using the REST API, we could define this analysis configuration:[source,js]--------------------------------------------------"analysis_config" : {  "bucket_span" : "10m",  "detectors" : [    {      "detector_description" : "Sum of total",      "function" : "sum",      "field_name" : "total"    }  ]}--------------------------------------------------// NOTCONSOLEUsing the `AnalysisConfig` object and the high level REST client, the listof detectors must be built first.An example of building a `Detector` instance is as follows:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-detector]--------------------------------------------------<1> The function to use<2> The field to apply the function to<3> Optionally, a human-readable descriptionThen the same configuration would be:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-analysis-config]--------------------------------------------------<1> Create a list of detectors<2> Pass the list of detectors to the analysis config builder constructor<3> The bucket span[id="{upid}-{api}-data-description"]==== Data DescriptionAfter defining the analysis config, the next thing to define is thedata description, using a `DataDescription` instance. `DataDescription`reflects all the configuration settings that can be defined using theREST API.Using the REST API, we could define this metrics configuration:[source,js]--------------------------------------------------"data_description" : {  "time_field" : "timestamp"}--------------------------------------------------// NOTCONSOLEUsing the `DataDescription` object and the high level REST client, the sameconfiguration would be:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-data-description]--------------------------------------------------<1> The time fieldinclude::../execution.asciidoc[][id="{upid}-{api}-response"]==== ResponseThe returned +{response}+ returns the full representation ofthe new {ml} job if it has been successfully created. This willcontain the creation time and other fields initialized usingdefault values:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[{api}-response]--------------------------------------------------<1> The creation time is a field that was not passed in the `Job` object in the request
 |