public Request<CreateIdentityPoolRequest> marshall( CreateIdentityPoolRequest createIdentityPoolRequest) { if (createIdentityPoolRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateIdentityPoolRequest> request = new DefaultRequest<CreateIdentityPoolRequest>( createIdentityPoolRequest, "AmazonCognitoIdentity"); String target = "AWSCognitoIdentityService.CreateIdentityPool"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (createIdentityPoolRequest.getIdentityPoolName() != null) { jsonWriter.key("IdentityPoolName").value(createIdentityPoolRequest.getIdentityPoolName()); } if (createIdentityPoolRequest.isAllowUnauthenticatedIdentities() != null) { jsonWriter .key("AllowUnauthenticatedIdentities") .value(createIdentityPoolRequest.isAllowUnauthenticatedIdentities()); } if (createIdentityPoolRequest.getSupportedLoginProviders() != null) { jsonWriter.key("SupportedLoginProviders"); jsonWriter.object(); for (Map.Entry<String, String> supportedLoginProvidersListValue : createIdentityPoolRequest.getSupportedLoginProviders().entrySet()) { if (supportedLoginProvidersListValue.getValue() != null) { jsonWriter.key(supportedLoginProvidersListValue.getKey()); jsonWriter.value(supportedLoginProvidersListValue.getValue()); } } jsonWriter.endObject(); } jsonWriter.endObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", "application/x-amz-json-1.0"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
public Request<SetIdentityPoolRolesRequest> marshall( SetIdentityPoolRolesRequest setIdentityPoolRolesRequest) { if (setIdentityPoolRolesRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<SetIdentityPoolRolesRequest> request = new DefaultRequest<SetIdentityPoolRolesRequest>( setIdentityPoolRolesRequest, "AmazonCognitoIdentity"); request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.SetIdentityPoolRoles"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (setIdentityPoolRolesRequest.getIdentityPoolId() != null) { jsonWriter.key("IdentityPoolId").value(setIdentityPoolRolesRequest.getIdentityPoolId()); } java.util.Map<String, String> rolesMap = setIdentityPoolRolesRequest.getRoles(); if (rolesMap != null) { jsonWriter.key("Roles"); jsonWriter.object(); for (Map.Entry<String, String> rolesMapValue : rolesMap.entrySet()) { if (rolesMapValue.getValue() != null) { jsonWriter.key(rolesMapValue.getKey()); jsonWriter.value(rolesMapValue.getValue()); } } jsonWriter.endObject(); } jsonWriter.endObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", "application/x-amz-json-1.1"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }