Help Center/ Elastic IP/ API Reference/ APIs/ EIP/ Assigning an EIP (Pay-per-Use)
Updated on 2024-04-17 GMT+08:00

Assigning an EIP (Pay-per-Use)

Function

This API is used to assign an EIP.

The EIP service provides independent public IP addresses and bandwidth for Internet access. EIPs can be bound to or unbound from ECSs, BMSs, virtual IP addresses, NAT gateways, or load balancers. Various billing modes are provided to meet diversified service requirements.

URI

POST /v1/{project_id}/publicips

Table 1 describes the parameters.
Table 1 Parameter description

Name

Mandatory

Description

project_id

Yes

Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request body parameter

Name

Mandatory

Type

Description

publicip

Yes

publicip object

Specifies the EIP object. For details, see Table 3.

bandwidth

Yes

bandwidth object

Specifies the bandwidth object. For details, see Table 4.

enterprise_project_id

No

String

  • Specifies the enterprise project ID. The value is 0 or a string that contains a maximum of 36 characters in UUID format with hyphens (-).
  • When you assign an EIP, associate an enterprise project ID with the EIP.
  • If this parameter is not specified, the default value is 0, which indicates that the default enterprise project is used.
NOTE:

For more information about enterprise projects and how to obtain enterprise project IDs, see the Enterprise Management User Guide.

Table 3 Description of the publicip field

Name

Mandatory

Type

Description

type

Yes

String

  • Specifies the EIP type.
  • The value can be 5_bgp (dynamic BGP) or 5_sbgp (static BGP).
    • CN South-Guangzhou: 5_bgp and 5_sbgp
    • CN East-Shanghai1: 5_bgp and 5_sbgp
    • CN East-Shanghai2: 5_bgp and 5_sbgp
    • CN North-Beijing1: 5_bgp and 5_sbgp
    • CN-Hong Kong: 5_bgp
    • AP-Bangkok: 5_bgp
    • AP-Singapore: 5_bgp
    • AF-Johannesburg: 5_bgp
    • CN Southwest-Guiyang1: 5_sbgp
    • CN North-Beijing4: 5_bgp and 5_sbgp
    • LA-Santiago: 5_bgp
    • LA-Sao Paulo1: 5_bgp
    • LA-Mexico City1: 5_bgp
    • LA-Buenos Aires1: 5_bgp
    • LA-Lima1: 5_bgp
    • LA-Santiago2: 5_bgp
  • Constraints:
    • The configured value must be supported by the system.
    • publicip_id is an IPv4 port. If publicip_type is not specified, the default value is 5_bgp.

ip_version

No

Integer

  • Specifies the EIP version.
  • The value can be 4 and 6, indicating IPv4 address and IPv6 address, respectively.
  • Constraints:
    • The configured value must be supported by the system.
    • If this parameter is left blank or is an empty string, IPv4 address is created by default.

ip_address

No

String

  • Specifies the EIP to be assigned. The system automatically assigns an EIP if you do not specify it.
  • The value must be a valid IPv4 address in the available IP address range.

alias

No

String

  • Specifies the EIP name.
  • The value can contain 1 to 64 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

port_id

No

String

  • Specifies the port ID. The EIP to be assigned is bound to this port.
  • The value must be an ID of an existing port. If the port does not exist or has been bound to an EIP, an error message is displayed.
Table 4 Description of the bandwidth field

Name

Mandatory

Type

Description

name

No

String

  • Specifies the bandwidth name.
  • The value can contain 1 to 64 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).
  • This parameter is mandatory when share_type is set to PER. This parameter will be ignored when share_type is set to WHOLE with an ID specified.

size

No

Integer

  • Specifies the bandwidth size.
  • The value ranges from 1 Mbit/s to 300 Mbit/s by default. (The specific range may vary depending on the configuration in each region. You can see the bandwidth range of each region on the management console.)
  • This parameter is mandatory when share_type is set to PER. This parameter will be ignored when share_type is set to WHOLE with an ID specified.
  • The minimum increment for bandwidth adjustment varies depending on the bandwidth range. The details are as follows:
    • The minimum increment is 1 Mbit/s if the allowed bandwidth ranges from 0 Mbit/s to 300 Mbit/s (with 300 Mbit/s included).
    • The minimum increment is 50 Mbit/s if the allowed bandwidth ranges from 300 Mbit/s to 1000 Mbit/s (with 1000 Mbit/s included).
    • The minimum increment is 500 Mbit/s if the allowed bandwidth is greater than 1000 Mbit/s.

id

No

String

  • Specifies the bandwidth ID. You can specify an existing shared bandwidth when assigning an EIP.
  • The value can be the ID of the shared bandwidth whose type is set to WHOLE.

share_type

Yes

String

  • Specifies the bandwidth type.
  • Possible values are as follows:
    • PER: Dedicated bandwidth
    • WHOLE: Shared bandwidth
  • If this parameter is set to WHOLE, the bandwidth ID must be specified.

