Example usage for java.net HttpURLConnection HTTP_PRECON_FAILED

List of usage examples for java.net HttpURLConnection HTTP_PRECON_FAILED

Introduction

In this page you can find the example usage for java.net HttpURLConnection HTTP_PRECON_FAILED.

Prototype

int HTTP_PRECON_FAILED

To view the source code for java.net HttpURLConnection HTTP_PRECON_FAILED.

Click Source Link

Document

HTTP Status-Code 412: Precondition Failed.

Usage

From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java

/**
 * Add new tags to a given application.//  w w  w .  j  a va  2  s  .  c  o  m
 *
 * @param id   The id of the application to add the tags to. Not
 *             null/empty/blank.
 * @param tags The tags to add. Not null/empty/blank.
 * @return The active tags for this application.
 * @throws GenieException For any error
 */
@POST
@Path("/{id}/tags")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Add new tags to a application", notes = "Add the supplied tags to the application with the supplied id.", response = String.class, responseContainer = "List")
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> addTagsForApplication(
        @ApiParam(value = "Id of the application to add configuration to.", required = true) @PathParam("id") final String id,
        @ApiParam(value = "The tags to add.", required = true) final Set<String> tags) throws GenieException {
    LOG.info("Called with id " + id + " and config " + tags);
    return this.applicationConfigService.addTagsForApplication(id, tags);
}

From source file:com.netflix.genie.server.resources.ClusterConfigResource.java

/**
 * Add new tags to a given cluster.//from ww  w  .j  a v  a2 s. c o m
 *
 * @param id   The id of the cluster to add the tags to. Not
 *             null/empty/blank.
 * @param tags The tags to add. Not null/empty/blank.
 * @return The active tags for this cluster.
 * @throws GenieException For any error
 */
@POST
@Path("/{id}/tags")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Add new tags to a cluster", notes = "Add the supplied tags to the cluster with the supplied id.", response = String.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Cluster not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> addTagsForCluster(
        @ApiParam(value = "Id of the cluster to add configuration to.", required = true) @PathParam("id") final String id,
        @ApiParam(value = "The tags to add.", required = true) final Set<String> tags) throws GenieException {
    LOG.info("Called with id " + id + " and tags " + tags);
    return this.clusterConfigService.addTagsForCluster(id, tags);
}

From source file:com.netflix.genie.server.resources.CommandConfigResource.java

/**
 * Get the application configured for a given command.
 *
 * @param id The id of the command to get the application files for. Not
 *           NULL/empty/blank./*from   www . j a  va2 s . c  o m*/
 * @return The active application for the command.
 * @throws GenieException For any error
 */
@GET
@Path("/{id}/application")
@ApiOperation(value = "Get the application for a command", notes = "Get the application for the command with the supplied id.", response = Application.class)
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Application getApplicationForCommand(
        @ApiParam(value = "Id of the command to get the application for.", required = true) @PathParam("id") final String id)
        throws GenieException {
    LOG.info("Called with id " + id);
    return this.commandConfigService.getApplicationForCommand(id);
}

From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java

/**
 * Get all the tags for a given application.
 *
 * @param id The id of the application to get the tags for. Not
 *           NULL/empty/blank./* ww w  . ja v  a2s.co  m*/
 * @return The active set of tags.
 * @throws GenieException For any error
 */
@GET
@Path("/{id}/tags")
@ApiOperation(value = "Get the tags for a application", notes = "Get the tags for the application with the supplied id.", response = String.class, responseContainer = "List")
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> getTagsForApplication(
        @ApiParam(value = "Id of the application to get tags for.", required = true) @PathParam("id") final String id)
        throws GenieException {
    LOG.info("Called with id " + id);
    return this.applicationConfigService.getTagsForApplication(id);
}

From source file:com.netflix.genie.server.resources.CommandConfigResource.java

/**
 * Remove the application from a given command.
 *
 * @param id The id of the command to delete the application from. Not
 *           null/empty/blank./*from www  . ja v  a  2 s  .  com*/
 * @return The active set of applications for the command.
 * @throws GenieException For any error
 */
@DELETE
@Path("/{id}/application")
@ApiOperation(value = "Remove an application from a command", notes = "Remove the application from the command with given id.", response = Application.class)
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Application removeApplicationForCommand(
        @ApiParam(value = "Id of the command to delete from.", required = true) @PathParam("id") final String id)
        throws GenieException {
    LOG.info("Called with id '" + id + "'.");
    return this.commandConfigService.removeApplicationForCommand(id);
}

From source file:com.netflix.genie.server.resources.ClusterConfigResource.java

