All Products
Search
Document Center

Serverless App Engine:CreateConfigMap

Last Updated:Dec 25, 2023

Creates a ConfigMap instance in a namespace. ConfigMap is a type of resource that is used to store the configurations that are required for applications. ConfigMap helps decouple configurations from the process of running images and improves the portability of applications.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

This operation uses only common request headers. For more information, see Common request and response headers.

Request syntax

POST /pop/v1/sam/configmap/configMap HTTP/1.1

Request parameters

Parameter

Type

Location

Required

Example

Description

Name

String

Query

Yes

name

The name of the ConfigMap instance. The name can contain digits, letters, and underscores (_). The name can start with only a letter.

NamespaceId

String

Query

Yes

cn-hangzhou

The ID of the namespace to which the ConfigMap instance belongs.

Object

Body

No

The ConfigMap data.

Data

String

Body

Yes

{"env.shell": "/bin/sh"}

The data of ConfigMap key-value pairs. JSON format:

{"Data":"{\"k1\":\"v1\", \"k2\":\"v2\"}"}

k specifies a key and v specifies a value. For more information, see Manage and use configurations.

Description

String

Query

No

test-desc

The description. The description must be 1 to 255 characters in length, and cannot contain spaces.

Response parameters

Parameter

Type

Example

Description

RequestId

String

91F93257-7A4A-4BD3-9A7E-2F6EAE6D****

The ID of the request.

Message

String

success

The returned information.

TraceId

String

0a98a02315955564772843261e****

The ID of the trace. The ID is used to query the details of a request.

Data

Object

The returned result.

ConfigMapId

Long

1

The ID of the ConfigMap instance that was created.

ErrorCode

String

Empty

The returned error code. Valid values:

  • If the call is successful, the ErrorCode parameter is not returned.

  • If the call fails, the ErrorCode parameter is returned. For more information, see the "Error codes" section of this topic.

Code

String

200

The HTTP status code. Valid values:

  • 2xx: indicates that the call was successful.

  • 3xx: indicates that the call was redirected.

  • 4xx: indicates that the call failed.

  • 5xx: indicates that a server error occurred.

Success

Boolean

true

Indicates whether the ConfigMap instance was created. Valid values:

  • true: The instance was created.

  • false: The call failed to be created.

Examples

Sample requests

POST /pop/v1/sam/configmap/configMap?Name=name&NamespaceId=cn-hangzhou&Description=test-desc HTTP/1.1
Host:sae.aliyuncs.com
Content-Type:application/json

{
  "Data" : "{\"env.shell\": \"/bin/sh\"}"
}

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateConfigMapResponse>
    <RequestId>91F93257-7A4A-4BD3-9A7E-2F6EAE6D****</RequestId>
    <Message>success</Message>
    <TraceId>0a98a02315955564772843261e****</TraceId>
    <Data>
        <ConfigMapId>1</ConfigMapId>
    </Data>
    <Code>200</Code>
    <Success>true</Success>
</CreateConfigMapResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "91F93257-7A4A-4BD3-9A7E-2F6EAE6D****",
  "Message" : "success",
  "TraceId" : "0a98a02315955564772843261e****",
  "Data" : {
    "ConfigMapId" : 1
  },
  "Code" : "200",
  "Success" : true
}

Error codes

HttpCode

Error code

Error message

Description

400

InvalidParameter.NotEmpty

You must specify the parameter %s.

The error message returned because the value of the %s parameter is invalid. This parameter cannot be left empty.

400

InvalidParameter.Obviously

The specified parameter is invalid {%s}.

The error message returned because the value of the {%s} parameter is invalid.

400

InvalidParameter.WithMessage

The parameter is invalid {%s}: %s

The error message returned because the value of the %s parameter is invalid: %s.

400

Exceed.ConfigMap

Too many ConfigMap objects have been created in the namespace.

The error message returned because the number of ConfigMap objects that are created in the namespace exceeds the limit.

400

TooMany.Configmap

The maximum number of keys or the maximum length of Configmap is exceeded.

The error message returned because the number of keys in the ConfigMap object or the length of the object body exceeds the limit.

500

OperationFailed.RPCError

Internal RPC request processing error.

The error message returned because the system failed to process an internal RPC request.

For a list of error codes, visit the API Error Center.