public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTag() == null) ? 0 : getTag().hashCode()); hashCode = prime * hashCode + ((getResourceName() == null) ? 0 : getResourceName().hashCode()); hashCode = prime * hashCode + ((getResourceType() == null) ? 0 : getResourceType().hashCode()); return hashCode; }
/** * <p> * The value for the resource tag. * </p> * * @param value * The value for the resource tag. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withValue(String value) { setValue(value); return this; }
/** * <p> * The key, or name, for the resource tag. * </p> * * @param key * The key, or name, for the resource tag. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withKey(String key) { setKey(key); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof TaggedResource == false) return false; TaggedResource other = (TaggedResource) obj; if (other.getTag() == null ^ this.getTag() == null) return false; if (other.getTag() != null && other.getTag().equals(this.getTag()) == false) return false; if (other.getResourceName() == null ^ this.getResourceName() == null) return false; if (other.getResourceName() != null && other.getResourceName().equals(this.getResourceName()) == false) return false; if (other.getResourceType() == null ^ this.getResourceType() == null) return false; if (other.getResourceType() != null && other.getResourceType().equals(this.getResourceType()) == false) return false; return true; }
/** * <p> * The value for the resource tag. * </p> * * @param value * The value for the resource tag. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withValue(String value) { setValue(value); return this; }
/** * <p> * The key, or name, for the resource tag. * </p> * * @param key * The key, or name, for the resource tag. * @return Returns a reference to this object so that method calls can be chained together. */ public Tag withKey(String key) { setKey(key); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof TaggedResource == false) return false; TaggedResource other = (TaggedResource) obj; if (other.getTag() == null ^ this.getTag() == null) return false; if (other.getTag() != null && other.getTag().equals(this.getTag()) == false) return false; if (other.getResourceName() == null ^ this.getResourceName() == null) return false; if (other.getResourceName() != null && other.getResourceName().equals(this.getResourceName()) == false) return false; if (other.getResourceType() == null ^ this.getResourceType() == null) return false; if (other.getResourceType() != null && other.getResourceType().equals(this.getResourceType()) == false) return false; return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Tag == false) return false; Tag other = (Tag) obj; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; return true; }
/** * * @param resourceId * @param clientMap * @param pacTag * @return */ private Boolean setRedshiftTag(final String resourceId, final Map<String, Object> clientMap, Map<String, String> pacTag) { com.amazonaws.services.redshift.model.Tag tag = new com.amazonaws.services.redshift.model.Tag(); for (Map.Entry<String, String> tags : pacTag.entrySet()) { tag.setKey(tags.getKey()); tag.setValue(tags.getValue()); } AmazonRedshift amazonRedshift = (AmazonRedshift) clientMap .get("client"); com.amazonaws.services.redshift.model.CreateTagsRequest createTagsRequest = new com.amazonaws.services.redshift.model.CreateTagsRequest(); createTagsRequest.setResourceName(resourceId); createTagsRequest.setTags(Arrays.asList(tag)); try { amazonRedshift.createTags(createTagsRequest); return Boolean.TRUE; } catch (AmazonServiceException ase) { logger.error("error tagging redshift - > " + resourceId, ase); throw ase; } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTag() == null) ? 0 : getTag().hashCode()); hashCode = prime * hashCode + ((getResourceName() == null) ? 0 : getResourceName().hashCode()); hashCode = prime * hashCode + ((getResourceType() == null) ? 0 : getResourceType().hashCode()); return hashCode; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKey() != null) sb.append("Key: ").append(getKey()).append(","); if (getValue() != null) sb.append("Value: ").append(getValue()); sb.append("}"); return sb.toString(); }
public Tag unmarshall(StaxUnmarshallerContext context) throws Exception { Tag tag = new Tag(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return tag; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Key", targetDepth)) { tag.setKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Value", targetDepth)) { tag.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return tag; } } } }
public Request<CreateTagsRequest> marshall(CreateTagsRequest createTagsRequest) { if (createTagsRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreateTagsRequest> request = new DefaultRequest<CreateTagsRequest>(createTagsRequest, "AmazonRedshift"); request.addParameter("Action", "CreateTags"); request.addParameter("Version", "2012-12-01"); request.setHttpMethod(HttpMethodName.POST); if (createTagsRequest.getResourceName() != null) { request.addParameter("ResourceName", StringUtils.fromString(createTagsRequest.getResourceName())); } if (!createTagsRequest.getTags().isEmpty() || !((com.amazonaws.internal.SdkInternalList<Tag>) createTagsRequest.getTags()).isAutoConstruct()) { com.amazonaws.internal.SdkInternalList<Tag> tagsList = (com.amazonaws.internal.SdkInternalList<Tag>) createTagsRequest.getTags(); int tagsListIndex = 1; for (Tag tagsListValue : tagsList) { if (tagsListValue.getKey() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); } if (tagsListValue.getValue() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue())); } tagsListIndex++; } } return request; }
public Request<CreateHsmClientCertificateRequest> marshall(CreateHsmClientCertificateRequest createHsmClientCertificateRequest) { if (createHsmClientCertificateRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreateHsmClientCertificateRequest> request = new DefaultRequest<CreateHsmClientCertificateRequest>(createHsmClientCertificateRequest, "AmazonRedshift"); request.addParameter("Action", "CreateHsmClientCertificate"); request.addParameter("Version", "2012-12-01"); request.setHttpMethod(HttpMethodName.POST); if (createHsmClientCertificateRequest.getHsmClientCertificateIdentifier() != null) { request.addParameter("HsmClientCertificateIdentifier", StringUtils.fromString(createHsmClientCertificateRequest.getHsmClientCertificateIdentifier())); } if (!createHsmClientCertificateRequest.getTags().isEmpty() || !((com.amazonaws.internal.SdkInternalList<Tag>) createHsmClientCertificateRequest.getTags()).isAutoConstruct()) { com.amazonaws.internal.SdkInternalList<Tag> tagsList = (com.amazonaws.internal.SdkInternalList<Tag>) createHsmClientCertificateRequest.getTags(); int tagsListIndex = 1; for (Tag tagsListValue : tagsList) { if (tagsListValue.getKey() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); } if (tagsListValue.getValue() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue())); } tagsListIndex++; } } return request; }
public Request<CreateSnapshotCopyGrantRequest> marshall(CreateSnapshotCopyGrantRequest createSnapshotCopyGrantRequest) { if (createSnapshotCopyGrantRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreateSnapshotCopyGrantRequest> request = new DefaultRequest<CreateSnapshotCopyGrantRequest>(createSnapshotCopyGrantRequest, "AmazonRedshift"); request.addParameter("Action", "CreateSnapshotCopyGrant"); request.addParameter("Version", "2012-12-01"); request.setHttpMethod(HttpMethodName.POST); if (createSnapshotCopyGrantRequest.getSnapshotCopyGrantName() != null) { request.addParameter("SnapshotCopyGrantName", StringUtils.fromString(createSnapshotCopyGrantRequest.getSnapshotCopyGrantName())); } if (createSnapshotCopyGrantRequest.getKmsKeyId() != null) { request.addParameter("KmsKeyId", StringUtils.fromString(createSnapshotCopyGrantRequest.getKmsKeyId())); } if (!createSnapshotCopyGrantRequest.getTags().isEmpty() || !((com.amazonaws.internal.SdkInternalList<Tag>) createSnapshotCopyGrantRequest.getTags()).isAutoConstruct()) { com.amazonaws.internal.SdkInternalList<Tag> tagsList = (com.amazonaws.internal.SdkInternalList<Tag>) createSnapshotCopyGrantRequest.getTags(); int tagsListIndex = 1; for (Tag tagsListValue : tagsList) { if (tagsListValue.getKey() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Key", StringUtils.fromString(tagsListValue.getKey())); } if (tagsListValue.getValue() != null) { request.addParameter("Tags.Tag." + tagsListIndex + ".Value", StringUtils.fromString(tagsListValue.getValue())); } tagsListIndex++; } } return request; }