package com.atlassian.bitbucket.rest.util;

import com.atlassian.bitbucket.comment.Comment;
import com.atlassian.bitbucket.commit.Commit;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.pull.PullRequest;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.user.ApplicationUser;

import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

/**
 * An enumeration of root resource paths for Stash's REST APIs.
 */
public class ResourcePatterns {

    public static final String COMMENT_ID = "commentId";
    public static final String COMMIT_ID = "commitId";
    public static final String PROJECT_KEY = "projectKey";
    public static final String PULL_REQUEST_ID = "pullRequestId";
    public static final String REPOSITORY_SLUG = "repositorySlug";
    public static final String TASK_ID = "taskId";
    public static final String USER_SLUG = "userSlug";

    public static final String COMMENT_ID_PATH = "{" + COMMENT_ID + "}";
    public static final String COMMIT_ID_PATH = "{" + COMMIT_ID + "}";
    public static final String PROJECT_KEY_PATH = "{" + PROJECT_KEY + "}";
    public static final String PULL_REQUEST_ID_PATH = "{" + PULL_REQUEST_ID + "}";
    public static final String REPOSITORY_SLUG_PATH = "{" + REPOSITORY_SLUG + "}";
    public static final String TASK_ID_PATH = "{" + TASK_ID + "}";
    public static final String USER_SLUG_PATH = "{" + USER_SLUG + "}";

    /**
     * The root resource path for {@link Project}-related resources. Resources with {@link Path paths} under this URI
     * can use the {@link Context} annotation to inject the {@link Project} object referenced by the {projectKey} path
     * parameter of the context request.
     */
    public static final String PROJECT_URI = "projects/" + PROJECT_KEY_PATH;
    /**
     * The root resource path for {@link Repository}-related resources. Resources with {@link Path paths} under this URI
     * can use the {@link Context} annotation to inject the {@link Project} and {@link Repository} objects referenced by
     * the {projectKey} and {repositorySlug} path parameters of the context request.
     */
    public static final String REPOSITORY_URI = PROJECT_URI + "/repos/" + REPOSITORY_SLUG_PATH;
    /**
     * The root resource path for {@link Commit Commit}-related resources. Resources
     * with {@link Path paths} under this URI can use the {@link Context} annotation to inject the {@link Project} and
     * {@link Repository} objects referenced by the {projectKey} and {repositorySlug} path parameters of the context
     * request.
     */
    public static final String COMMIT_URI = REPOSITORY_URI + "/commits/" + COMMIT_ID_PATH;
    /**
     * The root resource path for {@link PullRequest}-related resources. Resources with {@link Path paths} under this
     * URI can use the {@link Context} annotation to inject the {@link Project}, {@link Repository} and
     * {@link PullRequest} objects referenced by the {projectKey}, {repositorySlug} and {pullRequestId} path parameters
     * of the context request.
     */
    public static final String PULL_REQUEST_URI = REPOSITORY_URI + "/pull-requests/" + PULL_REQUEST_ID_PATH;

    /**
     * The generic root resource for {@link Comment}-related resources. This needs to be
     * used in combination with either {@link #PROJECT_URI}, or {@link #COMMIT_URI}, to construct a comment root
     * resource for comments associated with the respective "parent" resources. Refer to the documentation of those
     * parent resources for the entities that can be injected using the {@link Context} annotation when using this URI.
     */
    public static final String COMMENT_URI = "/comments";
    /**
     * The root resource for Task-related resources. TODO
     */
    public static final String TASK_URI = "tasks";
    /**
     * The root resource path for {@link ApplicationUser}-related resources. Resources with {@link Path paths} under this URI
     * can use the {@link Context} annotation to inject the {@link ApplicationUser} object referenced by the {username} path
     * parameter of the context request.
     */
    public static final String USER_URI = "users/" + USER_SLUG_PATH;
}
