Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Swift 3/4 Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Swift 3/4) Azure List Storage Accounts

Demonstrates how to list Azure storage accounts.

Chilkat Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    // Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
    let jsonToken = CkoJsonObject()!
    var success: Bool = jsonToken.loadFile("qa_data/tokens/azureToken.json")
    // Assuming success..
    http.authToken = jsonToken.string(of: "access_token")
    print("AuthToken: \(http.authToken!)")

    http.accept = "application/json"

    var url: String? = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"

    var jsonResp: String? = http.quickGetStr(url)
    if http.lastMethodSuccess != true {
        print("\(http.lastErrorText!)")
        return
    }

    print("Response Status Code: \(http.lastStatus.intValue)")

    let json = CkoJsonObject()!
    json.load(jsonResp)
    json.emitCompact = false
    print("\(json.emit()!)")

    if http.lastStatus.intValue != 200 {
        print("Failed.")
        return
    }

    // Sample output...
    // (See the parsing code below..)
    // 
    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    // {
    //   "value": [
    //     {
    //       "sku": {
    //         "name": "Standard_LRS",
    //         "tier": "Standard"
    //       },
    //       "kind": "Storage",
    //       "id": "/subscriptions/6c42643b-ebef-45e0-b917-b3583b84a57f/resourceGroups/gchilkat/providers/Microsoft.Storage/storageAccounts/chilkat",
    //       "name": "chilkat",
    //       "type": "Microsoft.Storage/storageAccounts",
    //       "location": "eastus",
    //       "tags": {},
    //       "properties": {
    //         "networkAcls": {
    //           "bypass": "AzureServices",
    //           "virtualNetworkRules": [
    //           ],
    //           "ipRules": [
    //           ],
    //           "defaultAction": "Allow"
    //         },
    //         "supportsHttpsTrafficOnly": true,
    //         "encryption": {
    //           "services": {
    //             "file": {
    //               "enabled": true,
    //               "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
    //             },
    //             "blob": {
    //               "enabled": true,
    //               "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
    //             }
    //           },
    //           "keySource": "Microsoft.Storage"
    //         },
    //         "provisioningState": "Succeeded",
    //         "creationTime": "2016-04-18T22:57:36.5377065Z",
    //         "primaryEndpoints": {
    //           "blob": "https://chilkat.blob.core.windows.net/",
    //           "queue": "https://chilkat.queue.core.windows.net/",
    //           "table": "https://chilkat.table.core.windows.net/",
    //           "file": "https://chilkat.file.core.windows.net/"
    //         },
    //         "primaryLocation": "eastus",
    //         "statusOfPrimary": "available"
    //       }
    //     }
    //   ]
    // }
    // 

    var i: Int
    var count_i: Int
    var skuName: String?
    var skuTier: String?
    var kind: String?
    var id: String?
    var name: String?
    var v_type: String?
    var location: String?
    var propertiesNetworkAclsBypass: String?
    var propertiesNetworkAclsDefaultAction: String?
    var propertiesSupportsHttpsTrafficOnly: Bool
    var propertiesEncryptionServicesFileEnabled: Bool
    var propertiesEncryptionServicesFileLastEnabledTime: String?
    var propertiesEncryptionServicesBlobEnabled: Bool
    var propertiesEncryptionServicesBlobLastEnabledTime: String?
    var propertiesEncryptionKeySource: String?
    var propertiesProvisioningState: String?
    var propertiesCreationTime: String?
    var propertiesPrimaryEndpointsBlob: String?
    var propertiesPrimaryEndpointsQueue: String?
    var propertiesPrimaryEndpointsTable: String?
    var propertiesPrimaryEndpointsFile: String?
    var propertiesPrimaryLocation: String?
    var propertiesStatusOfPrimary: String?

    i = 0
    count_i = json.size(ofArray: "value").intValue
    while i < count_i {
        json.i = i
        skuName = json.string(of: "value[i].sku.name")
        skuTier = json.string(of: "value[i].sku.tier")
        kind = json.string(of: "value[i].kind")
        id = json.string(of: "value[i].id")
        name = json.string(of: "value[i].name")
        v_type = json.string(of: "value[i].type")
        location = json.string(of: "value[i].location")
        propertiesNetworkAclsBypass = json.string(of: "value[i].properties.networkAcls.bypass")
        propertiesNetworkAclsDefaultAction = json.string(of: "value[i].properties.networkAcls.defaultAction")
        propertiesSupportsHttpsTrafficOnly = json.bool(of: "value[i].properties.supportsHttpsTrafficOnly")
        propertiesEncryptionServicesFileEnabled = json.bool(of: "value[i].properties.encryption.services.file.enabled")
        propertiesEncryptionServicesFileLastEnabledTime = json.string(of: "value[i].properties.encryption.services.file.lastEnabledTime")
        propertiesEncryptionServicesBlobEnabled = json.bool(of: "value[i].properties.encryption.services.blob.enabled")
        propertiesEncryptionServicesBlobLastEnabledTime = json.string(of: "value[i].properties.encryption.services.blob.lastEnabledTime")
        propertiesEncryptionKeySource = json.string(of: "value[i].properties.encryption.keySource")
        propertiesProvisioningState = json.string(of: "value[i].properties.provisioningState")
        propertiesCreationTime = json.string(of: "value[i].properties.creationTime")
        propertiesPrimaryEndpointsBlob = json.string(of: "value[i].properties.primaryEndpoints.blob")
        propertiesPrimaryEndpointsQueue = json.string(of: "value[i].properties.primaryEndpoints.queue")
        propertiesPrimaryEndpointsTable = json.string(of: "value[i].properties.primaryEndpoints.table")
        propertiesPrimaryEndpointsFile = json.string(of: "value[i].properties.primaryEndpoints.file")
        propertiesPrimaryLocation = json.string(of: "value[i].properties.primaryLocation")
        propertiesStatusOfPrimary = json.string(of: "value[i].properties.statusOfPrimary")
        i = i + 1
    }


}

 

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