Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Tcl Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Tcl) Azure Create Storage Account

Demonstrates how to create an Azure storage account.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

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

set http [new_CkHttp]

# Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
set jsonToken [new_CkJsonObject]

set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/azureToken.json"]
# Assuming success..
CkHttp_put_AuthToken $http [CkJsonObject_stringOf $jsonToken "access_token"]
puts "AuthToken: [CkHttp_authToken $http]"

CkHttp_put_Accept $http "application/json"

# Create the following JSON:

# {
#   "sku": {
#     "name": "Standard_GRS"
#   },
#   "kind": "StorageV2",
#   "location": "eastus2",
# }

# Use this online tool to generate the code from sample JSON: 
# Generate Code to Create JSON

set jsonRequestBody [new_CkJsonObject]

CkJsonObject_UpdateString $jsonRequestBody "sku.name" "Standard_GRS"
CkJsonObject_UpdateString $jsonRequestBody "kind" "StorageV2"
CkJsonObject_UpdateString $jsonRequestBody "location" "eastus2"

set url "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01"

# resp is a CkHttpResponse
set resp [CkHttp_PText $http "PUT" $url [CkJsonObject_emit $jsonRequestBody] "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] != 1} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkJsonObject $jsonRequestBody
    exit
}

puts "Response Status Code: [CkHttpResponse_get_StatusCode $resp]"

set json [new_CkJsonObject]

CkJsonObject_Load $json [CkHttpResponse_bodyStr $resp]
CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]

if {[CkHttpResponse_get_StatusCode $resp] >= 300} then {
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkJsonObject $jsonRequestBody
    delete_CkJsonObject $json
    exit
}

# Successful requests to create a new account return a 202 status code with an empty response body. The storage account is created asynchronously. 
# If the account already exists or is being provisioned, the request response has a 200 return code with the configuration of the existing storage account in the response body.
if {[CkHttpResponse_get_StatusCode $resp] == 202} then {
    puts "Azure-AsyncOperation: [CkHttpResponse_getHeaderField $resp Azure-AsyncOperation]"
}

