Chilkat Online Tools

delphiDll / Core Services API / GetSubnet

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
strVal: PWideChar;
vcnId: PWideChar;
id: PWideChar;
compartmentId: PWideChar;
cidrBlock: PWideChar;
routeTableId: PWideChar;
virtualRouterIp: PWideChar;
virtualRouterMac: PWideChar;
lifecycleState: PWideChar;
availabilityDomain: PWideChar;
dhcpOptionsId: PWideChar;
displayName: PWideChar;
dnsLabel: PWideChar;
ipv6CidrBlock: PWideChar;
ipv6PublicCidrBlock: PWideChar;
ipv6VirtualRouterIp: PWideChar;
prohibitPublicIpOnVnic: Boolean;
subnetDomainName: PWideChar;
timeCreated: PWideChar;
i: Integer;
count_i: Integer;

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

http := CkHttp_Create();

CkHttp_SetRequestHeader(http,'Authorization','{{signature}}');
CkHttp_SetRequestHeader(http,'Date','{{date}}');

sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://iaas.{{region}}.oraclecloud.com/20160918/subnets/:subnetId',sbResponseBody);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));

respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttp__lastHeader(http));
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

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

// {
//   "vcnId": "enim non eu cillum",
//   "id": "eu incididunt tempor",
//   "compartmentId": "deserunt eu et v",
//   "cidrBlock": "minim",
//   "routeTableId": "veniam dolor voluptate m",
//   "virtualRouterIp": "dolore dolor ven",
//   "virtualRouterMac": "pariatur",
//   "lifecycleState": "AVAILABLE",
//   "availabilityDomain": "Lorem pariatur do",
//   "definedTags": {},
//   "dhcpOptionsId": "aute",
//   "displayName": "Duis ad eu sunt",
//   "dnsLabel": "eiusmod",
//   "freeformTags": {},
//   "ipv6CidrBlock": "adipisicing reprehende",
//   "ipv6PublicCidrBlock": "sed Lorem",
//   "ipv6VirtualRouterIp": "in ex cupidatat",
//   "prohibitPublicIpOnVnic": false,
//   "securityListIds": [
//     "dolore in enim",
//     "anim Lorem"
//   ],
//   "subnetDomainName": "labore cupidatat commodo",
//   "timeCreated": "1995-01-31T14:27:19.328Z"
// }

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

vcnId := CkJsonObject__stringOf(jResp,'vcnId');
id := CkJsonObject__stringOf(jResp,'id');
compartmentId := CkJsonObject__stringOf(jResp,'compartmentId');
cidrBlock := CkJsonObject__stringOf(jResp,'cidrBlock');
routeTableId := CkJsonObject__stringOf(jResp,'routeTableId');
virtualRouterIp := CkJsonObject__stringOf(jResp,'virtualRouterIp');
virtualRouterMac := CkJsonObject__stringOf(jResp,'virtualRouterMac');
lifecycleState := CkJsonObject__stringOf(jResp,'lifecycleState');
availabilityDomain := CkJsonObject__stringOf(jResp,'availabilityDomain');
dhcpOptionsId := CkJsonObject__stringOf(jResp,'dhcpOptionsId');
displayName := CkJsonObject__stringOf(jResp,'displayName');
dnsLabel := CkJsonObject__stringOf(jResp,'dnsLabel');
ipv6CidrBlock := CkJsonObject__stringOf(jResp,'ipv6CidrBlock');
ipv6PublicCidrBlock := CkJsonObject__stringOf(jResp,'ipv6PublicCidrBlock');
ipv6VirtualRouterIp := CkJsonObject__stringOf(jResp,'ipv6VirtualRouterIp');
prohibitPublicIpOnVnic := CkJsonObject_BoolOf(jResp,'prohibitPublicIpOnVnic');
subnetDomainName := CkJsonObject__stringOf(jResp,'subnetDomainName');
timeCreated := CkJsonObject__stringOf(jResp,'timeCreated');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'securityListIds');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'securityListIds[i]');
    i := i + 1;
  end;

CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);

Curl Command

curl -X GET
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://iaas.{{region}}.oraclecloud.com/20160918/subnets/:subnetId

Postman Collection Item JSON

{
  "name": "GetSubnet",
  "request": {
    "method": "GET",
    "header": [
      {
        "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}}/subnets/:subnetId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "subnets",
        ":subnetId"
      ],
      "variable": [
        {
          "key": "subnetId",
          "value": "amet ut",
          "description": "(Required) The [OCID](/Content/General/Concepts/identifiers.htm) of the subnet."
        }
      ]
    },
    "description": "Gets the specified subnet's information."
  },
  "response": [
    {
      "name": "The subnet was retrieved.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/subnets/:subnetId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "subnets",
            ":subnetId"
          ],
          "variable": [
            {
              "key": "subnetId"
            }
          ]
        }
      },
      "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 \"vcnId\": \"enim non eu cillum\",\n \"id\": \"eu incididunt tempor\",\n \"compartmentId\": \"deserunt eu et v\",\n \"cidrBlock\": \"minim\",\n \"routeTableId\": \"veniam dolor voluptate m\",\n \"virtualRouterIp\": \"dolore dolor ven\",\n \"virtualRouterMac\": \"pariatur\",\n \"lifecycleState\": \"AVAILABLE\",\n \"availabilityDomain\": \"Lorem pariatur do\",\n \"definedTags\": {},\n \"dhcpOptionsId\": \"aute\",\n \"displayName\": \"Duis ad eu sunt\",\n \"dnsLabel\": \"eiusmod\",\n \"freeformTags\": {},\n \"ipv6CidrBlock\": \"adipisicing reprehende\",\n \"ipv6PublicCidrBlock\": \"sed Lorem\",\n \"ipv6VirtualRouterIp\": \"in ex cupidatat\",\n \"prohibitPublicIpOnVnic\": false,\n \"securityListIds\": [\n  \"dolore in enim\",\n  \"anim Lorem\"\n ],\n \"subnetDomainName\": \"labore cupidatat commodo\",\n \"timeCreated\": \"1995-01-31T14:27:19.328Z\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/subnets/:subnetId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "subnets",
            ":subnetId"
          ],
          "variable": [
            {
              "key": "subnetId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/subnets/:subnetId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "subnets",
            ":subnetId"
          ],
          "variable": [
            {
              "key": "subnetId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/subnets/:subnetId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "subnets",
            ":subnetId"
          ],
          "variable": [
            {
              "key": "subnetId"
            }
          ]
        }
      },
      "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": [
        ],
        "url": {
          "raw": "{{baseUrl}}/subnets/:subnetId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "subnets",
            ":subnetId"
          ],
          "variable": [
            {
              "key": "subnetId"
            }
          ]
        }
      },
      "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}"
    }
  ]
}