charge_mode

No

String

  • Specifies whether the bandwidth is billed by traffic or by bandwidth size.
  • The value bandwidth indicates that you will be billed by bandwidth, and the value traffic indicates that you will be billed by traffic.

Example Request

Example request (IPv4 EIP with dedicated bandwidth)
POST https://{Endpoint}/v1/{project_id}/publicips

{
    "publicip": {
        "type": "5_bgp",
        "ip_version": 4
    },
    "bandwidth": {
        "name": "bandwidth123",
        "size": 10,
        "share_type": "PER"
    },
    "enterprise_project_id":"b261ac1f-2489-4bc7-b31b-c33c3346a439"
}

Response Message

  • Response parameter
    Table 5 Response parameter

    Name

    Type

    Description

    publicip

    publicip object

    Specifies the EIP object. For details, see Table 6.

    Table 6 Description of the publicip field

    Name

    Type

    Description

    id

    String

    Specifies the unique identifier of an EIP.

    status

    String

    • Specifies the EIP status.
    • Possible values are as follows:
      • FREEZED (Frozen)
      • BIND_ERROR (Binding failed)
      • BINDING (Binding)
      • PENDING_DELETE (Releasing)
      • PENDING_CREATE (Assigning)
      • PENDING_UPDATE (Updating)
      • NOTIFYING (Assigning)
      • NOTIFY_DELETE (Release)
      • DOWN (Unbound)
      • ACTIVE (Bound)
      • ELB (Bound to a load balancer)
      • VPN (Bound to a VPN)
      • ERROR (Exceptions)

    type

    String

    • Specifies the EIP type.
    • The value can be 5_bgp (dynamic BGP) or 5_sbgp (static BGP).
      • CN South-Guangzhou: 5_bgp and 5_sbgp
      • CN East-Shanghai1: 5_bgp and 5_sbgp
      • CN East-Shanghai2: 5_bgp and 5_sbgp
      • CN North-Beijing1: 5_bgp and 5_sbgp
      • CN-Hong Kong: 5_bgp
      • AP-Bangkok: 5_bgp
      • AP-Singapore: 5_bgp
      • AF-Johannesburg: 5_bgp
      • CN Southwest-Guiyang1: 5_sbgp
      • CN North-Beijing4: 5_bgp and 5_sbgp
      • LA-Santiago: 5_bgp
      • LA-Sao Paulo1: 5_bgp
      • LA-Mexico City1: 5_bgp
      • LA-Buenos Aires1: 5_bgp
      • LA-Lima1: 5_bgp
      • LA-Santiago2: 5_bgp
    • Constraints:
      • The configured value must be supported by the system.
      • publicip_id is an IPv4 port. If publicip_type is not specified, the default value is 5_bgp.

    public_ip_address

    String

    Specifies the obtained EIP if only IPv4 EIPs are available.

    public_ipv6_address

    String

    Specifies the obtained EIP if IPv6 EIPs are available. This parameter does not exist if only IPv4 EIPs are available.

    ip_version

    Integer

    Specifies the IP address version. The value can be 4 or 6.

    • 4: IPv4
    • 6: IPv6

    tenant_id

    String

    Specifies the project ID.

    create_time

    String

    Specifies the time (UTC) when the EIP is assigned.

    Format: yyyy-MM-dd HH:mm:ss

    bandwidth_size

    Integer

    Specifies the bandwidth (Mbit/s).

    alias

    String

    Specifies the EIP name.

    enterprise_project_id

    String

    • Specifies the enterprise project ID. The value is 0 or a string that contains a maximum of 36 characters in UUID format with hyphens (-).
    • When you assign an EIP, associate an enterprise project ID with the EIP.
    • If this parameter is not specified, the default value is 0, which indicates that the default enterprise project is used.
    NOTE:

    For more information about enterprise projects and how to obtain enterprise project IDs, see the Enterprise Management User Guide.

    public_border_group

    String

    Specifies whether it is in a central site or an edge site.

    The value can be:

    • center
    • Edge site name

    This resource can only be associated with an EIP of the same region.

Example Response

Example response (IPv4 EIP with dedicated bandwidth)
{
    "publicip": {
        "id": "f588ccfa-8750-4d7c-bf5d-2ede24414706",
        "alias": "tom",
        "public_border_group": "center",
        "status": "PENDING_CREATE",
        "type": "5_bgp",
        "public_ip_address": "161.xx.xx.7",
        "tenant_id": "8b7e35ad379141fc9df3e178bd64f55c",
        "ip_version": 4,
        "create_time": "2015-07-16 04:10:52",
        "bandwidth_size": 0,
        "enterprise_project_id": "b261ac1f-2489-4bc7-b31b-c33c3346a439"
    }
}

Status Code

See Status Codes.

Error Code

See Error Codes.