Chilkat Online Tools

PureBasic / Core Services API / GetIpv6

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    CkHttp::ckSetRequestHeader(http,"opc-request-id","8wF")
    CkHttp::ckSetRequestHeader(http,"Authorization","{{signature}}")
    CkHttp::ckSetRequestHeader(http,"Date","{{date}}")

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckQuickGetSb(http,"https://iaas.{{region}}.oraclecloud.com/20160918/ipv6/:ipv6Id",sbResponseBody)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttp::ckLastStatus(http)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttp::ckLastHeader(http)
        Debug "Failed."
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

    ; Sample JSON response:
    ; (Sample code for parsing the JSON response is shown below)

    ; {
    ;   "compartmentId": "nisi non",
    ;   "displayName": "eu ex",
    ;   "id": "adipisicing exercitation officia dolore ex",
    ;   "ipAddress": "magna dolore volu",
    ;   "lifecycleState": "TERMINATED",
    ;   "subnetId": "ad",
    ;   "timeCreated": "1993-02-19T03:20:41.962Z",
    ;   "vnicId": "pariatur consequat incididunt id",
    ;   "definedTags": {},
    ;   "freeformTags": {},
    ;   "isInternetAccessAllowed": true,
    ;   "publicIpAddress": "magna "
    ; }

    ; Sample code for parsing the JSON response...
    ; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    compartmentId.s = CkJsonObject::ckStringOf(jResp,"compartmentId")
    displayName.s = CkJsonObject::ckStringOf(jResp,"displayName")
    id.s = CkJsonObject::ckStringOf(jResp,"id")
    ipAddress.s = CkJsonObject::ckStringOf(jResp,"ipAddress")
    lifecycleState.s = CkJsonObject::ckStringOf(jResp,"lifecycleState")
    subnetId.s = CkJsonObject::ckStringOf(jResp,"subnetId")
    timeCreated.s = CkJsonObject::ckStringOf(jResp,"timeCreated")
    vnicId.s = CkJsonObject::ckStringOf(jResp,"vnicId")
    isInternetAccessAllowed.i = CkJsonObject::ckBoolOf(jResp,"isInternetAccessAllowed")
    publicIpAddress.s = CkJsonObject::ckStringOf(jResp,"publicIpAddress")


    CkHttp::ckDispose(http)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -X GET
	-H "opc-request-id: 8wF"
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://iaas.{{region}}.oraclecloud.com/20160918/ipv6/:ipv6Id

Postman Collection Item JSON

{
  "name": "GetIpv6",
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
        "key": "opc-request-id",
        "value": "8wF"
      },
      {
        "key": "Date",
        "value": "{{date}}",
        "description": "(Required) Current Date",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "{{signature}}",
        "description": "(Required) Signature Authentication on Authorization header",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/ipv6/:ipv6Id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "ipv6",
        ":ipv6Id"
      ],
      "variable": [
        {
          "key": "ipv6Id",
          "value": "amet ut",
          "description": "(Required) The [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the IPv6."
        }
      ]
    },
    "description": "Gets the specified IPv6. You must specify the object's [OCID](/Content/General/Concepts/identifiers.htm).\nAlternatively, you can get the object by using\n[ListIpv6s](#/en/iaas/latest/Ipv6/ListIpv6s)\nwith the IPv6 address (for example, 2001:0db8:0123:1111:98fe:dcba:9876:4321) and subnet [OCID](/iaas/Content/General/Concepts/identifiers.htm).\n"
  },
  "response": [
    {
      "name": "The IPv6 was retrievd.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ipv6/:ipv6Id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ipv6",
            ":ipv6Id"
          ],
          "variable": [
            {
              "key": "ipv6Id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "etag",
          "value": "officia sed",
          "description": "For optimistic concurrency control. See `if-match`.\n"
        },
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"compartmentId\": \"nisi non\",\n \"displayName\": \"eu ex\",\n \"id\": \"adipisicing exercitation officia dolore ex\",\n \"ipAddress\": \"magna dolore volu\",\n \"lifecycleState\": \"TERMINATED\",\n \"subnetId\": \"ad\",\n \"timeCreated\": \"1993-02-19T03:20:41.962Z\",\n \"vnicId\": \"pariatur consequat incididunt id\",\n \"definedTags\": {},\n \"freeformTags\": {},\n \"isInternetAccessAllowed\": true,\n \"publicIpAddress\": \"magna \"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ipv6/:ipv6Id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ipv6",
            ":ipv6Id"
          ],
          "variable": [
            {
              "key": "ipv6Id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "Not Found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ipv6/:ipv6Id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ipv6",
            ":ipv6Id"
          ],
          "variable": [
            {
              "key": "ipv6Id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "Internal Server Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ipv6/:ipv6Id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ipv6",
            ":ipv6Id"
          ],
          "variable": [
            {
              "key": "ipv6Id"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    },
    {
      "name": "An error has occurred.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Unique identifier for the request.\nIf you need to contact Oracle about a particular request, please provide the request ID.\n",
            "key": "opc-request-id",
            "value": "8wF"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ipv6/:ipv6Id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ipv6",
            ":ipv6Id"
          ],
          "variable": [
            {
              "key": "ipv6Id"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "officia sed",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact\nOracle about a particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"et exercitation Excepteur\",\n \"message\": \"irure sit\"\n}"
    }
  ]
}