Help Center/ ModelArts/ API Reference/ Resource Management/ Creating Network Resources
Updated on 2024-06-13 GMT+08:00

Creating Network Resources

Function

This API is used to create network resources.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

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

NetworkSpec object

Description of network resources.

Table 3 NetworkMetadataCreation

Parameter

Mandatory

Type

Description

labels

Yes

NetworkMetadataLabels object

Indicates the label information of a network resource.

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, indicating the default workspace.

Table 5 NetworkSpec

Parameter

Mandatory

Type

Description

cidr

Yes

String

Network CIDR. Value range:

  • 172.16.0.0/12-172.16.0.0/24

  • 192.168.0.0/16-192.168.0.0/24

connection

No

NetworkConnection object

Information about the connection between the current network and other cloud services.

Table 6 NetworkConnection

Parameter

Mandatory

Type

Description

peerConnectionList

No

Array of peerConnectionList objects

List of networks that can be connected in peer mode.

Table 7 peerConnectionList

Parameter

Mandatory

Type

Description

peerVpcId

Yes

String

Indicates the ID of the peer VPC.

peerSubnetId

Yes

String

ID of the peer subnet.

defaultGateWay

Yes

Boolean

Whether the default gateway is enabled.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

apiVersion

String

API version. Options:

  • v1

kind

String

Resource type. Options:

  • Network

metadata

NeworkMetadata object

Metadata of network resources.

spec

NetworkSpec object

Description of network resources.

status

NetworkStatus object

Status of network resources.

Table 9 NeworkMetadata

Parameter

Type

Description

name

String

Network name automatically generated by the system, which is equivalent to networkId. networkId indicates the unique ID generated by ModelArts based on the network name entered by the user.

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 10 NetworkMetadataLabels

Parameter

Type

Description

os.modelarts/name

String

Specified network name.

os.modelarts/workspace.id

String

Workspace ID The default value is 0, indicating the default workspace.

Table 11 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 12 NetworkSpec

Parameter

Type

Description

cidr

String

Network CIDR. Value range:

  • 172.16.0.0/12-172.16.0.0/24

  • 192.168.0.0/16-192.168.0.0/24

connection

NetworkConnection object

Information about the connection between the current network and other cloud services.

Table 13 NetworkConnection

Parameter

Type

Description

peerConnectionList

Array of peerConnectionList objects

List of networks that can be connected in peer mode.

Table 14 peerConnectionList

Parameter

Type

Description

peerVpcId

String

Indicates the ID of the peer VPC.

peerSubnetId

String

ID of the peer subnet.

defaultGateWay

Boolean

Whether the default gateway is enabled.

Table 15 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

Indicates the connection status between the network and other cloud services.

Table 16 NetworkConnectionStatus

Parameter

Type

Description

peerConnectionStatus

Array of peerConnectionStatus objects

Indicates the status information list of the network in peer mode.

sfsTurboStatus

Array of sfsTurboStatus objects

Specifies the list of SFS Turbos that can be connected to the network.

Table 17 peerConnectionStatus

Parameter

Type

Description

peerVpcId

String

Indicates the ID of the peer VPC.

peerSubnetId

String

ID of the peer subnet.

defaultGateWay

Boolean

Whether the default gateway is enabled.

phase

String

Connection status of the network. The options are as follows:

  • Connecting: The network is being connected.

  • Active: The network connection is normal.

  • Abnormal: The network connection is abnormal.

Table 18 sfsTurboStatus

Parameter

Type

Description

sfsId

String

Specifies the SFS Turbo ID.

name

String

Specifies the name of the SFS Turbo.

status

String

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

  • Active: The SFS connection status is normal.

  • Abnormal: The SFS connection status is abnormal.

ipAddr

String

Specifies the address for accessing SFS Turbo.

Status code: 400

Table 19 Response body parameters

Parameter

Type

Description

error_code

String

Error codes of ModelArts.

error_msg

String

Error message.

Example Requests

The following is an example of how to create a network whose resource type is Network, network name is network-7a03, and CIDR block is 192.168.128.0/17.

POST {endpoint}/v2/{project_id}/pools

{
  "apiVersion" : "v1",
  "kind" : "Network",
  "metadata" : {
    "labels" : {
      "os.modelarts/name" : "network-7a03",
      "os.modelarts/workspace.id" : "0"
    }
  },
  "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",
      "os.modelarts/workspace.id" : "0"
    },
    "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.