Vcenter NamespaceManagement InfrastructurePolicies create

Vcenter NamespaceManagement InfrastructurePolicies create

Create a new policy.

This operation was added in vSphere API 9.1.0.0.

Returns an authorization error if you do not have all of the privileges described as follows:

  • Operation execution requires Namespaces.Policies.Manage.
Request
URI
POST
https://{host}/api/vcenter/namespace-management/infrastructure-policies
COPY
Request Body

Specification for the new policy.

Show optional properties

{
    "policy": "string"
}
{
    "policy": "string",
    "description": "string",
    "compute_policy_id": "string",
    "enforcement_mode": "string",
    "match": {
        "op": "string",
        "match": [
            {
                "op": "string",
                "match": [
                    "Vcenter NamespaceManagement InfrastructurePolicies MatchSpec Object"
                ],
                "workload": {
                    "guest": {
                        "guest_id": {
                            "op": "string",
                            "value": "string"
                        },
                        "guest_family": {
                            "op": "string",
                            "value": "string"
                        }
                    },
                    "labels": [
                        {
                            "key": "string",
                            "operator": "string",
                            "values": [
                                "string"
                            ]
                        }
                    ],
                    "kind": "string"
                }
            }
        ],
        "workload": {
            "guest": {
                "guest_id": {
                    "op": "string",
                    "value": "string"
                },
                "guest_family": {
                    "op": "string",
                    "value": "string"
                }
            },
            "labels": [
                {
                    "key": "string",
                    "operator": "string",
                    "values": [
                        "string"
                    ]
                }
            ],
            "kind": "string"
        }
    }
}
string
policy
Required

Identifier of the policy. This has DNS label restrictions as specified in . This must be an alphanumeric (a-z and 0-9) string and with maximum length of 63 characters and with the '-' character allowed anywhere except the first or last character. This name is unique in this vCenter server and cannot be changed after creation.

This property was added in vSphere API 9.1.0.0.

When clients pass a value of this schema as a parameter, the property must be an identifier for the resource type: com.vmware.vcenter.namespace_management.INFRASTRUCTURE_POLICY. When operations return a value of this schema as a response, the property will be an identifier for the resource type: com.vmware.vcenter.namespace_management.INFRASTRUCTURE_POLICY.

string
description
Optional

Specifies the desired description of the policy.

This property was added in vSphere API 9.1.0.0.

If missing or null, no description is provided.

string
compute_policy_id
Optional

Specifies the UUID of the underlying vSphere com.vmware.vcenter.compute.Policy, if one is associated with this object.

This property was added in vSphere API 9.1.0.0.

If missing or null, no policy ID is specified.

When clients pass a value of this schema as a parameter, the property must be an identifier for the resource type: com.vmware.vcenter.compute.Policy. When operations return a value of this schema as a response, the property will be an identifier for the resource type: com.vmware.vcenter.compute.Policy.

string
enforcement_mode
Optional

Specifies how the policy is enforced.

For more information see: Vcenter NamespaceManagement InfrastructurePolicies EnforcementMode.

This property was added in vSphere API 9.1.0.0.

If missing or null, defaults to Vcenter NamespaceManagement InfrastructurePolicies EnforcementMode.MANDATORY.

match
Optional

Used to match workloads to which this policy should be applied.

This property was added in vSphere API 9.1.0.0.

If missing or null, policy applies to all workloads.

Authentication
This operation uses the following authentication methods.
Responses
201

Success!

Operation doesn't return any data structure

400

Vapi Std Errors AlreadyExists if a policy with the same identifier already exists.

Vapi Std Errors InvalidArgument if the specification contains invalid values.

Returns Vapi Std Errors Error of type(s) application/json
{
    "messages": [
        {
            "id": "string",
            "default_message": "string",
            "args": [
                "string"
            ],
            "params": {
                "params": {
                    "s": "string",
                    "dt": "string",
                    "i": 0,
                    "d": "number",
                    "l": {
                        "id": "string",
                        "params": {
                            "params": "Vapi Std LocalizationParam Object"
                        }
                    },
                    "format": "string",
                    "precision": 0
                }
            },
            "localized": "string"
        }
    ],
    "data": {},
    "error_type": "string"
}
array of object
messages
Required

Stack of one or more localizable messages for human error consumers.

The message at the top of the stack (first in the list) describes the error from the perspective of the operation the client invoked.

Each subsequent message in the stack describes the "cause" of the prior message.

object
data
Optional

Data to facilitate clients responding to the operation reporting a standard error to indicating that it was unable to complete successfully.

Operations may provide data that clients can use when responding to errors. Since the data that clients need may be specific to the context of the operation reporting the error, different operations that report the same error may provide different data in the error. The documentation for each each operation will describe what, if any, data it provides for each error it reports.

