VPC ============== Create an API Key and access token: ``````````````````````` For create a **API Key** and **Access Token** to refer this link :- `https://www.e2enetworks.com/help/knowledge-base/how-to-create-an-api-access-token/ `_ List of VPC ``````````````````````` To find a list of **VPC** to send a **GET** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/vpc/list/?apikey={{API_Key}}&page_no=1&per_page=5&location=Delhi&project_id={{project-id}} The request returns a JSON object that contains the following attributes: .. list-table:: :widths: 25 25 50 :header-rows: 1 * - Name - Type - Description * - ip_address_private - Integer - Information regarding the network configuration. * - network_id - string - A unique integer identifier created and assigned to the VPC after its creation. * - gateway_ip - Integer - Information regarding the network configuration. * - name - string - The name assigned to the VPC. * - created_at - integer - A string represents both the date and time when the reserve ip is created. * - state - string - A string that denotes the state of the Reserve ip. * - ip_address_private - integer - Information regarding the network configuration. * - dns - integer - A unique integer identifier created and assigned to the VPC after its creation. .. tabs:: .. code-tab:: python http client import http.client conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = '' headers = { 'Authorization': 'API_token ', } conn.request("GET", "/myaccount/api/v1/vpc/list/?apikey=API_key&page_no=1&per_page=5&location=Delhi&project_id={{project-id}}", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) .. code-tab:: python Request import requests url = "https://api.e2enetworks.com/myaccount/api/v1/vpc/list/?apikey={{apikey}}&page_no=1&per_page=5&location=Delhi&project_id={{project-id}}" payload={} headers = { 'Authorization': 'API_Token ', } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted .. tabs:: .. code-tab:: python Response Body { "code": 200, "data": [ { "name": "VPC-765", "network_id": 7140, "is_active": true, "created_at": "2022-03-30T12:33:15.052911Z", "network_mask": "255.255.254.0", "ipv4_cidr": "10.3.234.0/23", "vm_count": 0, "dns": "8.8.8.8 8.8.4.4", "gateway_ip": "10.3.234.1", "pool_size": 512, "gateway_node": { "node_name": "VPC-765-gateway", "node_id": 90966, "ip_address_public": "164.52.208.56", "ip_address_private": "10.3.234.1", "state": "Creating" }, "state": "Creating" } ], "errors": {}, "message": "Success", "total_page_number": 1 } Create a new VPC ``````````````````````` To create a **VPC** to send a **Post** request .. code:: bash https://api.e2enetworks.com/myaccount/api/v1/vpc/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}} Attributes and respective values required to send this POST request are: .. list-table:: :widths: 25 25 60 10 :header-rows: 1 * - Name - Type - Description - Required * - network_size - Integer - A unique integer that provide the size of VPC. - True * - vpc_name - string - The name assigned to the VPC. - True The request returns a JSON object that contains the following attributes: .. list-table:: :widths: 25 25 50 :header-rows: 1 * - Name - Type - Description * - vpc_id - Integer - A unique integer identifier created and assigned to the VPC after its creation. * - vpc_name - string - The name was assigned to the VPC after its creation. .. tabs:: .. code-tab:: python http client import http.client import json conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = json.dumps({ "network_size": 512, "vpc_name": "VPC-769" }) headers = { 'Authorization': 'API_token ', 'Content-Type': 'application/json', } conn.request("POST", "/myaccount/api/v1/vpc/?apikey={{API_Key}}&location=Delhi&project_id={{project-id}}", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) .. code-tab:: python Request import requests import json url = "https://api.e2enetworks.com/myaccount/api/v1/vpc/?apikey={{apikey}}&location=Delhi&project_id={{project-id}}" payload = json.dumps({ "network_size": 512, "vpc_name": "VPC-769" }) headers = { 'Authorization': 'API_Token ', 'Content-Type': 'application/json', } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted .. tabs:: .. code-tab:: python Request Body { "network_size": 512, "vpc_name": "VPC-765" } .. code-tab:: python Response Body { "code": 201, "data": { "vpc_id": 614, "vpc_name": "VPC-768" }, "errors": {}, "message": "Created Successfully" } Delete a VPC ``````````````````````` To delete a **VPC** to send a **DELETE** request .. code-block:: bash https://api.e2enetworks.com/myaccount/api/v1/vpc/7146/?apikey={{API_Key}}&project_id={{project-id}} The request returns a JSON object that contains the following attributes: .. list-table:: :widths: 25 25 50 :header-rows: 1 * - Name - Type - Description * - vpc_id - Integer - A unique integer identifier created and assigned to the VPC after its creation. * - vpc_name - string - The name was assigned to the VPC after its creation. .. tabs:: .. code-tab:: python http client import http.client conn = http.client.HTTPSConnection("api.e2enetworks.com") payload = '' headers = { 'Authorization': 'API_Token ', } conn.request("DELETE", "/myaccount/api/v1/vpc/{{network_id}}/?apikey={{API_Key}}&project_id={{project-id}}", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) .. code-tab:: python Request import requests url = "https://api.e2enetworks.com/myaccount/api/v1/vpc/{{network_id}}/?apikey={{apikey}}&project_id={{project-id}}" payload={} headers = { 'Authorization': 'API_Token ' , } response = requests.request("DELETE", url, headers=headers, data=payload) print(response.text) .. tabs:: .. code-tab:: python Request Headers Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi... .. code-tab:: python Response Headers content-type: application/json; charset=utf-8 status: 202 Accepted .. tabs:: .. code-tab:: python Response Body { "code": 200, "data": { "vpc_id": 614, "vpc_name": "VPC-768" }, "errors": {}, "message": "Success" }