All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.genie.client.apis.ApplicationService Maven / Gradle / Ivy

There is a newer version: 4.3.20
Show newest version
/*
 *
 *  Copyright 2016 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
package com.netflix.genie.client.apis;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonpatch.JsonPatch;
import com.netflix.genie.common.dto.Application;
import com.netflix.genie.common.dto.Command;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

import java.util.List;
import java.util.Set;

/**
 * An interface that provides all methods needed for the Genie application client implementation.
 *
 * @author amsharma
 * @since 3.0.0
 */
public interface ApplicationService {

    /**
     * Path to Applications.
     */
    String APPLICATION_URL_SUFFIX = "/api/v3/applications";

    /******************* CRUD Methods   ***************************/

    /**
     * Method to create a application in Genie.
     *
     * @param application The application object.
     * @return A callable object.
     */
    @POST(APPLICATION_URL_SUFFIX)
    Call createApplication(@Body Application application);

    /**
     * Method to update a application in Genie.
     *
     * @param applicationId The id of the application to update.
     * @param application   The application object.
     * @return A callable object.
     */
    @PUT(APPLICATION_URL_SUFFIX + "/{id}")
    Call updateApplication(@Path("id") String applicationId, @Body Application application);

    /**
     * Method to get all applications from Genie.
     *
     * @param name       The name of the commands.
     * @param user       The user who created the command.
     * @param statusList The list of Command statuses.
     * @param tagList    The list of tags.
     * @param type       The type of the application.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX)
    Call getApplications(
        @Query("name") String name,
        @Query("user") String user,
        @Query("status") List statusList,
        @Query("tag") List tagList,
        @Query("type") String type
    );

    /**
     * Method to fetch a single job from Genie.
     *
     * @param applicationId The id of the application to get.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX + "/{id}")
    Call getApplication(@Path("id") String applicationId);

    /**
     * Method to delete a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX + "/{id}")
    Call deleteApplication(@Path("id") String applicationId);

    /**
     * Method to delete all applications in Genie.
     *
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX)
    Call deleteAllApplications();

    /**
     * Patch a application using JSON Patch.
     *
     * @param applicationId The id of the application to patch
     * @param patch         The JSON Patch instructions
     * @return A callable object.
     */
    @PATCH(APPLICATION_URL_SUFFIX + "/{id}")
    Call patchApplication(@Path("id") String applicationId, @Body JsonPatch patch);

    /**
     * Method to get commmands for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX + "/{id}/commands")
    Call> getCommandsForApplication(@Path("id") String applicationId);

    /****************** Methods to manipulate dependencies for a application   *********************/

    /**
     * Method to get dependency files for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX + "/{id}/dependencies")
    Call> getDependenciesForApplication(@Path("id") String applicationId);

    /**
     * Method to add dependencies to a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param dependencies  The dependencies to be added.
     * @return A callable object.
     */
    @POST(APPLICATION_URL_SUFFIX + "/{id}/dependencies")
    Call addDependenciesToApplication(
        @Path("id") String applicationId,
        @Body Set dependencies
    );

    /**
     * Method to update dependencies for a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param dependencies  The dependencies to be added.
     * @return A callable object.
     */
    @PUT(APPLICATION_URL_SUFFIX + "/{id}/dependencies")
    Call updateDependenciesForApplication(
        @Path("id") String applicationId,
        @Body Set dependencies
    );

    /**
     * Method to delete all dependencies for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX + "/{id}/dependencies")
    Call removeAllDependenciesForApplication(@Path("id") String applicationId);

    /****************** Methods to manipulate configs for a application   *********************/

    /**
     * Method to get configs for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX + "/{id}/configs")
    Call> getConfigsForApplication(@Path("id") String applicationId);

    /**
     * Method to add configs to a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param configs       The configs to be added.
     * @return A callable object.
     */
    @POST(APPLICATION_URL_SUFFIX + "/{id}/configs")
    Call addConfigsToApplication(@Path("id") String applicationId, @Body Set configs);

    /**
     * Method to update configs for a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param configs       The configs to be added.
     * @return A callable object.
     */
    @PUT(APPLICATION_URL_SUFFIX + "/{id}/configs")
    Call updateConfigsForApplication(@Path("id") String applicationId, @Body Set configs);

    /**
     * Method to delete all configs for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX + "/{id}/configs")
    Call removeAllConfigsForApplication(@Path("id") String applicationId);

    /****************** Methods to manipulate tags for a application   *********************/

    /**
     * Method to get tags for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @GET(APPLICATION_URL_SUFFIX + "/{id}/tags")
    Call> getTagsForApplication(@Path("id") String applicationId);

    /**
     * Method to add tags to a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param tags          The tags to be added.
     * @return A callable object.
     */
    @POST(APPLICATION_URL_SUFFIX + "/{id}/tags")
    Call addTagsToApplication(@Path("id") String applicationId, @Body Set tags);

    /**
     * Method to update tags for a application in Genie.
     *
     * @param applicationId The id of the application..
     * @param tags          The tags to be added.
     * @return A callable object.
     */
    @PUT(APPLICATION_URL_SUFFIX + "/{id}/tags")
    Call updateTagsForApplication(@Path("id") String applicationId, @Body Set tags);

    /**
     * Method to delete a tag for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @param tag           The tag to delete.
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX + "/{id}/tags/{tag}")
    Call removeTagForApplication(@Path("id") String applicationId, @Path("tag") String tag);

    /**
     * Method to delete all tags for a application in Genie.
     *
     * @param applicationId The id of the application.
     * @return A callable object.
     */
    @DELETE(APPLICATION_URL_SUFFIX + "/{id}/tags")
    Call removeAllTagsForApplication(@Path("id") String applicationId);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy