internal static CognitoClientContext FromJson(string json) { var result = new CognitoClientContext(); if (!string.IsNullOrWhiteSpace(json)) { var jsonData = JsonDocument.Parse(json).RootElement; if (jsonData.TryGetProperty("client", out var clientElement)) { result.Client = CognitoClientApplication.FromJsonData(clientElement); } if (jsonData.TryGetProperty("custom", out var customElement)) { result.Custom = GetDictionaryFromJsonData(customElement); } if (jsonData.TryGetProperty("env", out var envElement)) { result.Environment = GetDictionaryFromJsonData(envElement); } return(result); } return(result); }
public LambdaContext(RuntimeApiHeaders runtimeApiHeaders, LambdaEnvironment lambdaEnvironment) { _lambdaEnvironment = lambdaEnvironment; _runtimeApiHeaders = runtimeApiHeaders; int.TryParse(_lambdaEnvironment.FunctionMemorySize, out _memoryLimitInMB); long.TryParse(_runtimeApiHeaders.DeadlineMs, out _deadlineMs); _cognitoIdentityLazy = new Lazy <CognitoIdentity>(() => CognitoIdentity.FromJson(runtimeApiHeaders.CognitoIdentityJson)); _cognitoClientContextLazy = new Lazy <CognitoClientContext>(() => CognitoClientContext.FromJson(runtimeApiHeaders.ClientContextJson)); // set environment variable so that if the function uses the XRay client it will work correctly _lambdaEnvironment.SetXAmznTraceId(_runtimeApiHeaders.TraceId); }
internal static CognitoClientContext FromJson(string json) { var result = new CognitoClientContext(); if (!string.IsNullOrWhiteSpace(json)) { var jsonData = JsonMapper.ToObject(json); if (jsonData["client"] != null) { result.Client = CognitoClientApplication.FromJsonData(jsonData["client"]); } if (jsonData["custom"] != null) { result.Custom = GetDictionaryFromJsonData(jsonData["custom"]); } if (jsonData["env"] != null) { result.Environment = GetDictionaryFromJsonData(jsonData["env"]); } } return(result); }