in AWSAppSyncTestCommon/AppSyncClientTestConfiguration.swift [90:171]
init?(with bundle: Bundle) {
guard let credentialsPath = bundle.path(forResource: "appsync_test_credentials", ofType: "json") else {
return nil
}
guard let credentialsData = try? Data.init(contentsOf: URL(fileURLWithPath: credentialsPath)) else {
return nil
}
print("json path: \(credentialsPath)")
let json = try? JSONSerialization.jsonObject(with: credentialsData, options: JSONSerialization.ReadingOptions.allowFragments)
guard let jsonObject = json as? JSONObject else {
return nil
}
guard let apiKey = jsonObject[JSONKeys.apiKey] as? String else {
return nil
}
self.apiKey = apiKey
guard let apiKeyEndpointURLString = jsonObject[JSONKeys.apiKeyEndpointURL] as? String,
let endpointURL = URL(string: apiKeyEndpointURLString) else {
return nil
}
self.apiKeyEndpointURL = endpointURL
guard let apiKeyEndpointRegionString = jsonObject[JSONKeys.apiKeyEndpointRegion] as? String else {
return nil
}
self.apiKeyEndpointRegion = apiKeyEndpointRegionString.aws_regionTypeValue()
guard let cognitoPoolId = jsonObject[JSONKeys.cognitoPoolId] as? String else {
return nil
}
self.cognitoPoolId = cognitoPoolId
guard let cognitoPoolRegionString = jsonObject[JSONKeys.cognitoPoolRegion] as? String else {
return nil
}
self.cognitoPoolRegion = cognitoPoolRegionString.aws_regionTypeValue()
guard let cognitoPoolEndpointURLString = jsonObject[JSONKeys.cognitoPoolEndpointURL] as? String,
let cognitoPoolEndpointURL = URL(string: cognitoPoolEndpointURLString) else {
return nil
}
self.cognitoPoolEndpointURL = cognitoPoolEndpointURL
guard let cognitoPoolEndpointRegionString = jsonObject[JSONKeys.cognitoPoolEndpointRegion] as? String else {
return nil
}
self.cognitoPoolEndpointRegion = cognitoPoolEndpointRegionString.aws_regionTypeValue()
guard let apiKeyForCognitoPoolEndpoint = jsonObject[JSONKeys.apiKeyForCognitoPoolEndpoint] as? String else {
return nil
}
self.apiKeyForCognitoPoolEndpoint = apiKeyForCognitoPoolEndpoint
guard let bucketName = jsonObject[JSONKeys.bucketName] as? String else {
return nil
}
self.bucketName = bucketName
guard let bucketRegionString = jsonObject[JSONKeys.bucketRegion] as? String else {
return nil
}
self.bucketRegion = bucketRegionString.aws_regionTypeValue()
self.clientDatabasePrefix = ""
guard let lambdaEndpointRegionString = jsonObject[JSONKeys.lambdaEndpointRegion] as? String else {
return nil
}
self.lambdaEndpointRegion = lambdaEndpointRegionString.aws_regionTypeValue()
guard let lambdaEndpointString = jsonObject[JSONKeys.lambdaEndpointURL] as? String,
let lambdaEndpoint = URL(string: lambdaEndpointString) else {
return nil
}
self.lambdaEndpointURL = lambdaEndpoint
}