Chilkat Online Tools

GetApp C# Example

Amplify

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

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

Chilkat.AuthAws authAws = new Chilkat.AuthAws();
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 = "amplify";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws);

// URL: https://amplify.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("amplify.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","GetApp");

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = rest.FullRequestNoBodySb("GET","/apps/{appId}",sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
Debug.WriteLine("response status code = " + Convert.ToString(respStatusCode));
if (respStatusCode != 200) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
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

string strVal;
string condition;
string source;
string status;
string target;

string AppArn = jResp.StringOf("app.appArn");
string AppId = jResp.StringOf("app.appId");
string BasicAuthCredentials = jResp.StringOf("app.autoBranchCreationConfig.basicAuthCredentials");
string BuildSpec = jResp.StringOf("app.autoBranchCreationConfig.buildSpec");
int EnableAutoBuild = jResp.IntOf("app.autoBranchCreationConfig.enableAutoBuild");
int EnableBasicAuth = jResp.IntOf("app.autoBranchCreationConfig.enableBasicAuth");
int EnablePerformanceMode = jResp.IntOf("app.autoBranchCreationConfig.enablePerformanceMode");
int EnablePullRequestPreview = jResp.IntOf("app.autoBranchCreationConfig.enablePullRequestPreview");
string v_String = jResp.StringOf("app.autoBranchCreationConfig.environmentVariables.string");
string Framework = jResp.StringOf("app.autoBranchCreationConfig.framework");
string PullRequestEnvironmentName = jResp.StringOf("app.autoBranchCreationConfig.pullRequestEnvironmentName");
string Stage = jResp.StringOf("app.autoBranchCreationConfig.stage");
string appBasicAuthCredentials = jResp.StringOf("app.basicAuthCredentials");
string appBuildSpec = jResp.StringOf("app.buildSpec");
int CreateTime = jResp.IntOf("app.createTime");
string CustomHeaders = jResp.StringOf("app.customHeaders");
string DefaultDomain = jResp.StringOf("app.defaultDomain");
string Description = jResp.StringOf("app.description");
int EnableAutoBranchCreation = jResp.IntOf("app.enableAutoBranchCreation");
int appEnableBasicAuth = jResp.IntOf("app.enableBasicAuth");
int EnableBranchAutoBuild = jResp.IntOf("app.enableBranchAutoBuild");
int EnableBranchAutoDeletion = jResp.IntOf("app.enableBranchAutoDeletion");
string EnvironmentVariablesString = jResp.StringOf("app.environmentVariables.string");
string IamServiceRoleArn = jResp.StringOf("app.iamServiceRoleArn");
string Name = jResp.StringOf("app.name");
string Platform = jResp.StringOf("app.platform");
string BranchName = jResp.StringOf("app.productionBranch.branchName");
int LastDeployTime = jResp.IntOf("app.productionBranch.lastDeployTime");
string Status = jResp.StringOf("app.productionBranch.status");
string ThumbnailUrl = jResp.StringOf("app.productionBranch.thumbnailUrl");
string Repository = jResp.StringOf("app.repository");
string RepositoryCloneMethod = jResp.StringOf("app.repositoryCloneMethod");
string TagsString = jResp.StringOf("app.tags.string");
int UpdateTime = jResp.IntOf("app.updateTime");
int i = 0;
int count_i = jResp.SizeOfArray("app.autoBranchCreationPatterns");
while (i < count_i) {
    jResp.I = i;
    strVal = jResp.StringOf("app.autoBranchCreationPatterns[i]");
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("app.customRules");
while (i < count_i) {
    jResp.I = i;
    condition = jResp.StringOf("app.customRules[i].condition");
    source = jResp.StringOf("app.customRules[i].source");
    status = jResp.StringOf("app.customRules[i].status");
    target = jResp.StringOf("app.customRules[i].target");
    i = i + 1;
}

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

// {
//   "app": {
//     "appArn": "string",
//     "appId": "string",
//     "autoBranchCreationConfig": {
//       "basicAuthCredentials": "string",
//       "buildSpec": "string",
//       "enableAutoBuild": boolean,
//       "enableBasicAuth": boolean,
//       "enablePerformanceMode": boolean,
//       "enablePullRequestPreview": boolean,
//       "environmentVariables": {
//         "string": "string"
//       },
//       "framework": "string",
//       "pullRequestEnvironmentName": "string",
//       "stage": "string"
//     },
//     "autoBranchCreationPatterns": [
//       "string"
//     ],
//     "basicAuthCredentials": "string",
//     "buildSpec": "string",
//     "createTime": number,
//     "customHeaders": "string",
//     "customRules": [
//       {
//         "condition": "string",
//         "source": "string",
//         "status": "string",
//         "target": "string"
//       }
//     ],
//     "defaultDomain": "string",
//     "description": "string",
//     "enableAutoBranchCreation": boolean,
//     "enableBasicAuth": boolean,
//     "enableBranchAutoBuild": boolean,
//     "enableBranchAutoDeletion": boolean,
//     "environmentVariables": {
//       "string": "string"
//     },
//     "iamServiceRoleArn": "string",
//     "name": "string",
//     "platform": "string",
//     "productionBranch": {
//       "branchName": "string",
//       "lastDeployTime": number,
//       "status": "string",
//       "thumbnailUrl": "string"
//     },
//     "repository": "string",
//     "repositoryCloneMethod": "string",
//     "tags": {
//       "string": "string"
//     },
//     "updateTime": number
//   }
// }