@TimedResource
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Create a tag definition", response = TagDefinitionJson.class)
@ApiResponses(value = {@ApiResponse(code = 201, message = "Tag definition created successfully"),
@ApiResponse(code = 400, message = "Invalid name or description supplied")})
public Response createTagDefinition(final TagDefinitionJson json,
@HeaderParam(HDR_CREATED_BY) final String createdBy,
@HeaderParam(HDR_REASON) final String reason,
@HeaderParam(HDR_COMMENT) final String comment,
@javax.ws.rs.core.Context final HttpServletRequest request,
@javax.ws.rs.core.Context final UriInfo uriInfo) throws TagDefinitionApiException {
verifyNonNullOrEmpty(json, "TagDefinitionJson body should be specified");
verifyNonNullOrEmpty(json.getName(), "TagDefinition name needs to be set",
json.getDescription(), "TagDefinition description needs to be set");
Preconditions.checkArgument(json.getApplicableObjectTypes() != null &&
!json.getApplicableObjectTypes().isEmpty(), "Applicable object types must be set");
final TagDefinition createdTagDef = tagUserApi.createTagDefinition(json.getName(), json.getDescription(), json.getApplicableObjectTypes(), context.createCallContextNoAccountId(createdBy, reason, comment, request));
return uriBuilder.buildResponse(uriInfo, TagDefinitionResource.class, "getTagDefinition", createdTagDef.getId(), request);
}