# 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.Billing do @moduledoc """ GitHub `billing` API. """ import Noizu.Github @doc """ Create a budget for an organization @see https://docs.github.com/rest/billing/budgets#create-a-budget-for-an-organization """ def create_organization_budget(org, body, options \\ nil) do url = github_base() <> "/organizations/#{org}/settings/billing/budgets" body = body api_call(:post, url, body, Noizu.Github.CreateBudget, options) end @doc """ Delete a budget for an organization @see https://docs.github.com/rest/billing/budgets#delete-a-budget-for-an-organization """ def delete_budget_org(org, budget_id, options \\ nil) do url = github_base() <> "/organizations/#{org}/settings/billing/budgets/#{budget_id}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Get all budgets for an organization @see https://docs.github.com/rest/billing/budgets#get-all-budgets-for-an-organization """ def get_all_budgets_org(org, options \\ nil) do url = ( query = [ get_field(:page, options, nil), get_field(:per_page, options, nil), get_field(:scope, options, nil), get_field(:user, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/organizations/#{org}/settings/billing/budgets" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get a budget by ID for an organization @see https://docs.github.com/rest/billing/budgets#get-a-budget-by-id-for-an-organization """ def get_budget_org(org, budget_id, options \\ nil) do url = github_base() <> "/organizations/#{org}/settings/billing/budgets/#{budget_id}" body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing AI credit usage report for an organization @see https://docs.github.com/rest/billing/usage#get-billing-ai-credit-usage-report-for-an-organization """ def get_github_billing_ai_credit_usage_report_org(org, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:user, options, nil), get_field(:model, options, nil), get_field(:product, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/organizations/#{org}/settings/billing/ai_credit/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing AI credit usage report for a user @see https://docs.github.com/rest/billing/usage#get-billing-ai-credit-usage-report-for-a-user """ def get_github_billing_ai_credit_usage_report_user(username, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:model, options, nil), get_field(:product, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/users/#{username}/settings/billing/ai_credit/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing premium request usage report for an organization @see https://docs.github.com/rest/billing/usage#get-billing-premium-request-usage-report-for-an-organization """ def get_github_billing_premium_request_usage_report_org(org, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:user, options, nil), get_field(:model, options, nil), get_field(:product, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/organizations/#{org}/settings/billing/premium_request/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing premium request usage report for a user @see https://docs.github.com/rest/billing/usage#get-billing-premium-request-usage-report-for-a-user """ def get_github_billing_premium_request_usage_report_user(username, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:model, options, nil), get_field(:product, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/users/#{username}/settings/billing/premium_request/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing usage report for an organization @see https://docs.github.com/rest/billing/usage#get-billing-usage-report-for-an-organization """ def get_github_billing_usage_report_org(org, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/organizations/#{org}/settings/billing/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing usage report for a user @see https://docs.github.com/rest/billing/usage#get-billing-usage-report-for-a-user """ def get_github_billing_usage_report_user(username, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/users/#{username}/settings/billing/usage" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing usage summary for an organization @see https://docs.github.com/rest/billing/usage#get-billing-usage-summary-for-an-organization """ def get_github_billing_usage_summary_report_org(org, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:repository, options, nil), get_field(:product, options, nil), get_field(:sku, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/organizations/#{org}/settings/billing/usage/summary" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get billing usage summary for a user @see https://docs.github.com/rest/billing/usage#get-billing-usage-summary-for-a-user """ def get_github_billing_usage_summary_report_user(username, options \\ nil) do url = ( query = [ get_field(:year, options, nil), get_field(:month, options, nil), get_field(:day, options, nil), get_field(:repository, options, nil), get_field(:product, options, nil), get_field(:sku, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/users/#{username}/settings/billing/usage/summary" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Update a budget for an organization @see https://docs.github.com/rest/billing/budgets#update-a-budget-for-an-organization """ def update_budget_org(org, budget_id, body, options \\ nil) do url = github_base() <> "/organizations/#{org}/settings/billing/budgets/#{budget_id}" body = body api_call(:patch, url, body, Noizu.Github.UpdateBudget, options) end end