# Generated by `mix github.gen` from docs/github-api/api.github.com.json.
# Do not edit by hand; re-run the task instead.
defmodule Noizu.Github.Api.Projects do
@moduledoc """
GitHub `projects` API.
"""
import Noizu.Github
@doc """
Add a field to an organization-owned project.
@see https://docs.github.com/rest/projects/fields#add-a-field-to-an-organization-owned-project
"""
def add_field_for_org(project_number, org, body, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/fields"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2Field, options)
end
@doc """
Add field to user owned project
@see https://docs.github.com/rest/projects/fields#add-field-to-user-owned-project
"""
def add_field_for_user(username, project_number, body, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}/fields"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2Field, options)
end
@doc """
Add item to organization owned project
@see https://docs.github.com/rest/projects/items#add-item-to-organization-owned-project
"""
def add_item_for_org(org, project_number, body, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/items"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2ItemSimple, options)
end
@doc """
Add item to user owned project
@see https://docs.github.com/rest/projects/items#add-item-to-user-owned-project
"""
def add_item_for_user(username, project_number, body, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}/items"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2ItemSimple, options)
end
@doc """
Create draft item for user owned project
@see https://docs.github.com/rest/projects/drafts#create-draft-item-for-user-owned-project
"""
def create_draft_item_for_authenticated_user(user_id, project_number, body, options \\ nil) do
url = github_base() <> "/user/#{user_id}/projectsV2/#{project_number}/drafts"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2ItemSimple, options)
end
@doc """
Create draft item for organization owned project
@see https://docs.github.com/rest/projects/drafts#create-draft-item-for-organization-owned-project
"""
def create_draft_item_for_org(org, project_number, body, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/drafts"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2ItemSimple, options)
end
@doc """
Create a view for an organization-owned project
@see https://docs.github.com/rest/projects/views#create-a-view-for-an-organization-owned-project
"""
def create_view_for_org(org, project_number, body, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/views"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2View, options)
end
@doc """
Create a view for a user-owned project
@see https://docs.github.com/rest/projects/views#create-a-view-for-a-user-owned-project
"""
def create_view_for_user(user_id, project_number, body, options \\ nil) do
url = github_base() <> "/users/#{user_id}/projectsV2/#{project_number}/views"
body = body
api_call(:post, url, body, Noizu.Github.ProjectsV2View, options)
end
@doc """
Delete project item for organization
@see https://docs.github.com/rest/projects/items#delete-project-item-for-organization
"""
def delete_item_for_org(project_number, org, item_id, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/items/#{item_id}"
body = %{}
api_call(:delete, url, body, Noizu.Github.Raw, options)
end
@doc """
Delete project item for user
@see https://docs.github.com/rest/projects/items#delete-project-item-for-user
"""
def delete_item_for_user(project_number, username, item_id, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}/items/#{item_id}"
body = %{}
api_call(:delete, url, body, Noizu.Github.Raw, options)
end
@doc """
Get project field for organization
@see https://docs.github.com/rest/projects/fields#get-project-field-for-organization
"""
def get_field_for_org(project_number, field_id, org, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/fields/#{field_id}"
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2Field, options)
end
@doc """
Get project field for user
@see https://docs.github.com/rest/projects/fields#get-project-field-for-user
"""
def get_field_for_user(project_number, field_id, username, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}/fields/#{field_id}"
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2Field, options)
end
@doc """
Get project for organization
@see https://docs.github.com/rest/projects/projects#get-project-for-organization
"""
def get_for_org(project_number, org, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}"
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2, options)
end
@doc """
Get project for user
@see https://docs.github.com/rest/projects/projects#get-project-for-user
"""
def get_for_user(project_number, username, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}"
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2, options)
end
@doc """
Get an item for an organization owned project
@see https://docs.github.com/rest/projects/items#get-an-item-for-an-organization-owned-project
"""
def get_org_item(project_number, org, item_id, options \\ nil) do
url =
(
query =
[
get_field(:fields, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/items/#{item_id}" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2ItemWithContent, options)
end
@doc """
Get an item for a user owned project
@see https://docs.github.com/rest/projects/items#get-an-item-for-a-user-owned-project
"""
def get_user_item(project_number, username, item_id, options \\ nil) do
url =
(
query =
[
get_field(:fields, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/users/#{username}/projectsV2/#{project_number}/items/#{item_id}" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.ProjectsV2ItemWithContent, options)
end
@doc """
List project fields for organization
@see https://docs.github.com/rest/projects/fields#list-project-fields-for-organization
"""
def list_fields_for_org(project_number, org, options \\ nil) do
url =
(
query =
[
get_field(:per_page, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/fields" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2Field, options)
end
@doc """
List project fields for user
@see https://docs.github.com/rest/projects/fields#list-project-fields-for-user
"""
def list_fields_for_user(project_number, username, options \\ nil) do
url =
(
query =
[
get_field(:per_page, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/users/#{username}/projectsV2/#{project_number}/fields" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2Field, options)
end
@doc """
List projects for organization
@see https://docs.github.com/rest/projects/projects#list-projects-for-organization
"""
def list_for_org(org, options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/orgs/#{org}/projectsV2" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2, options)
end
@doc """
List projects for user
@see https://docs.github.com/rest/projects/projects#list-projects-for-user
"""
def list_for_user(username, options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/users/#{username}/projectsV2" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2, options)
end
@doc """
List items for an organization owned project
@see https://docs.github.com/rest/projects/items#list-items-for-an-organization-owned-project
"""
def list_items_for_org(project_number, org, options \\ nil) do
url =
(
query =
[
get_field(:q, options, nil),
get_field(:fields, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/items" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2ItemWithContent, options)
end
@doc """
List items for a user owned project
@see https://docs.github.com/rest/projects/items#list-items-for-a-user-owned-project
"""
def list_items_for_user(project_number, username, options \\ nil) do
url =
(
query =
[
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil),
get_field(:q, options, nil),
get_field(:fields, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/users/#{username}/projectsV2/#{project_number}/items" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2ItemWithContent, options)
end
@doc """
List items for an organization project view
@see https://docs.github.com/rest/projects/items#list-items-for-an-organization-project-view
"""
def list_view_items_for_org(project_number, org, view_number, options \\ nil) do
url =
(
query =
[
get_field(:fields, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <>
"/orgs/#{org}/projectsV2/#{project_number}/views/#{view_number}/items" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2ItemWithContent, options)
end
@doc """
List items for a user project view
@see https://docs.github.com/rest/projects/items#list-items-for-a-user-project-view
"""
def list_view_items_for_user(project_number, username, view_number, options \\ nil) do
url =
(
query =
[
get_field(:fields, options, nil),
get_field(:before, options, nil),
get_field(:after, options, nil),
get_field(:per_page, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <>
"/users/#{username}/projectsV2/#{project_number}/views/#{view_number}/items" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.ProjectsV2ItemWithContent, options)
end
@doc """
Update project item for organization
@see https://docs.github.com/rest/projects/items#update-project-item-for-organization
"""
def update_item_for_org(project_number, org, item_id, body, options \\ nil) do
url = github_base() <> "/orgs/#{org}/projectsV2/#{project_number}/items/#{item_id}"
body = body
api_call(:patch, url, body, Noizu.Github.ProjectsV2ItemWithContent, options)
end
@doc """
Update project item for user
@see https://docs.github.com/rest/projects/items#update-project-item-for-user
"""
def update_item_for_user(project_number, username, item_id, body, options \\ nil) do
url = github_base() <> "/users/#{username}/projectsV2/#{project_number}/items/#{item_id}"
body = body
api_call(:patch, url, body, Noizu.Github.ProjectsV2ItemWithContent, options)
end
end