/**
 * Get all the tags for a given cluster.
 *
 * @param id The id of the cluster to get the tags for. Not
 *           NULL/empty/blank.//from   w  w  w. j  a  va  2  s. c  om
 * @return The active set of tags.
 * @throws GenieException For any error
 */
@GET
@Path("/{id}/tags")
@ApiOperation(value = "Get the tags for a cluster", notes = "Get the tags for the cluster with the supplied id.", response = String.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Cluster not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> getTagsForCluster(
        @ApiParam(value = "Id of the cluster to get tags for.", required = true) @PathParam("id") final String id)
        throws GenieException {
    LOG.info("Called with id " + id);
    return this.clusterConfigService.getTagsForCluster(id);
}

From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java

/**
 * Update the tags for a given application.
 *
 * @param id   The id of the application to update the tags for.
 *             Not null/empty/blank./*from  ww w.  ja v  a2s . c  o  m*/
 * @param tags The tags to replace existing configuration
 *             files with. Not null/empty/blank.
 * @return The new set of application tags.
 * @throws GenieException For any error
 */
@PUT
@Path("/{id}/tags")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update tags for a application", notes = "Replace the existing tags for application with given id.", response = String.class, responseContainer = "List")
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> updateTagsForApplication(
        @ApiParam(value = "Id of the application to update tags for.", required = true) @PathParam("id") final String id,
        @ApiParam(value = "The tags to replace existing with.", required = true) final Set<String> tags)
        throws GenieException {
    LOG.info("Called with id " + id + " and tags " + tags);
    return this.applicationConfigService.updateTagsForApplication(id, tags);
}

From source file:com.netflix.genie.server.resources.CommandConfigResource.java

/**
 * Get all the clusters this command is associated with.
 *
 * @param id       The id of the command to get the clusters for. Not
 *                 NULL/empty/blank.//from  w w  w  .  ja  va2s.  c  o m
 * @param statuses The statuses of the clusters to get
 * @return The list of clusters.
 * @throws GenieException For any error
 */
@GET
@Path("/{id}/clusters")
@ApiOperation(value = "Get the clusters this command is associated with", notes = "Get the clusters which this command exists on supports.", response = Cluster.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public List<Cluster> getClustersForCommand(
        @ApiParam(value = "Id of the command to get the clusters for.", required = true) @PathParam("id") final String id,
        @ApiParam(value = "Status of the cluster.", allowableValues = "UP, OUT_OF_SERVICE, TERMINATED") @QueryParam("status") final Set<String> statuses)
        throws GenieException {
    LOG.info("Called with id " + id + " and statuses " + statuses);

    Set<ClusterStatus> enumStatuses = null;
    if (!statuses.isEmpty()) {
        enumStatuses = EnumSet.noneOf(ClusterStatus.class);
        for (final String status : statuses) {
            if (StringUtils.isNotBlank(status)) {
                enumStatuses.add(ClusterStatus.parse(status));
            }
        }
    }

    return this.commandConfigService.getClustersForCommand(id, enumStatuses);
}

From source file:com.netflix.genie.server.resources.ClusterConfigResource.java

/**
 * Update the tags for a given cluster.// w w  w  . j  av a  2 s  .  com
 *
 * @param id   The id of the cluster to update the tags for.
 *             Not null/empty/blank.
 * @param tags The tags to replace existing configuration
 *             files with. Not null/empty/blank.
 * @return The new set of cluster tags.
 * @throws GenieException For any error
 */
@PUT
@Path("/{id}/tags")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update tags for a cluster", notes = "Replace the existing tags for cluster with given id.", response = String.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Cluster not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> updateTagsForCluster(
        @ApiParam(value = "Id of the cluster to update tags for.", required = true) @PathParam("id") final String id,
        @ApiParam(value = "The tags to replace existing with.", required = true) final Set<String> tags)
        throws GenieException {
    LOG.info("Called with id " + id + " and tags " + tags);
    return this.clusterConfigService.updateTagsForCluster(id, tags);
}

From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java

/**
 * Delete the all tags from a given application.
 *
 * @param id The id of the application to delete the tags from.
 *           Not null/empty/blank.//from   w  ww . j a  va2 s .co  m
 * @return Empty set if successful
 * @throws GenieException For any error
 */
@DELETE
@Path("/{id}/tags")
@ApiOperation(value = "Remove all tags from a application", notes = "Remove all the tags from the application with given id.  Note that the genie name space tags"
        + "prefixed with genie.id and genie.name cannot be deleted.", response = String.class, responseContainer = "List")
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"),
        @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"),
        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") })
public Set<String> removeAllTagsForApplication(
        @ApiParam(value = "Id of the application to delete from.", required = true) @PathParam("id") final String id)
        throws GenieException {
    LOG.info("Called with id " + id);
    return this.applicationConfigService.removeAllTagsForApplication(id);
}