Creating Network Resources

Function

This API is used to create network resources.

URI

POST /v1/{project_id}/networks

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

apiVersion

Yes

String

API version. Options:

  • v1

kind

Yes

String

Resource type. Options:

  • Network

metadata

Yes

NetworkMetadataCreation object

Metadata of network resources.

spec

Yes

NetworkSpecCreation object

Description of network resources.

Table 3 NetworkMetadataCreation

Parameter

Mandatory

Type

Description

labels

Yes

NetworkMetadataLabels object

Metadata labels of network resources.

Table 4 NetworkMetadataLabels

Parameter

Mandatory

Type

Description

os.modelarts/name

Yes

String

Specified network name.

os.modelarts/workspace.id

No

String

Workspace ID. The default value is 0.

Table 5 NetworkSpecCreation

Parameter

Mandatory

Type

Description

ipv6enable

No

Boolean

Whether to enable IPv6. Once IPv6 is enabled, it cannot be disabled.

cidr

Yes

String

Network CIDR. Values:

  • 172.16.0.0/12-172.16.0.0/24

  • 192.168.0.0/16-192.168.0.0/24

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

apiVersion

String

API version. Options:

  • v1

kind

String

Resource type. Options:

  • Network

metadata

NetworkMetadata object

Metadata of network resources.

spec

NetworkSpec object

Description of network resources.

status

NetworkStatus object

Status of network resources.

Table 7 NetworkMetadata

Parameter

Type

Description

name

String

Automatically generated network name, which is equivalent to networkId.

creationTimestamp

String

Timestamp, for example, 2021-11-01T03:49:41Z.

labels

NetworkMetadataLabels object

Labels of network resources.

annotations

NetworkMetadataAnnotations object

Annotations of network resources.

Table 8 NetworkMetadataLabels

Parameter

Type

Description

os.modelarts/name

String

Specified network name.

os.modelarts/workspace.id

String

Workspace ID. The default value is 0.

Table 9 NetworkMetadataAnnotations

Parameter

Type

Description

os.modelarts/description

String

Network resource description, which is used to describe a scenario. The following special characters are not allowed: !<>=&"'

Table 10 NetworkSpec

Parameter

Type

Description

ipv6enable

Boolean

Whether to enable IPv6. Once IPv6 is enabled, it cannot be disabled.

cidr

String

Network CIDR.

connection

NetworkConnection object

Automatically interconnected endpoint.

Table 11 NetworkConnection

Parameter

Type

Description

peerConnectionList

Array of PeerConnectionItem objects

Peering connections

sfsTurboConnectionList

Array of SfsTurboConnectionItem objects

SFS Turbo connections through attached NICs

Table 12 PeerConnectionItem

Parameter

Type

Description

peerVpcId

String

VPC ID of the peer end.

peerSubnetId

String

Subnet ID of the peer end.

defaultGateWay

Boolean

Whether to create a default route. The default value is false.

Table 13 SfsTurboConnectionItem

Parameter

Type

Description

name

String

Name of an SFS Turbo instance.

sfsId

String

ID of an SFS Turbo instance.

Table 14 NetworkStatus

Parameter

Type

Description

phase

String

Current network status. Options:

  • Creating: The network is being created.

  • Active: The network is functional.

  • Abnormal: The network malfunctions.

connectionStatus

NetworkConnectionStatus object

Network connection status.

Table 15 NetworkConnectionStatus

Parameter

Type

Description

peerConnectionStatus

Array of PeerConnectionStatus objects

Peering connection status

sfsTurboStatus

Array of SfsTurboConnectionStatus objects

Status of SFS Turbo accessible to the network

Table 16 PeerConnectionStatus

Parameter

Type

Description

peerVpcId

String

VPC ID of the peer end.

peerSubnetId

String

Subnet ID of the peer end.

defaultGateWay

Boolean

Whether to create a default route. The default value is false.

phase

String

Network connection status. The options are as follows:

  • Connecting: The network is being connected.

  • Active: The network is connected properly.

  • Abnormal: The network connection is abnormal.

Table 17 SfsTurboConnectionStatus

Parameter

Type

Description

name

String

Name of an SFS Turbo instance.

sfsId

String

ID of an SFS Turbo instance.

connectionType

String

Connection type. The options are as follows:

  • VpcPort: passthrough through attached NICs

  • Peering: connection through VPC peering

ipAddr

String

SFS Turbo access address.

status

String

Status of the connection to SFS Turbo. The options are as follows:

  • Active: The SFS connection is normal.

  • Abnormal: The SFS connection is abnormal.

  • Creating: The SFS connection is being set up.

  • Deleting: The SFS connection is being deleted.

Status code: 400

Table 18 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Create a network.

POST {endpoint}/v1/{project_id}/networks

{
  "apiVersion" : "v1",
  "kind" : "Network",
  "metadata" : {
    "labels" : {
      "os.modelarts/name" : "network-7a03"
    }
  },
  "spec" : {
    "cidr" : "192.168.128.0/17"
  }
}

Example Responses

Status code: 200

OK

{
  "kind" : "Network",
  "apiVersion" : "v1",
  "metadata" : {
    "name" : "network-7a03-86c13962597848eeb29c5861153a391f",
    "creationTimestamp" : "2022-09-16T09:44:59Z",
    "labels" : {
      "os.modelarts/name" : "network-7a03"
    },
    "annotations" : { }
  },
  "spec" : {
    "cidr" : "192.168.128.0/17",
    "connection" : { }
  },
  "status" : {
    "phase" : ""
  }
}

Status code: 400

Bad request.

{
  "error_code" : "ModelArts.50004000",
  "error_msg" : "Bad request."
}

Status Codes

Status Code

Description

200

OK

400

Bad request.

Error Codes

See Error Codes.