• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. CronJob
  6. Replacing the Status of a Specified CronJob

Replacing the Status of a Specified CronJob

Function

This API is used to replace the status of a specified CronJob resource object.

URI

PUT /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}/status

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

name

Yes

name of the Job

namespace

Yes

object name and auth scope, such as for teams and projects

Request

Request parameters:

For the description about request parameters, see Table 2.

Example request:

{
    "apiVersion": "batch/v1beta1",
    "kind": "CronJob",
    "metadata": {
        "creationTimestamp": "2018-03-07T12:17:22Z",
        "enable": true,
        "name": "cronjob-test",
        "namespace": "default",
        "resourceVersion": "442543",
        "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test",
        "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c"
    },
    "spec": {
        "concurrencyPolicy": "Forbid",
        "failedJobsHistoryLimit": 1,
        "jobTemplate": {
            "metadata": {
                "creationTimestamp": null,
                "enable": true
            },
            "spec": {
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "enable": true,
                        "labels": {
                            "sjname": "cronjob-test"
                        }
                    },
                    "spec": {
                        "containers": [
                            {
                                "image": "nginx:stable-perl",
                                "imagePullPolicy": "IfNotPresent",
                                "lifecycle": {},
                                "name": "container-0",
                                "resources": {},
                                "terminationMessagePath": "/dev/termination-log",
                                "terminationMessagePolicy": "File"
                            }
                        ],
                        "dnsPolicy": "ClusterFirst",
                        "imagePullSecrets": [
                            {
                                "name": "default-secret"
                            }
                        ],
                        "restartPolicy": "OnFailure",
                        "schedulerName": "default-scheduler",
                        "securityContext": {},
                        "terminationGracePeriodSeconds": 30
                    }
                }
            }
        },
        "schedule": "*/2 * * * *",
        "successfulJobsHistoryLimit": 3,
        "suspend": false
    },
    "status": {
        "active": [
            {
                "apiVersion": "batch",
                "kind": "Job",
                "name": "cronjob-test-1520425800",
                "namespace": "default",
                "resourceVersion": "442542",
                "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c"
            }
        ],
        "lastScheduleTime": "2018-03-07T12:30:00Z"
    }
}

Response

Response parameters:

For the description about response parameters, see the parameter description in Table 2.

Example response:

{
    "apiVersion": "batch/v1beta1",
    "kind": "CronJob",
    "metadata": {
        "creationTimestamp": "2018-03-07T12:17:22Z",
        "enable": true,
        "name": "cronjob-test",
        "namespace": "default",
        "resourceVersion": "442543",
        "selfLink": "/apis/batch/v1beta1/namespaces/default/cronjobs/cronjob-test",
        "uid": "7cf2c54b-2201-11e8-96aa-fa163ecd089c"
    },
    "spec": {
        "concurrencyPolicy": "Forbid",
        "failedJobsHistoryLimit": 1,
        "jobTemplate": {
            "metadata": {
                "creationTimestamp": null,
                "enable": true
            },
            "spec": {
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "enable": true,
                        "labels": {
                            "sjname": "cronjob-test"
                        }
                    },
                    "spec": {
                        "containers": [
                            {
                                "image": "nginx:stable-perl",
                                "imagePullPolicy": "IfNotPresent",
                                "lifecycle": {},
                                "name": "container-0",
                                "resources": {},
                                "terminationMessagePath": "/dev/termination-log",
                                "terminationMessagePolicy": "File"
                            }
                        ],
                        "dnsPolicy": "ClusterFirst",
                        "imagePullSecrets": [
                            {
                                "name": "default-secret"
                            }
                        ],
                        "restartPolicy": "OnFailure",
                        "schedulerName": "default-scheduler",
                        "securityContext": {},
                        "terminationGracePeriodSeconds": 30
                    }
                }
            }
        },
        "schedule": "*/2 * * * *",
        "successfulJobsHistoryLimit": 3,
        "suspend": false
    },
    "status": {
        "active": [
            {
                "apiVersion": "batch",
                "kind": "Job",
                "name": "cronjob-test-1520425800",
                "namespace": "default",
                "resourceVersion": "442542",
                "uid": "75aede3f-2203-11e8-96aa-fa163ecd089c"
            }
        ],
        "lastScheduleTime": "2018-03-07T12:30:00Z"
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

This operation succeeds, and a Job resource object is returned.

For the description about status codes, see Status Codes.