Chilkat Online Tools

UpdateSiteRackPhysicalProperties Swift Example

AWS Outposts

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

    let rest = CkoRest()
    var success: Bool

    let authAws = CkoAuthAws()
    authAws.AccessKey = "AWS_ACCESS_KEY"
    authAws.SecretKey = "AWS_SECRET_KEY"

    // Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
    authAws.Region = "us-west-2"
    authAws.ServiceName = "outposts"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    rest.SetAuthAws(authAws)

    // URL: https://outposts.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    success = rest.Connect("outposts.us-west-2.amazonaws.com", port: 443, tls: true, autoReconnect: true)
    if success != true {
        print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
        print("\(rest.LastErrorText)")
        return
    }

    // The following code creates the JSON request body.
    // The JSON created by this code is shown below.

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

    let json = CkoJsonObject()
    json.UpdateString("FiberOpticCableType", value: "string")
    json.UpdateString("MaximumSupportedWeightLbs", value: "string")
    json.UpdateString("OpticalStandard", value: "string")
    json.UpdateString("PowerConnector", value: "string")
    json.UpdateString("PowerDrawKva", value: "string")
    json.UpdateString("PowerFeedDrop", value: "string")
    json.UpdateString("PowerPhase", value: "string")
    json.UpdateString("UplinkCount", value: "string")
    json.UpdateString("UplinkGbps", value: "string")

    // The JSON request body created by the above code:

    // {
    //   "FiberOpticCableType": "string",
    //   "MaximumSupportedWeightLbs": "string",
    //   "OpticalStandard": "string",
    //   "PowerConnector": "string",
    //   "PowerDrawKva": "string",
    //   "PowerFeedDrop": "string",
    //   "PowerPhase": "string",
    //   "UplinkCount": "string",
    //   "UplinkGbps": "string"
    // }

    rest.AddHeader("Content-Type", value: "application/x-amz-json-1.1")
    rest.AddHeader("X-Amz-Target", value: "UpdateSiteRackPhysicalProperties")

    let sbRequestBody = CkoStringBuilder()
    json.EmitSb(sbRequestBody)
    let sbResponseBody = CkoStringBuilder()
    success = rest.FullRequestSb("PATCH", uriPath: "/sites/{SiteId}/rackPhysicalProperties", requestBody: sbRequestBody, responseBody: sbResponseBody)
    if success != true {
        print("\(rest.LastErrorText)")
        return
    }

    var respStatusCode: Int = rest.ResponseStatusCode.intValue
    print("response status code = \(respStatusCode)")
    if respStatusCode != 200 {
        print("Response Header:")
        print("\(rest.ResponseHeader)")
        print("Response Body:")
        print("\(sbResponseBody.GetAsString())")
        return
    }

    let jResp = CkoJsonObject()
    jResp.LoadSb(sbResponseBody)

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.

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

    var AccountId: String? = jResp.StringOf("Site.AccountId")
    var Description: String? = jResp.StringOf("Site.Description")
    var Name: String? = jResp.StringOf("Site.Name")
    var Notes: String? = jResp.StringOf("Site.Notes")
    var OperatingAddressCity: String? = jResp.StringOf("Site.OperatingAddressCity")
    var OperatingAddressCountryCode: String? = jResp.StringOf("Site.OperatingAddressCountryCode")
    var OperatingAddressStateOrRegion: String? = jResp.StringOf("Site.OperatingAddressStateOrRegion")
    var FiberOpticCableType: String? = jResp.StringOf("Site.RackPhysicalProperties.FiberOpticCableType")
    var MaximumSupportedWeightLbs: String? = jResp.StringOf("Site.RackPhysicalProperties.MaximumSupportedWeightLbs")
    var OpticalStandard: String? = jResp.StringOf("Site.RackPhysicalProperties.OpticalStandard")
    var PowerConnector: String? = jResp.StringOf("Site.RackPhysicalProperties.PowerConnector")
    var PowerDrawKva: String? = jResp.StringOf("Site.RackPhysicalProperties.PowerDrawKva")
    var PowerFeedDrop: String? = jResp.StringOf("Site.RackPhysicalProperties.PowerFeedDrop")
    var PowerPhase: String? = jResp.StringOf("Site.RackPhysicalProperties.PowerPhase")
    var UplinkCount: String? = jResp.StringOf("Site.RackPhysicalProperties.UplinkCount")
    var UplinkGbps: String? = jResp.StringOf("Site.RackPhysicalProperties.UplinkGbps")
    var SiteArn: String? = jResp.StringOf("Site.SiteArn")
    var SiteId: String? = jResp.StringOf("Site.SiteId")
    var v_String: String? = jResp.StringOf("Site.Tags.string")

    // A sample JSON response body parsed by the above code:

    // {
    //   "Site": {
    //     "AccountId": "string",
    //     "Description": "string",
    //     "Name": "string",
    //     "Notes": "string",
    //     "OperatingAddressCity": "string",
    //     "OperatingAddressCountryCode": "string",
    //     "OperatingAddressStateOrRegion": "string",
    //     "RackPhysicalProperties": {
    //       "FiberOpticCableType": "string",
    //       "MaximumSupportedWeightLbs": "string",
    //       "OpticalStandard": "string",
    //       "PowerConnector": "string",
    //       "PowerDrawKva": "string",
    //       "PowerFeedDrop": "string",
    //       "PowerPhase": "string",
    //       "UplinkCount": "string",
    //       "UplinkGbps": "string"
    //     },
    //     "SiteArn": "string",
    //     "SiteId": "string",
    //     "Tags": {
    //       "string": "string"
    //     }
    //   }
    // }

}