Chilkat Online Tools

SQL Server / Core Services API / GetVirtualCircuit

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{signature}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Date', '{{date}}'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://iaas.{{region}}.oraclecloud.com/20160918/virtualCircuits/:virtualCircuitId', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

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

    -- {
    --   "bandwidthShapeName": "aliquip quis",
    --   "bgpManagement": "PROVIDER_MANAGED",
    --   "bgpSessionState": "UP",
    --   "compartmentId": "ex voluptate ea eiusmod",
    --   "crossConnectMappings": [
    --     {
    --       "value": "<Error: Too many levels of nesting to fake this schema>"
    --     },
    --     {
    --       "value": "<Error: Too many levels of nesting to fake this schema>"
    --     }
    --   ],
    --   "customerBgpAsn": 32592947,
    --   "definedTags": {},
    --   "displayName": "sunt exercitation",
    --   "freeformTags": {},
    --   "gatewayId": "sed deserunt magna",
    --   "id": "ex Duis amet culpa",
    --   "lifecycleState": "PROVISIONING",
    --   "oracleBgpAsn": 34318225,
    --   "providerName": "ullamco occaecat culpa cillum",
    --   "providerServiceId": "nisi ex culpa dolor",
    --   "providerServiceKeyName": "nostru",
    --   "providerServiceName": "laboris labore",
    --   "providerState": "ACTIVE",
    --   "publicPrefixes": [
    --     "proident et amet qui dolor",
    --     "tempor nostrud"
    --   ],
    --   "referenceComment": "laboris fugiat do",
    --   "region": "dolore sint ut non",
    --   "routingPolicy": [
    --     "MARKET_LEVEL",
    --     "GLOBAL"
    --   ],
    --   "serviceType": "LAYER2",
    --   "timeCreated": "2021-02-05T13:31:56.554Z",
    --   "type": "PUBLIC"
    -- }

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

    DECLARE @value nvarchar(4000)

    DECLARE @strVal nvarchar(4000)

    DECLARE @bandwidthShapeName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @bandwidthShapeName OUT, 'bandwidthShapeName'
    DECLARE @bgpManagement nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @bgpManagement OUT, 'bgpManagement'
    DECLARE @bgpSessionState nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @bgpSessionState OUT, 'bgpSessionState'
    DECLARE @compartmentId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @compartmentId OUT, 'compartmentId'
    DECLARE @customerBgpAsn int
    EXEC sp_OAMethod @jResp, 'IntOf', @customerBgpAsn OUT, 'customerBgpAsn'
    DECLARE @displayName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @displayName OUT, 'displayName'
    DECLARE @gatewayId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @gatewayId OUT, 'gatewayId'
    DECLARE @id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
    DECLARE @lifecycleState nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleState OUT, 'lifecycleState'
    DECLARE @oracleBgpAsn int
    EXEC sp_OAMethod @jResp, 'IntOf', @oracleBgpAsn OUT, 'oracleBgpAsn'
    DECLARE @providerName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @providerName OUT, 'providerName'
    DECLARE @providerServiceId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @providerServiceId OUT, 'providerServiceId'
    DECLARE @providerServiceKeyName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @providerServiceKeyName OUT, 'providerServiceKeyName'
    DECLARE @providerServiceName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @providerServiceName OUT, 'providerServiceName'
    DECLARE @providerState nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @providerState OUT, 'providerState'
    DECLARE @referenceComment nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @referenceComment OUT, 'referenceComment'
    DECLARE @region nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @region OUT, 'region'
    DECLARE @serviceType nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @serviceType OUT, 'serviceType'
    DECLARE @timeCreated nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @timeCreated OUT, 'timeCreated'
    DECLARE @v_type nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'type'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'crossConnectMappings'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'crossConnectMappings[i].value'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'publicPrefixes'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'publicPrefixes[i]'
        SELECT @i = @i + 1
      END
    SELECT @i = 0
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'routingPolicy'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'routingPolicy[i]'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

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

Postman Collection Item JSON

{
  "name": "GetVirtualCircuit",
  "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}}/virtualCircuits/:virtualCircuitId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "virtualCircuits",
        ":virtualCircuitId"
      ],
      "variable": [
        {
          "key": "virtualCircuitId",
          "value": "amet ut",
          "description": "(Required) The [OCID](/Content/General/Concepts/identifiers.htm) of the virtual circuit."
        }
      ]
    },
    "description": "Gets the specified virtual circuit's information."
  },
  "response": [
    {
      "name": "The virtual circuit was retrieved.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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 \"bandwidthShapeName\": \"aliquip quis\",\n \"bgpManagement\": \"PROVIDER_MANAGED\",\n \"bgpSessionState\": \"UP\",\n \"compartmentId\": \"ex voluptate ea eiusmod\",\n \"crossConnectMappings\": [\n  {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  },\n  {\n   \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n  }\n ],\n \"customerBgpAsn\": 32592947,\n \"definedTags\": {},\n \"displayName\": \"sunt exercitation\",\n \"freeformTags\": {},\n \"gatewayId\": \"sed deserunt magna\",\n \"id\": \"ex Duis amet culpa\",\n \"lifecycleState\": \"PROVISIONING\",\n \"oracleBgpAsn\": 34318225,\n \"providerName\": \"ullamco occaecat culpa cillum\",\n \"providerServiceId\": \"nisi ex culpa dolor\",\n \"providerServiceKeyName\": \"nostru\",\n \"providerServiceName\": \"laboris labore\",\n \"providerState\": \"ACTIVE\",\n \"publicPrefixes\": [\n  \"proident et amet qui dolor\",\n  \"tempor nostrud\"\n ],\n \"referenceComment\": \"laboris fugiat do\",\n \"region\": \"dolore sint ut non\",\n \"routingPolicy\": [\n  \"MARKET_LEVEL\",\n  \"GLOBAL\"\n ],\n \"serviceType\": \"LAYER2\",\n \"timeCreated\": \"2021-02-05T13:31:56.554Z\",\n \"type\": \"PUBLIC\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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}}/virtualCircuits/:virtualCircuitId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "virtualCircuits",
            ":virtualCircuitId"
          ],
          "variable": [
            {
              "key": "virtualCircuitId"
            }
          ]
        }
      },
      "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}"
    }
  ]
}