if {[CkHttpResponse_get_StatusCode $resp] == 200} then {

    # Parse a response like this:

    # 	{
    # 	  "sku": {
    # 	    "name": "Standard_GRS",
    # 	    "tier": "Standard"
    # 	  },
    # 	  "kind": "StorageV2",
    # 	  "id": "/subscriptions/6c42643b-ebef-45f0-b917-b3583b84a57f/resourceGroups/gChilkat/providers/Microsoft.Storage/storageAccounts/chilkatsoftware",
    # 	  "name": "chilkatsoftware",
    # 	  "type": "Microsoft.Storage/storageAccounts",
    # 	  "location": "eastus2",
    # 	  "tags": {},
    # 	  "properties": {
    # 	    "networkAcls": {
    # 	      "bypass": "AzureServices",
    # 	      "virtualNetworkRules": [
    # 	      ],
    # 	      "ipRules": [
    # 	      ],
    # 	      "defaultAction": "Allow"
    # 	    },
    # 	    "supportsHttpsTrafficOnly": false,
    # 	    "encryption": {
    # 	      "services": {
    # 	        "file": {
    # 	          "enabled": true,
    # 	          "lastEnabledTime": "2019-05-14T22:18:33.2246670Z"
    # 	        },
    # 	        "blob": {
    # 	          "enabled": true,
    # 	          "lastEnabledTime": "2019-05-14T22:18:33.2246670Z"
    # 	        }
    # 	      },
    # 	      "keySource": "Microsoft.Storage"
    # 	    },
    # 	    "accessTier": "Hot",
    # 	    "provisioningState": "Succeeded",
    # 
    # 	    "creationTime": "2019-05-14T22:18:33.1309165Z",
    # 	    "primaryEndpoints": {
    # 	      "dfs": "https://chilkatsoftware.dfs.core.windows.net/",
    # 	      "web": "https://chilkatsoftware.z20.web.core.windows.net/",
    # 	      "blob": "https://chilkatsoftware.blob.core.windows.net/",
    # 	      "queue": "https://chilkatsoftware.queue.core.windows.net/",
    # 	      "table": "https://chilkatsoftware.table.core.windows.net/",
    # 	      "file": "https://chilkatsoftware.file.core.windows.net/"
    # 	    },
    # 	    "primaryLocation": "eastus2",
    # 	    "statusOfPrimary": "available",
    # 	    "secondaryLocation": "centralus",
    # 	    "statusOfSecondary": "available"
    # 	  }
    # 	}

    # Use this online tool to generate parsing code from sample JSON: 
    # Generate Parsing Code from JSON

    set skuName [CkJsonObject_stringOf $json "sku.name"]
    set skuTier [CkJsonObject_stringOf $json "sku.tier"]
    set kind [CkJsonObject_stringOf $json "kind"]
    set id [CkJsonObject_stringOf $json "id"]
    set name [CkJsonObject_stringOf $json "name"]
    set v_type [CkJsonObject_stringOf $json "type"]
    set location [CkJsonObject_stringOf $json "location"]
    set propertiesNetworkAclsBypass [CkJsonObject_stringOf $json "properties.networkAcls.bypass"]
    set propertiesNetworkAclsDefaultAction [CkJsonObject_stringOf $json "properties.networkAcls.defaultAction"]
    set propertiesSupportsHttpsTrafficOnly [CkJsonObject_BoolOf $json "properties.supportsHttpsTrafficOnly"]
    set propertiesEncryptionServicesFileEnabled [CkJsonObject_BoolOf $json "properties.encryption.services.file.enabled"]
    set propertiesEncryptionServicesFileLastEnabledTime [CkJsonObject_stringOf $json "properties.encryption.services.file.lastEnabledTime"]
    set propertiesEncryptionServicesBlobEnabled [CkJsonObject_BoolOf $json "properties.encryption.services.blob.enabled"]
    set propertiesEncryptionServicesBlobLastEnabledTime [CkJsonObject_stringOf $json "properties.encryption.services.blob.lastEnabledTime"]
    set propertiesEncryptionKeySource [CkJsonObject_stringOf $json "properties.encryption.keySource"]
    set propertiesAccessTier [CkJsonObject_stringOf $json "properties.accessTier"]
    set propertiesProvisioningState [CkJsonObject_stringOf $json "properties.provisioningState"]
    set propertiesCreationTime [CkJsonObject_stringOf $json "properties.creationTime"]
    set propertiesPrimaryEndpointsDfs [CkJsonObject_stringOf $json "properties.primaryEndpoints.dfs"]
    set propertiesPrimaryEndpointsWeb [CkJsonObject_stringOf $json "properties.primaryEndpoints.web"]
    set propertiesPrimaryEndpointsBlob [CkJsonObject_stringOf $json "properties.primaryEndpoints.blob"]
    set propertiesPrimaryEndpointsQueue [CkJsonObject_stringOf $json "properties.primaryEndpoints.queue"]
    set propertiesPrimaryEndpointsTable [CkJsonObject_stringOf $json "properties.primaryEndpoints.table"]
    set propertiesPrimaryEndpointsFile [CkJsonObject_stringOf $json "properties.primaryEndpoints.file"]
    set propertiesPrimaryLocation [CkJsonObject_stringOf $json "properties.primaryLocation"]
    set propertiesStatusOfPrimary [CkJsonObject_stringOf $json "properties.statusOfPrimary"]
    set propertiesSecondaryLocation [CkJsonObject_stringOf $json "properties.secondaryLocation"]
    set propertiesStatusOfSecondary [CkJsonObject_stringOf $json "properties.statusOfSecondary"]
}

puts "Success."

delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonObject $jsonToken
delete_CkJsonObject $jsonRequestBody
delete_CkJsonObject $json

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.