The Vapi Std Errors ArgumentLocations, Vapi Std Errors FileLocations, and Vapi Std Errors TransientIndication schemas are intended as possible values for this property. Vapi Std DynamicID may also be useful as a value for this property (although that is not its primary purpose). Some resources may provide their own specific schemas for use as the value of this property when reporting errors from their operations.

Some operations will not set this property when reporting errors.

string
error_type
Required

Discriminator field to help API consumers identify the structure type.

For more information see: Vapi Std Errors Error Type.

This property was added in vSphere API 6.7.2.

Can be missing or null for compatibility with preceding implementations.


401

if the user cannot be authenticated.

Returns Vapi Std Errors Unauthenticated of type(s) application/json
This response body class contains all of the following: Vapi Std Errors Error
{
    "messages": [
        {
            "id": "string",
            "default_message": "string",
            "args": [
                "string"
            ],
            "params": {
                "params": {
                    "s": "string",
                    "dt": "string",
                    "i": 0,
                    "d": "number",
                    "l": "Vapi Std NestedLocalizableMessage Object",
                    "format": "string",
                    "precision": 0
                }
            },
            "localized": "string"
        }
    ],
    "data": {},
    "error_type": "string",
    "challenge": "string"
}
string
challenge
Optional

Indicates the authentication challenges applicable to the target API provider. It can be used by a client to discover the correct authentication scheme to use. The exact syntax of the value is defined by the specific provider, the protocol and authentication schemes used.

For example, a provider using REST may adhere to the WWW-Authenticate HTTP header specification, RFC7235, section 4.1. In this case an example challenge value may be: SIGN realm="27da1358-2ba4-11e9-b210-d663bd873d93",sts="http://vcenter/sso?vsphere.local", Basic realm="vCenter"

This property was added in vSphere API 7.0.0.0.

This property is optional because it was added in a newer version than its parent node.


403

if the user does not have Namespaces.Policies.Manage privilege.

Returns Vapi Std Errors Unauthorized of type(s) application/json
This response body class contains all of the following: Vapi Std Errors Error
{
    "messages": [
        {
            "id": "string",
            "default_message": "string",
            "args": [
                "string"
            ],
            "params": {
                "params": {
                    "s": "string",
                    "dt": "string",
                    "i": 0,
                    "d": "number",
                    "l": "Vapi Std NestedLocalizableMessage Object",
                    "format": "string",
                    "precision": 0
                }
            },
            "localized": "string"
        }
    ],
    "data": {},
    "error_type": "string",
    "challenge": "string"
}
string
challenge
Optional

Indicates the authentication challenges applicable to the target API provider. It can be used by a client to discover the correct authentication scheme to use. The exact syntax of the value is defined by the specific provider, the protocol and authentication schemes used.

For example, a provider using REST may adhere to the WWW-Authenticate HTTP header specification, RFC7235, section 4.1. In this case an example challenge value may be: SIGN realm="27da158-2ba4-11e9-b",sts="http://vcenter/sso?vsphere.local", Basic realm="vCenter"

This property was added in vSphere API 9.1.0.0.

This property is optional because it was added in a newer version than its parent node.


500

if the system reports an error while responding to the request.

Returns Vapi Std Errors Error of type(s) application/json
{
    "messages": [
        {
            "id": "string",
            "default_message": "string",
            "args": [
                "string"
            ],
            "params": {
                "params": {
                    "s": "string",
                    "dt": "string",
                    "i": 0,
                    "d": "number",
                    "l": "Vapi Std NestedLocalizableMessage Object",
                    "format": "string",
                    "precision": 0
                }
            },
            "localized": "string"
        }
    ],
    "data": {},
    "error_type": "string"
}
array of object
messages
Required

Stack of one or more localizable messages for human error consumers.

The message at the top of the stack (first in the list) describes the error from the perspective of the operation the client invoked.

Each subsequent message in the stack describes the "cause" of the prior message.

object
data
Optional

Data to facilitate clients responding to the operation reporting a standard error to indicating that it was unable to complete successfully.

Operations may provide data that clients can use when responding to errors. Since the data that clients need may be specific to the context of the operation reporting the error, different operations that report the same error may provide different data in the error. The documentation for each each operation will describe what, if any, data it provides for each error it reports.

The Vapi Std Errors ArgumentLocations, Vapi Std Errors FileLocations, and Vapi Std Errors TransientIndication schemas are intended as possible values for this property. Vapi Std DynamicID may also be useful as a value for this property (although that is not its primary purpose). Some resources may provide their own specific schemas for use as the value of this property when reporting errors from their operations.

Some operations will not set this property when reporting errors.

string
error_type
Required

Discriminator field to help API consumers identify the structure type.

For more information see: Vapi Std Errors Error Type.

This property was added in vSphere API 6.7.2.

Can be missing or null for compatibility with preceding implementations.


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"policy":"string"}' https://{api_host}/api/vcenter/namespace-management/infrastructure-policies