hexsha
stringlengths
40
40
size
int64
2
991k
ext
stringclasses
2 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
208
max_stars_repo_name
stringlengths
6
106
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequence
max_stars_count
int64
1
33.5k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
208
max_issues_repo_name
stringlengths
6
106
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
sequence
max_issues_count
int64
1
16.3k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
208
max_forks_repo_name
stringlengths
6
106
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
sequence
max_forks_count
int64
1
6.91k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
2
991k
avg_line_length
float64
1
36k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
73ec7c1c1a0c873d6941091801aeb1e789f10c8b
448
ex
Elixir
lib/sanbase_web/admin/auth/api_call_limit.ex
santiment/sanbase2
9ef6e2dd1e377744a6d2bba570ea6bd477a1db31
[ "MIT" ]
81
2017-11-20T01:20:22.000Z
2022-03-05T12:04:25.000Z
lib/sanbase_web/admin/auth/api_call_limit.ex
rmoorman/sanbase2
226784ab43a24219e7332c49156b198d09a6dd85
[ "MIT" ]
359
2017-10-15T14:40:53.000Z
2022-01-25T13:34:20.000Z
lib/sanbase_web/admin/auth/api_call_limit.ex
rmoorman/sanbase2
226784ab43a24219e7332c49156b198d09a6dd85
[ "MIT" ]
16
2017-11-19T13:57:40.000Z
2022-02-07T08:13:02.000Z
defmodule SanbaseWeb.ExAdmin.ApiCallLimit do use ExAdmin.Register register_resource Sanbase.ApiCallLimit do index do column(:id) column(:user, link: true) column(:remote_ip) column(:has_limits) column(:api_calls_limit_plan) column(:api_calls) end show acl do attributes_table(all: true) end form acl do inputs do input(acl, :has_limits) end end end end
17.92
44
0.638393
73ec7f7fc2812a8261f05ff7b849cec62fcc55c6
371
exs
Elixir
priv/repo/migrations/20171201141936_add_gravatar_to_emails.exs
Benjamin-Philip/hexpm
6f38244f81bbabd234c660f46ea973849ba77a7f
[ "Apache-2.0" ]
691
2017-03-08T09:15:45.000Z
2022-03-23T22:04:47.000Z
priv/repo/migrations/20171201141936_add_gravatar_to_emails.exs
Benjamin-Philip/hexpm
6f38244f81bbabd234c660f46ea973849ba77a7f
[ "Apache-2.0" ]
491
2017-03-07T12:58:42.000Z
2022-03-29T23:32:54.000Z
priv/repo/migrations/20171201141936_add_gravatar_to_emails.exs
Benjamin-Philip/hexpm
6f38244f81bbabd234c660f46ea973849ba77a7f
[ "Apache-2.0" ]
200
2017-03-12T23:03:39.000Z
2022-03-05T17:55:52.000Z
defmodule Hexpm.Repo.Migrations.AddGravatarToEmails do use Ecto.Migration def up() do alter table(:emails) do add(:gravatar, :boolean, default: false, null: false) end execute(""" UPDATE emails SET gravatar = true WHERE public """) end def down() do alter table(:emails) do remove(:gravatar) end end end
16.863636
59
0.619946
73ecb01b47610d7971394ba77e699b58984a6b5f
3,189
exs
Elixir
projects/standup/test/standup_web/controllers/journal_controller_test.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
1
2020-02-11T06:00:11.000Z
2020-02-11T06:00:11.000Z
projects/standup/test/standup_web/controllers/journal_controller_test.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
1
2017-09-23T19:41:29.000Z
2017-09-25T05:12:38.000Z
projects/standup/test/standup_web/controllers/journal_controller_test.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
null
null
null
defmodule StandupWeb.JournalControllerTest do use StandupWeb.ConnCase alias Standup.Content @create_attrs %{completed_at: "2010-04-17T14:00:00Z", description: "some description", public: true, started_at: "2010-04-17T14:00:00Z", tags: [], title: "some title"} @update_attrs %{completed_at: "2011-05-18T15:01:01Z", description: "some updated description", public: false, started_at: "2011-05-18T15:01:01Z", tags: [], title: "some updated title"} @invalid_attrs %{completed_at: nil, description: nil, public: nil, started_at: nil, tags: nil, title: nil} def fixture(:journal) do {:ok, journal} = Content.create_journal(@create_attrs) journal end describe "index" do test "lists all journals", %{conn: conn} do conn = get(conn, Routes.journal_path(conn, :index)) assert html_response(conn, 200) =~ "Listing Journals" end end describe "new journal" do test "renders form", %{conn: conn} do conn = get(conn, Routes.journal_path(conn, :new)) assert html_response(conn, 200) =~ "New Journal" end end describe "create journal" do test "redirects to show when data is valid", %{conn: conn} do conn = post(conn, Routes.journal_path(conn, :create), journal: @create_attrs) assert %{id: id} = redirected_params(conn) assert redirected_to(conn) == Routes.journal_path(conn, :show, id) conn = get(conn, Routes.journal_path(conn, :show, id)) assert html_response(conn, 200) =~ "Show Journal" end test "renders errors when data is invalid", %{conn: conn} do conn = post(conn, Routes.journal_path(conn, :create), journal: @invalid_attrs) assert html_response(conn, 200) =~ "New Journal" end end describe "edit journal" do setup [:create_journal] test "renders form for editing chosen journal", %{conn: conn, journal: journal} do conn = get(conn, Routes.journal_path(conn, :edit, journal)) assert html_response(conn, 200) =~ "Edit Journal" end end describe "update journal" do setup [:create_journal] test "redirects when data is valid", %{conn: conn, journal: journal} do conn = put(conn, Routes.journal_path(conn, :update, journal), journal: @update_attrs) assert redirected_to(conn) == Routes.journal_path(conn, :show, journal) conn = get(conn, Routes.journal_path(conn, :show, journal)) assert html_response(conn, 200) =~ "some updated description" end test "renders errors when data is invalid", %{conn: conn, journal: journal} do conn = put(conn, Routes.journal_path(conn, :update, journal), journal: @invalid_attrs) assert html_response(conn, 200) =~ "Edit Journal" end end describe "delete journal" do setup [:create_journal] test "deletes chosen journal", %{conn: conn, journal: journal} do conn = delete(conn, Routes.journal_path(conn, :delete, journal)) assert redirected_to(conn) == Routes.journal_path(conn, :index) assert_error_sent 404, fn -> get(conn, Routes.journal_path(conn, :show, journal)) end end end defp create_journal(_) do journal = fixture(:journal) {:ok, journal: journal} end end
35.831461
186
0.678269
73ecb8ede9ed119ab9002b86880ecccd999ec2a8
424
exs
Elixir
elixir_backend/migrations/20210607193148_create_rooms.exs
yusufaine/nus-clubhouse
eae8223d26111bab5e981c95b539c964293908e8
[ "MIT" ]
1
2021-05-16T08:17:37.000Z
2021-05-16T08:17:37.000Z
elixir_backend/migrations/20210607193148_create_rooms.exs
yusufaine/nus-clubhouse
eae8223d26111bab5e981c95b539c964293908e8
[ "MIT" ]
116
2021-05-29T16:32:51.000Z
2021-08-13T16:05:29.000Z
elixir_backend/migrations/20210607193148_create_rooms.exs
yusufaine/nus-clubhouse
eae8223d26111bab5e981c95b539c964293908e8
[ "MIT" ]
2
2021-05-23T07:12:40.000Z
2021-10-11T02:59:40.000Z
defmodule ClubhouseData.Repo.Migrations.CreateRooms do use Ecto.Migration def change do create table(:rooms) do add :name, :string add :numUsers, :integer add :type, :string add :isLive, :boolean add :isScheduled, :boolean add :scheduledStart, :string add :isEnded, :boolean add :creator_id, references(:users) timestamps() end end end
22.315789
54
0.617925
73eccc7353403cf9e66104b70df63c5010e58a75
314
exs
Elixir
test/type_test.exs
gregpardo/arc_ecto_paperclip
4b1af69597ed0dadf7de1efa3b920ddae8cd3b53
[ "Apache-2.0" ]
1
2019-07-10T16:00:08.000Z
2019-07-10T16:00:08.000Z
test/type_test.exs
gregpardo/arc_ecto_paperclip
4b1af69597ed0dadf7de1efa3b920ddae8cd3b53
[ "Apache-2.0" ]
null
null
null
test/type_test.exs
gregpardo/arc_ecto_paperclip
4b1af69597ed0dadf7de1efa3b920ddae8cd3b53
[ "Apache-2.0" ]
null
null
null
defmodule ArcTest.Ecto.Paperclip.Type do use ExUnit.Case, async: false test "dumps files" do {:ok, value} = DummyDefinition.Type.dump("file.png") assert value == "file.png" end test "loads file" do {:ok, value} = DummyDefinition.Type.load("file.png") assert value == "file.png" end end
22.428571
56
0.66242
73ed0f971109b935bd27f96b306b4ed264b816db
6,060
ex
Elixir
lib/seven/sync/api_command_router.ex
the-AjK/sevenotters
b56c4c129f441f832561b6a9aff66281aa8627de
[ "MIT" ]
7
2019-08-23T16:28:34.000Z
2020-12-18T04:57:51.000Z
lib/seven/sync/api_command_router.ex
the-AjK/sevenotters
b56c4c129f441f832561b6a9aff66281aa8627de
[ "MIT" ]
9
2021-07-29T16:18:30.000Z
2021-07-29T16:36:59.000Z
lib/seven/sync/api_command_router.ex
the-AjK/sevenotters
b56c4c129f441f832561b6a9aff66281aa8627de
[ "MIT" ]
6
2020-04-07T15:41:50.000Z
2021-10-01T19:03:08.000Z
defmodule Seven.Sync.ApiCommandRouter do @moduledoc """ Make a syncronized command. Example: ```elixir defmodule MyApp.Command.Ping do alias __MODULE__ require Logger use Seven.Sync.ApiCommandRouter, post: %{ command: "Ping", pre_command: &Ping.pre_command/1, post_command: &Ping.post_command/2, wait_for_events: ["Pinged"] } def pre_command(%ApiRequest{} = _req) do Logger.debug("Ping.pre_command()") :ok end def post_command(%ApiRequest{} = _req, %Seven.Otters.Event{type: "Pinged"} = _event) do Logger.debug("Ping.post_command(): pinged event received.") %{ping: "ok"} end end ``` `post` map can contains: - `command`: the command to send - `pre_command`: a function that will be run after to send the command, expressed in the form of `func_name(%ApiRequest{})` - `post_command`: a function that will be run before to send the command, expressed in the form of `func_name(%ApiRequest{}, %Seven.Otters.Event{})` - `wait_for_events`: list of events to wait for; this macro waits for all indicated events that are raised from the same request generated by the command above. Usage: ``` iex> MyApp.Command.Ping.run(params) ``` """ defp is_not_nil(arg), do: not is_nil(arg) defmacro __using__(post: post) do quote location: :keep do alias Seven.Sync.ApiRequest @doc false @spec run(map) :: any def run(params) do %ApiRequest{ request_id: Seven.Data.Persistence.new_id(), command: unquote(post).command, state: :unmanaged, params: params, wait_for_events: unquote(post)[:wait_for_events] || [], timeout: unquote(post)[:timeout] || 5_000 } |> internal_pre_command |> subscribe_to_event_store |> send_command_request |> wait_events |> unsubscribe_to_event_store |> internal_post_command |> send_response end # Privates defp send_response(%ApiRequest{state: :managed, response: resp}), do: resp defp send_response(%ApiRequest{state: state}), do: state unquote do {_, _, p} = post if p[:pre_command] |> is_not_nil do quote do defp internal_pre_command(%ApiRequest{state: :unmanaged, command: unquote(p[:command])} = req) do case unquote(p[:pre_command]).(req) do :ok -> req {:ok, req} -> req err -> %ApiRequest{req | state: err} end end end end end defp internal_pre_command(%ApiRequest{} = req), do: req defp subscribe_to_event_store(%ApiRequest{state: :unmanaged, wait_for_events: []} = req), do: req defp subscribe_to_event_store(%ApiRequest{state: :unmanaged, wait_for_events: wait_for_events} = req) when length(wait_for_events) > 0 do wait_for_events |> Enum.each(&Seven.EventStore.EventStore.subscribe(&1, self())) req end defp subscribe_to_event_store(%ApiRequest{} = req), do: req defp send_command_request(%ApiRequest{state: :unmanaged} = req) do res = %Seven.CommandRequest{ id: req.request_id, command: req.command, sender: __MODULE__, params: AtomicMap.convert(req.params, safe: false) } |> Seven.Log.command_request_sent() |> Seven.CommandBus.send_command_request() %ApiRequest{req | state: res} end defp send_command_request(%ApiRequest{} = req), do: req defp wait_events(%ApiRequest{state: :managed, wait_for_events: []} = req), do: req defp wait_events(%ApiRequest{state: :managed, wait_for_events: events, timeout: timeout} = req) do incoming_events = wait_for_one_of_events(req.request_id, events, timeout, []) %ApiRequest{req | events: incoming_events} end defp wait_events(%ApiRequest{} = req), do: req defp unsubscribe_to_event_store(%ApiRequest{state: :managed, wait_for_events: []} = req), do: req defp unsubscribe_to_event_store(%ApiRequest{state: :managed, wait_for_events: wait_for_events} = req) when length(wait_for_events) > 0 do wait_for_events |> Enum.each(&Seven.EventStore.EventStore.unsubscribe(&1, self())) req end defp unsubscribe_to_event_store(%ApiRequest{} = req), do: req unquote do {_, _, p} = post if p[:post_command] |> is_not_nil do quote do defp internal_post_command(%ApiRequest{state: :managed, command: unquote(p[:command]), events: []} = req), do: %ApiRequest{req | response: unquote(p[:post_command]).(req, nil)} defp internal_post_command(%ApiRequest{state: :managed, command: unquote(p[:command]), events: [e1]} = req), do: %ApiRequest{req | response: unquote(p[:post_command]).(req, e1)} end end end # no events to wait for defp internal_post_command(%ApiRequest{state: :managed, wait_for_events: [], events: []} = req), do: req defp internal_post_command(%ApiRequest{state: :managed, events: []} = req), do: %ApiRequest{req | state: :timeout} defp internal_post_command(%ApiRequest{} = req), do: req defp wait_for_one_of_events(_request_id, [], _timeout, incoming_events), do: incoming_events defp wait_for_one_of_events(request_id, events, timeout, incoming_events) do receive do %Seven.Otters.Event{request_id: ^request_id} = e -> if e.type in events do incoming_events ++ [e] else wait_for_one_of_events(request_id, events, timeout, incoming_events) end _ -> wait_for_one_of_events(request_id, events, timeout, incoming_events) after timeout -> [] end end end end end
33.480663
164
0.614026
73ed11e40fdd9e9bfd2d19e0ee0a70b392119fb1
264
exs
Elixir
spawning-a-new-process/03_procs.exs
herminiotorres/elixir-for-programmers
6a02e3312ad0f7b1e543627e3cf8b54db00d0a1e
[ "MIT" ]
1
2020-08-10T21:07:43.000Z
2020-08-10T21:07:43.000Z
spawning-a-new-process/03_procs.exs
herminiotorres/elixir-for-programmers
6a02e3312ad0f7b1e543627e3cf8b54db00d0a1e
[ "MIT" ]
null
null
null
spawning-a-new-process/03_procs.exs
herminiotorres/elixir-for-programmers
6a02e3312ad0f7b1e543627e3cf8b54db00d0a1e
[ "MIT" ]
null
null
null
defmodule Procs do def greeter(count) do receive do {:add, number} -> greeter(count + number) {:reset} -> greeter(0) message -> IO.puts("#{count}: Hello #{inspect(message)}") greeter(count) end end end
18.857143
54
0.530303
73ed204f77346c1cfd5197fcb42fa022ef3f2741
1,178
exs
Elixir
test/commits_test.exs
nmohoric/tentacat
3bbb9990aafad0a7232d302526ca00e282e7ba43
[ "MIT" ]
null
null
null
test/commits_test.exs
nmohoric/tentacat
3bbb9990aafad0a7232d302526ca00e282e7ba43
[ "MIT" ]
null
null
null
test/commits_test.exs
nmohoric/tentacat
3bbb9990aafad0a7232d302526ca00e282e7ba43
[ "MIT" ]
null
null
null
defmodule Tentacat.CommitsTest do use ExUnit.Case, async: false use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney import Tentacat.Commits doctest Tentacat.Commits @client Tentacat.Client.new(%{access_token: "yourtokencomeshere"}) # setup_all do # HTTPoison.start # end test "list/3" do use_cassette "commits#list" do assert {200,[],_} = list("soudqwiggle", "elixir-conspiracy", @client) end end test "filter/4" do use_cassette "commits#filter" do {_,[%{"sha" => sha}],_} = filter("soudqwiggle", "elixir-conspiracy", %{sha: "09fe12ca25d0440f143ab331e4684a8622d6e4e5"}, @client) assert sha == "09fe12ca25d0440f143ab331e4684a8622d6e4e5" end end test "find/4" do use_cassette "commits#find" do {_,%{"sha" => sha},_} = find("09fe12ca25d0440f", "soudqwiggle", "elixir-conspiracy", @client) assert sha == "09fe12ca25d0440f143ab331e4684a8622d6e4e5" end end test "compare/5" do use_cassette "commits#compare" do {_,%{"total_commits" => total_commits},_} = compare("master", "09fe12ca25d0440f", "soudqwiggle", "elixir-conspiracy", @client) assert total_commits == 0 end end end
28.731707
135
0.680815
73ed34fec53af836309bfb785f7858dbe7aa84f6
991
exs
Elixir
config/config.exs
amohamedali/bbc_schedulor_phoenix
0eb828ca7da4cfecd57e8ad8085acbd625a3c2fa
[ "MIT" ]
null
null
null
config/config.exs
amohamedali/bbc_schedulor_phoenix
0eb828ca7da4cfecd57e8ad8085acbd625a3c2fa
[ "MIT" ]
null
null
null
config/config.exs
amohamedali/bbc_schedulor_phoenix
0eb828ca7da4cfecd57e8ad8085acbd625a3c2fa
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. use Mix.Config # Configures the endpoint config :bbc_schedulor_phoenix, BbcSchedulorPhoenix.Endpoint, url: [host: "localhost"], root: Path.dirname(__DIR__), secret_key_base: "HLyLzGkcLPihnHHUdc7ig1CMIYFsTIdBGKAKT6nozXJ/wow4uNmdhm9tdV4NMt9f", render_errors: [accepts: ~w(html json)], pubsub: [name: BbcSchedulorPhoenix.PubSub, adapter: Phoenix.PubSub.PG2] # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env}.exs" # Configure phoenix generators config :phoenix, :generators, migration: true, binary_id: false
33.033333
86
0.766902
73ed44f670c3a0cba4bac4fe3a85abbbc82157d5
84
ex
Elixir
lib/earmark_parser2/error.ex
RobertDober/EarmarkParser2
a50053a20e7aa2d5e6041d778dd9f19bb043da1b
[ "Apache-2.0" ]
null
null
null
lib/earmark_parser2/error.ex
RobertDober/EarmarkParser2
a50053a20e7aa2d5e6041d778dd9f19bb043da1b
[ "Apache-2.0" ]
null
null
null
lib/earmark_parser2/error.ex
RobertDober/EarmarkParser2
a50053a20e7aa2d5e6041d778dd9f19bb043da1b
[ "Apache-2.0" ]
null
null
null
defmodule EarmarkParser2.Error do @moduledoc false defexception [:message] end
14
33
0.785714
73ed691e69dac7f200be3fc2ea11e11b502d502b
1,558
ex
Elixir
lib/utils.ex
kenspirit/elixir-merkle-patricia-tree
31ffdc401a7df38bfe254466b3ff122c10229fa3
[ "MIT" ]
8
2018-04-25T18:15:53.000Z
2021-02-09T20:42:46.000Z
lib/utils.ex
kenspirit/elixir-merkle-patricia-tree
31ffdc401a7df38bfe254466b3ff122c10229fa3
[ "MIT" ]
9
2018-06-19T09:42:46.000Z
2018-12-12T00:13:58.000Z
lib/utils.ex
kenspirit/elixir-merkle-patricia-tree
31ffdc401a7df38bfe254466b3ff122c10229fa3
[ "MIT" ]
7
2018-07-30T22:05:19.000Z
2022-03-06T09:22:51.000Z
defmodule MerklePatriciaTree.Utils do @moduledoc """ Helper functions related to common operations """ @hash_bytes 32 @doc """ Returns a semi-random string of length `length` that can be represented by alphanumeric characters. Adopted from https://stackoverflow.com/a/32002566. ## Examples iex> MerklePatriciaTree.Utils.random_string(20) |> is_binary true iex> String.length(MerklePatriciaTree.Utils.random_string(20)) 20 iex> MerklePatriciaTree.Utils.random_string(20) == MerklePatriciaTree.Utils.random_string(20) false """ def random_string(length) do length |> :crypto.strong_rand_bytes() |> Base.url_encode64() |> binary_part(0, length) end @doc """ Returns a semi-random atom, similar to `random_string/1`, but is an atom. This is obviously not to be used in production since atoms are not garbage collected. ## Examples iex> MerklePatriciaTree.Utils.random_atom(20) |> is_atom true iex> MerklePatriciaTree.Utils.random_atom(20) |> Atom.to_string |> String.length 20 iex> MerklePatriciaTree.Utils.random_atom(20) == MerklePatriciaTree.Utils.random_atom(20) false """ def random_atom(length) do length |> random_string |> String.to_atom() end @doc """ Hashes a data using blake2b """ @spec hash(binary) :: binary | {:error, term} def hash(bin) when is_binary(bin) do {:ok, hash} = :enacl.generichash(@hash_bytes, bin) hash end def hash(_) do {:error, "wrong input data"} end end
23.969231
99
0.681643
73ed9fb98fcec0a8e21fb672c1cdc33b5910909c
644
ex
Elixir
lib/waffle/definition.ex
xMunch/waffle
2c60c64bb7ccfe878d50ca809dbd6dfe15046558
[ "Apache-2.0" ]
562
2019-08-30T01:09:36.000Z
2022-03-22T08:27:39.000Z
lib/waffle/definition.ex
ndarilek/waffle
5880ae5ac146a33251bee6142be347e3df53b36d
[ "Apache-2.0" ]
76
2019-08-26T20:24:14.000Z
2022-03-05T07:38:43.000Z
lib/waffle/definition.ex
ndarilek/waffle
5880ae5ac146a33251bee6142be347e3df53b36d
[ "Apache-2.0" ]
46
2019-09-13T19:07:12.000Z
2022-02-02T01:35:10.000Z
defmodule Waffle.Definition do @moduledoc ~S""" Defines uploader to manage files. defmodule Avatar do use Waffle.Definition end Consists of several components to manage different parts of file managing process. * `Waffle.Definition.Versioning` * `Waffle.Definition.Storage` * `Waffle.Actions.Store` * `Waffle.Actions.Delete` * `Waffle.Actions.Url` """ defmacro __using__(_options) do quote do use Waffle.Definition.Versioning use Waffle.Definition.Storage use Waffle.Actions.Store use Waffle.Actions.Delete use Waffle.Actions.Url end end end
18.4
66
0.677019
73edb9858f3f3cbaa87a9214614914bdd6660dff
3,504
ex
Elixir
lib/vekil/protocol/forom.ex
ianrumford/plymio_vekil
070ab783dc8f7747002df61704285947eea583a2
[ "MIT" ]
null
null
null
lib/vekil/protocol/forom.ex
ianrumford/plymio_vekil
070ab783dc8f7747002df61704285947eea583a2
[ "MIT" ]
null
null
null
lib/vekil/protocol/forom.ex
ianrumford/plymio_vekil
070ab783dc8f7747002df61704285947eea583a2
[ "MIT" ]
null
null
null
defprotocol Plymio.Vekil.Forom do @moduledoc ~S""" The `Plymio.Vekil.Forom` protocol is implemented by the values returned by the *vekil* accessor functions (e.g. `Plymio.Vekil.proxy_fetch/2`). See `Plymio.Vekil` for a general overview and explanation of the documentation terms. ## Implementation Modules' State See `Plymio.Vekil` for other common fields. All implementations have these fields in their `struct` which can e.g. be pattern matched. | Field | Aliases | Purpose | | :--- | :--- | :--- | | `:produce_default` | *:produce_default* | *holds the produce default value* | | `:realise_default` | *:answer_default* | *holds the realise default value* | ### Module State Field: `:produce_default` This field can hold a default value `produce/2` can use / return as the *product*. For example, some *forom* return a `Keyword` as their *product* and `:produce_default` is an empty list. ### Module State Field: `:realise_default` This field can hold a default value `realise/2` can use / return as the *answer*. It could be, for example, *the unset value* (`Plymio.Fontais.the_unset_value/0`) """ @dialyzer {:nowarn_function, __protocol__: 1} @type error :: Plymio.Vekil.error() @type opts :: Plymio.Vekil.opts() @type proxy :: any @type proxies :: nil | proxy | [proxy] @type forom :: any @type product :: Keyword @type answer :: any @doc ~S""" `update/2` takes a *forom* and optional *opts* and updates the fields in the *forom* with the `{field,value}` tuples in the *opts*, returning `{:ok, forom}`. All implementations should be prepared to be passed values for the *vekil* and / or *proxy* fields. """ @spec update(t, opts) :: {:ok, t} | {:error, error} def update(forom, opts) @doc ~S""" `produce/1` takes a *forom* and "produces" the *forom* to create the *product*, returning `{:ok, {product, forom}}`. The protocol does not define what the *product* will be, but most implemenations return a `Keyword` with zero, one or more `:forom` keys, together with other implementation-specific keys. (The `@spec` for produce uses the type `product` which is defined as a `Keyword` by default.) Producing the *forom* may change it. """ @spec produce(t) :: {:ok, {product, t}} | {:error, error} def produce(forom) @doc ~S""" `produce/2` takes a *forom* and optional *opts*, calls `update/2` with the *vekil* and the *opts*, and then "produces" the *forom* to create the *product*, returning `{:ok, {product, forom}}`. The protocol does not define what the *product* will be, but often will be a `Keyword`. Producing the *forom* may change it. """ @spec produce(t, opts) :: {:ok, {product, t}} | {:error, error} def produce(forom, opts) @doc ~S""" `realise/1` takes a *forom* the realises the *forom* to create the *answer* returning `{:ok, {answer, forom}}`. Usually `realise/1` calls `produce/1` and then transforms the *product* to generate the *answer* returning `{:ok, {answer, forom}}`. """ @spec realise(t) :: {:ok, {answer, t}} | {:error, error} def realise(forom) @doc ~S""" `realise/2` takes a *forom* and optional *opts* the realises the *forom* to create the *answer* returning `{:ok, {answer, forom}}`. Usually `realise/2` calls `produce/2` and reduces the *product* in some way to generate the *answer". """ @spec realise(t, opts) :: {:ok, {answer, t}} | {:error, error} def realise(forom, opts) end
31.00885
103
0.661244
73edceb97545ea5c8fcb167cdd9494704702fd12
2,478
exs
Elixir
map_update.exs
zoten/my-elixir-benches
990ad33b6875948eed6d1f67a68842976d585086
[ "MIT" ]
null
null
null
map_update.exs
zoten/my-elixir-benches
990ad33b6875948eed6d1f67a68842976d585086
[ "MIT" ]
null
null
null
map_update.exs
zoten/my-elixir-benches
990ad33b6875948eed6d1f67a68842976d585086
[ "MIT" ]
null
null
null
Mix.install([ {:benchee, "~> 1.0"}, {:benchee_html, "~> 1.0"}, {:benchee_json, "~> 1.0"} ]) # inspired by https://blog.brian-underwood.codes/elixir/2021/07/23/How-Far-Can-I-Push-a-GenServer?utm_medium=email&utm_source=elixir-radar#benchmark.exs defmodule Tester do def update!(map, key) do try do {:ok, Map.update!(map, key, fn v -> v end)} rescue _e in KeyError -> {:error, :no_key} end end def update(map, key) do {:ok, Map.update(map, key, %{a: 1}, fn v -> v end)} end def check_and_update!(map, key) do if Map.has_key?(map, key) do {:ok, Map.update!(map, key, fn v -> v end)} else {:error, :no_key} end end end defmodule Helper do def random_string(num, alphabet \\ '0123456789abcdefghijklmnopqrstuvwxyz') do for _ <- 0..num - 1, into: "", do: <<Enum.random(alphabet)>> end def create_big_map(num) do 0..num - 1 |> Enum.map(fn _ -> {Enum.random(10..15) |> random_string() |> String.to_atom(), random_string(100)} end) |> Enum.into(%{}) end end map_1 = %{blah: 1} inputs_1_exists = [:blah] inputs_1_not_exist = [:blargh] map_500 = Helper.create_big_map(500) inputs_500_exists = Enum.map(0..500, fn _ -> Enum.random(Map.keys(map_500)) end) inputs_500_not_exist = for _ <- 0..500, do: Helper.random_string(Enum.random(5..9)) |> String.to_atom() map_10000 = Helper.create_big_map(10000) inputs_10000_exists = Enum.map(0..10000, fn _ -> Enum.random(Map.keys(map_10000)) end) inputs_10000_not_exist = for _ <- 0..10000, do: Helper.random_string(Enum.random(5..9)) |> String.to_atom() Benchee.run(%{ "check_and_update!" => fn %{map: map, keys: keys} -> Enum.map(keys, fn key -> Tester.check_and_update!(map, key) end) end, "update!" => fn %{map: map, keys: keys} -> Enum.map(keys, fn key -> Tester.update!(map, key) end) end, "update" => fn %{map: map, keys: keys} -> Enum.map(keys, fn key -> Tester.update(map, key) end) end, }, inputs: %{ "1.key_exists" => %{map: map_1, keys: inputs_1_exists}, "1.key_not_exist" => %{map: map_1, keys: inputs_1_not_exist}, "500.key_exists" => %{map: map_500, keys: inputs_500_exists}, "500.key_not_exist" => %{map: map_500, keys: inputs_500_not_exist}, "10000.key_exists" => %{map: map_10000, keys: inputs_10000_exists}, "10000.key_not_exist" => %{map: map_10000, keys: inputs_10000_not_exist}, }, formatters: [ {Benchee.Formatters.HTML, file: "output/map_update/results.html"}, Benchee.Formatters.Console ])
33.486486
152
0.653349
73edd4b91cd062f45ab5af92bd3c7df73fe00ca0
81
ex
Elixir
web/views/page_view.ex
jasonlam604/jasonlam604-website
95d3ecd9716b347ff4d9bbf5fc255d2ab5b008b7
[ "MIT" ]
null
null
null
web/views/page_view.ex
jasonlam604/jasonlam604-website
95d3ecd9716b347ff4d9bbf5fc255d2ab5b008b7
[ "MIT" ]
null
null
null
web/views/page_view.ex
jasonlam604/jasonlam604-website
95d3ecd9716b347ff4d9bbf5fc255d2ab5b008b7
[ "MIT" ]
null
null
null
defmodule Jasonlam604Website.PageView do use Jasonlam604Website.Web, :view end
20.25
40
0.839506
73edd8a5a08ffde1d81b357a0abf59b85cf4048f
2,554
ex
Elixir
lib/hound/response_parser.ex
myfreeweb/hound
9277401c86adc4f62c14a91b42b21c4460fb9aac
[ "MIT" ]
null
null
null
lib/hound/response_parser.ex
myfreeweb/hound
9277401c86adc4f62c14a91b42b21c4460fb9aac
[ "MIT" ]
null
null
null
lib/hound/response_parser.ex
myfreeweb/hound
9277401c86adc4f62c14a91b42b21c4460fb9aac
[ "MIT" ]
null
null
null
defmodule Hound.ResponseParser do @moduledoc """ Defines a behaviour for parsing driver responses and provides a default implementation of the behaviour """ require Logger @callback handle_response(any, integer, String.t) :: any @callback handle_error(map) :: {:error, any} defmacro __using__(_) do quote do @behaviour Hound.ResponseParser @before_compile unquote(__MODULE__) def handle_response(path, code, body) do Hound.ResponseParser.handle_response(__MODULE__, path, code, body) end defdelegate warning?(message), to: Hound.ResponseParser defoverridable [handle_response: 3, warning?: 1] end end def parse(parser, path, code = 204, _headers, raw_content = "") do # Don't try to parse the json because there is none. parser.handle_response(path, code, raw_content) end def parse(parser, path, code, _headers, raw_content) do case Hound.ResponseParser.decode_content(raw_content) do {:ok, body} -> parser.handle_response(path, code, body) _ -> :error end end @doc """ Default implementation to handle drivers responses. """ def handle_response(mod, path, code, body) def handle_response(_mod, "session", code, %{"sessionId" => session_id}) when code < 300 do {:ok, session_id} end def handle_response(_mod, "session", code, %{"value" => %{"sessionId" => session_id}}) when code < 300 do {:ok, session_id} end def handle_response(mod, _path, _code, %{"value" => %{"message" => message} = value}) do if mod.warning?(message) do Logger.warn(message) message else mod.handle_error(value) end end def handle_response(_mod, _path, _code, %{"value" => value}), do: value def handle_response(_mod, _path, code, _body) when code < 400, do: :ok def handle_response(_mod, _path, _code, _body), do: :error @doc """ Default implementation to check if the message is a warning """ def warning?(message) do Regex.match?(~r/#{Regex.escape("not clickable")}/, message) end @doc """ Decodes a response body """ def decode_content([]), do: Map.new def decode_content(content), do: Jason.decode(content) defmacro __before_compile__(_env) do quote do @doc """ Fallback case if we did not match the message in the using module """ def handle_error(response) do case response do %{"message" => message} -> {:error, message} _ -> {:error, response} end end end end end
29.022727
107
0.655051
73eddd6fcd4955617d33da6ed37a740f5266b0f8
657
ex
Elixir
lib/ai/media_provider/media_provider.ex
mirai-audio/-
365c0fba614543bf40ebaae55de47bc541bd473f
[ "MIT" ]
null
null
null
lib/ai/media_provider/media_provider.ex
mirai-audio/-
365c0fba614543bf40ebaae55de47bc541bd473f
[ "MIT" ]
null
null
null
lib/ai/media_provider/media_provider.ex
mirai-audio/-
365c0fba614543bf40ebaae55de47bc541bd473f
[ "MIT" ]
null
null
null
defmodule Ai.MediaProvider do defstruct provider: "", provider_uid: "" @callback parse(String.t) :: {:ok, %__MODULE__{}} | {:error, String.t} def parse!(url) do implementation = detect_implementation(url) case implementation.parse(url) do {:error, error} -> {:error, "parse error: #{error}"} data -> data end end defp detect_implementation(nil), do: Ai.MediaProvider.Example defp detect_implementation(url) do host = URI.parse(url).host cond do Regex.match?(~r/youtu(be\.com|\.be)+$/, host) -> Ai.MediaProvider.Youtube true -> Ai.MediaProvider.Example end end end
25.269231
72
0.628615
73eddf76b46d393e0101289a24011f97ba1d7acb
8,693
ex
Elixir
clients/plus_domains/lib/google_api/plus_domains/v1/api/media.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/plus_domains/lib/google_api/plus_domains/v1/api/media.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/plus_domains/lib/google_api/plus_domains/v1/api/media.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.PlusDomains.V1.Api.Media do @moduledoc """ API calls for all endpoints tagged `Media`. """ alias GoogleApi.PlusDomains.V1.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Add a new media item to an album. The current upload size limitations are 36MB for a photo and 1GB for a video. Uploads do not count against quota if photos are less than 2048 pixels on their longest side or videos are less than 15 minutes in length. ## Parameters - connection (GoogleApi.PlusDomains.V1.Connection): Connection to server - user_id (String.t): The ID of the user to create the activity on behalf of. - collection (String.t): - optional_params (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :body (Media): ## Returns {:ok, %GoogleApi.PlusDomains.V1.Model.Media{}} on success {:error, info} on failure """ @spec plus_domains_media_insert(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.PlusDomains.V1.Model.Media.t()} | {:error, Tesla.Env.t()} def plus_domains_media_insert( connection, user_id, collection, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/plusDomains/v1/people/{userId}/media/{collection}", %{ "userId" => URI.encode_www_form(user_id), "collection" => URI.encode_www_form(collection) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PlusDomains.V1.Model.Media{}]) end @doc """ Add a new media item to an album. The current upload size limitations are 36MB for a photo and 1GB for a video. Uploads do not count against quota if photos are less than 2048 pixels on their longest side or videos are less than 15 minutes in length. ## Parameters - connection (GoogleApi.PlusDomains.V1.Connection): Connection to server - user_id (String.t): The ID of the user to create the activity on behalf of. - collection (String.t): - upload_type (String.t): Upload type. Must be \&quot;resumable\&quot;. - optional_params (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :body (Media): ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec plus_domains_media_insert_resumable( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword() ) :: {:ok, nil} | {:error, Tesla.Env.t()} def plus_domains_media_insert_resumable( connection, user_id, collection, upload_type, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/resumable/upload/plusDomains/v1/people/{userId}/media/{collection}", %{ "userId" => URI.encode_www_form(user_id), "collection" => URI.encode_www_form(collection) }) |> Request.add_param(:query, :uploadType, upload_type) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Add a new media item to an album. The current upload size limitations are 36MB for a photo and 1GB for a video. Uploads do not count against quota if photos are less than 2048 pixels on their longest side or videos are less than 15 minutes in length. ## Parameters - connection (GoogleApi.PlusDomains.V1.Connection): Connection to server - user_id (String.t): The ID of the user to create the activity on behalf of. - collection (String.t): - upload_type (String.t): Upload type. Must be \&quot;multipart\&quot;. - metadata (Media): Media metadata. - data (String.t): The file to upload. - optional_params (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %GoogleApi.PlusDomains.V1.Model.Media{}} on success {:error, info} on failure """ @spec plus_domains_media_insert_simple( Tesla.Env.client(), String.t(), String.t(), String.t(), GoogleApi.PlusDomains.V1.Model.Media.t(), String.t(), keyword() ) :: {:ok, GoogleApi.PlusDomains.V1.Model.Media.t()} | {:error, Tesla.Env.t()} def plus_domains_media_insert_simple( connection, user_id, collection, upload_type, metadata, data, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:post) |> Request.url("/upload/plusDomains/v1/people/{userId}/media/{collection}", %{ "userId" => URI.encode_www_form(user_id), "collection" => URI.encode_www_form(collection) }) |> Request.add_param(:query, :uploadType, upload_type) |> Request.add_param(:body, :metadata, metadata) |> Request.add_param(:file, :data, data) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PlusDomains.V1.Model.Media{}]) end end
39.513636
252
0.663407
73ee2ce5abc194700034da2242e6d768a9e25bd2
1,210
ex
Elixir
lib/chroxy/application.ex
julienmarie/chroxy
a60525d4597ca4183954841df8973a6996cae1cc
[ "MIT" ]
null
null
null
lib/chroxy/application.ex
julienmarie/chroxy
a60525d4597ca4183954841df8973a6996cae1cc
[ "MIT" ]
null
null
null
lib/chroxy/application.ex
julienmarie/chroxy
a60525d4597ca4183954841df8973a6996cae1cc
[ "MIT" ]
null
null
null
defmodule Chroxy.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application require Logger def start(_type, _args) do # HACK to get exec running as root. Application.put_env(:exec, :root, true) Application.put_env(:exec, :port_path, "/usr/local/bin/exec-port") Application.put_env(:exec, :portexe, '/usr/local/bin/exec-port') Application.put_env(:erlexec, :root, true) Application.put_env(:erlexec, :port_path, "/usr/local/bin/exec-port") Application.put_env(:erlexec, :portexe, '/usr/local/bin/exec-port') {:ok, _} = Application.ensure_all_started(:erlexec) {:ok, _} = Application.ensure_all_started(:exexec) proxy_opts = Application.get_env(:chroxy, Chroxy.ProxyListener) children = [ Chroxy.ProxyListener.child_spec(proxy_opts), Chroxy.ChromeServer.Supervisor.child_spec(), Chroxy.BrowserPool.child_spec(), Chroxy.Endpoint.child_spec(), Chroxy.ProxyRouter.child_spec() ] Logger.info("Started application") opts = [strategy: :one_for_one, name: Chroxy.Supervisor] Supervisor.start_link(children, opts) end end
31.025641
73
0.706612
73ee7e7095e9c79d186572f0d7e82c9ff62a29fb
346
ex
Elixir
lib/ex_vertx/application.ex
PharosProduction/ExVertx
eb52d9ded96d5e344780304c4bb93f6302386f49
[ "Apache-2.0" ]
16
2019-03-18T12:46:38.000Z
2020-10-14T09:30:52.000Z
lib/ex_vertx/application.ex
PharosProduction/ExVertx
eb52d9ded96d5e344780304c4bb93f6302386f49
[ "Apache-2.0" ]
null
null
null
lib/ex_vertx/application.ex
PharosProduction/ExVertx
eb52d9ded96d5e344780304c4bb93f6302386f49
[ "Apache-2.0" ]
1
2019-04-30T21:26:28.000Z
2019-04-30T21:26:28.000Z
defmodule ExVertx.Application do @moduledoc false use Application # Callbacks @impl true def start(_type, _args) do children = [ {DynamicSupervisor, strategy: :one_for_one, name: ExVertx.BusSupervisor} ] opts = [strategy: :one_for_one, name: ExVertx.Supervisor] Supervisor.start_link(children, opts) end end
19.222222
78
0.705202
73ee8b6e081277bb1e2b8d8ebb427e64170f4e63
3,306
ex
Elixir
apps/ui/lib/ui/shift_register.ex
joshuawscott/led_control
e7851442b70dfb9940d5bd81463cc05e619b4faa
[ "MIT" ]
null
null
null
apps/ui/lib/ui/shift_register.ex
joshuawscott/led_control
e7851442b70dfb9940d5bd81463cc05e619b4faa
[ "MIT" ]
null
null
null
apps/ui/lib/ui/shift_register.ex
joshuawscott/led_control
e7851442b70dfb9940d5bd81463cc05e619b4faa
[ "MIT" ]
null
null
null
defmodule ShiftRegister do @moduledoc """ Controls a 74hc595 shift register Connect GPIO pins on your PI to pins 11, 12, 14 of the 74hc595. For an 74hc595n, if you put the package pins down, the pin layout looks like this (`U` is the notch on the end of the package.) ``` output1 -> 1 U 16 <- 5V power in output2 -> 2 15 <- output0 output3 3 14 <- data output4 4 13 <- connect to ground output5 5 12 <- latch output6 6 11 <- clock output7 7 10 <- Master Reset (connect to ground) ground -> 8 9 <- Q7S (?) ``` To start it up, pass in the latch pin, the clock pin, and the data pin. latch pin connects to STCP (pin 12) of the 74hc595 clock pin connects to SHCP (pin 11) of the 74hc595 data pin connects to DS (pin 14) of the 74hc595 """ use GenServer use Bitwise @latch_pin 5 @clock_pin 6 @data_pin 4 @type pin() :: non_neg_integer() defmodule State do @moduledoc "Container for the ShiftRegister's state" defstruct [:latch_pin, :clock_pin, :data_pin] end alias ShiftRegister.State @doc """ Takes the 3 pin numbers that are needed to operate the shift register. See module documentation for detail. """ def start_link(latch_pin \\ @latch_pin, clock_pin \\ @clock_pin, data_pin \\ @data_pin) do GenServer.start_link(__MODULE__, {latch_pin, clock_pin, data_pin}) end @spec init({pin, pin, pin}) :: {:ok, %State{}} def init({latch_pin_num, clock_pin_num, data_pin_num}) do {:ok, latch_pin} = Gpio.start_link(latch_pin_num, :output) {:ok, clock_pin} = Gpio.start_link(clock_pin_num, :output) {:ok, data_pin} = Gpio.start_link(data_pin_num, :output) {:ok, %State{latch_pin: latch_pin, clock_pin: clock_pin, data_pin: data_pin}} end @doc """ Sends data into the shift register """ @spec shift_out(pid(), non_neg_integer()) :: :ok def shift_out(pid, value) do GenServer.call(pid, {:shift_out, value}) end # Junk def display(pid, 0), do: ShiftRegister.shift_out(pid, 0b11111100) def display(pid, 1), do: ShiftRegister.shift_out(pid, 0b00110000) def display(pid, 2), do: ShiftRegister.shift_out(pid, 0b01101110) def display(pid, 3), do: ShiftRegister.shift_out(pid, 0b01111010) def display(pid, 4), do: ShiftRegister.shift_out(pid, 0b10110010) def display(pid, 5), do: ShiftRegister.shift_out(pid, 0b11011010) def display(pid, 6), do: ShiftRegister.shift_out(pid, 0b11011110) def display(pid, 7), do: ShiftRegister.shift_out(pid, 0b01110000) def display(pid, 8), do: ShiftRegister.shift_out(pid, 0b11111110) def display(pid, 9), do: ShiftRegister.shift_out(pid, 0b11111010) def handle_call({:shift_out, value}, _from, state) do require Logger Logger.info("Setting latch pin to 0") Gpio.write(state.latch_pin, 0) Enum.each(0..7, fn n -> mask = 1 <<< n overlap = value &&& mask pin_val = if overlap == 0 do 0 else 1 end Logger.info("setting data pin to #{pin_val}") Gpio.write(state.data_pin, pin_val) # Cycle the clock Logger.info "Clock Cycle" Gpio.write(state.clock_pin, 1) Gpio.write(state.clock_pin, 0) end) Logger.info("Setting latch pin to 1") Gpio.write(state.latch_pin, 1) {:reply, :ok, state} end end
32.097087
97
0.669389
73eeca6e6d98066c46cee17db4893f1735040aaa
1,931
ex
Elixir
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_entity_id.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_entity_id.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_entity_id.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2EntityId do @moduledoc """ An entity in a dataset is a field or set of fields that correspond to a single person. For example, in medical records the `EntityId` might be a patient identifier, or for financial records it might be an account identifier. This message is used when generalizations or analysis must take into account that multiple rows correspond to the same entity. ## Attributes * `field` (*type:* `GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2FieldId.t`, *default:* `nil`) - Composite key indicating which field contains the entity identifier. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :field => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2FieldId.t() } field(:field, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2FieldId) end defimpl Poison.Decoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2EntityId do def decode(value, options) do GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2EntityId.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2EntityId do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
37.862745
165
0.760746
73eee085e9b29934b49977d90ca440ebb819293e
2,016
ex
Elixir
clients/dfa_reporting/lib/google_api/dfa_reporting/v34/model/creative_fields_list_response.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/dfa_reporting/lib/google_api/dfa_reporting/v34/model/creative_fields_list_response.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/dfa_reporting/lib/google_api/dfa_reporting/v34/model/creative_fields_list_response.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-10-04T10:12:44.000Z
2020-10-04T10:12:44.000Z
# Copyright 2019 Google LLC # # 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. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.DFAReporting.V34.Model.CreativeFieldsListResponse do @moduledoc """ Creative Field List Response ## Attributes * `creativeFields` (*type:* `list(GoogleApi.DFAReporting.V34.Model.CreativeField.t)`, *default:* `nil`) - Creative field collection. * `kind` (*type:* `String.t`, *default:* `nil`) - Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse". * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - Pagination token to be used for the next list operation. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :creativeFields => list(GoogleApi.DFAReporting.V34.Model.CreativeField.t()), :kind => String.t(), :nextPageToken => String.t() } field(:creativeFields, as: GoogleApi.DFAReporting.V34.Model.CreativeField, type: :list) field(:kind) field(:nextPageToken) end defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V34.Model.CreativeFieldsListResponse do def decode(value, options) do GoogleApi.DFAReporting.V34.Model.CreativeFieldsListResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V34.Model.CreativeFieldsListResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.037736
162
0.737599
73eee5d1619bf0ab04a0a4554662230e726cb069
63
ex
Elixir
web/views/layout_view.ex
KazuCocoa/myChatEx
27871c7d9715987a664caa10a7c79b2682f6e56c
[ "MIT" ]
null
null
null
web/views/layout_view.ex
KazuCocoa/myChatEx
27871c7d9715987a664caa10a7c79b2682f6e56c
[ "MIT" ]
null
null
null
web/views/layout_view.ex
KazuCocoa/myChatEx
27871c7d9715987a664caa10a7c79b2682f6e56c
[ "MIT" ]
null
null
null
defmodule MyChatEx.LayoutView do use MyChatEx.Web, :view end
15.75
32
0.793651
73eef80fc3633b5da0974956b737c8d8ec6f8914
1,600
ex
Elixir
test/support/data_case.ex
longnd/elixir-gscraper
894570afd89e54b80ca591a56a182da55ac6ee61
[ "MIT" ]
null
null
null
test/support/data_case.ex
longnd/elixir-gscraper
894570afd89e54b80ca591a56a182da55ac6ee61
[ "MIT" ]
25
2021-03-23T07:27:21.000Z
2021-10-31T15:09:52.000Z
test/support/data_case.ex
longnd/elixir-gscraper
894570afd89e54b80ca591a56a182da55ac6ee61
[ "MIT" ]
null
null
null
defmodule Gscraper.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. You may define functions here to be used as helpers in your tests. Finally, if the test case interacts with the database, we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously by setting `use Gscraper.DataCase, async: true`, although this option is not recommended for other databases. """ use ExUnit.CaseTemplate alias Ecto.Adapters.SQL.Sandbox using do quote do alias Gscraper.Repo import Ecto import Ecto.Changeset import Ecto.Query import Gscraper.DataCase import Gscraper.Factory import GscraperWeb.Gettext end end setup tags do :ok = Sandbox.checkout(Gscraper.Repo) unless tags[:async] do Sandbox.mode(Gscraper.Repo, {:shared, self()}) end :ok end @doc """ A helper that transforms changeset errors into a map of messages. assert {:error, changeset} = Accounts.create_user(%{password: "short"}) assert "password is too short" in errors_on(changeset).password assert %{password: ["password is too short"]} = errors_on(changeset) """ def errors_on(changeset) do Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> Regex.replace(~r"%{(\w+)}", message, fn _, key -> opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() end) end) end end
26.666667
77
0.689375
73eefb7e48e86f35af7dbf3edda6dd7f5dcd1d36
2,583
ex
Elixir
clients/machine_learning/lib/google_api/machine_learning/v1/model/google_cloud_ml_v1__replica_config.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/machine_learning/lib/google_api/machine_learning/v1/model/google_cloud_ml_v1__replica_config.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
clients/machine_learning/lib/google_api/machine_learning/v1/model/google_cloud_ml_v1__replica_config.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1_ReplicaConfig do @moduledoc """ Represents the configuration for a replica in a cluster. ## Attributes * `acceleratorConfig` (*type:* `GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1__AcceleratorConfig.t`, *default:* `nil`) - Represents the type and number of accelerators used by the replica. [Learn about restrictions on accelerator configurations for training.](/ml-engine/docs/tensorflow/using-gpus#compute-engine-machine-types-with-gpu) * `imageUri` (*type:* `String.t`, *default:* `nil`) - The Docker image to run on the replica. This image must be in Container Registry. Learn more about [configuring custom containers](/ml-engine/docs/distributed-training-containers). * `tpuTfVersion` (*type:* `String.t`, *default:* `nil`) - TensorFlow version used in the custom container. This field is required if the replica is a TPU worker that uses a custom container. Otherwise, do not specify this field. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :acceleratorConfig => GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1__AcceleratorConfig.t(), :imageUri => String.t(), :tpuTfVersion => String.t() } field( :acceleratorConfig, as: GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1__AcceleratorConfig ) field(:imageUri) field(:tpuTfVersion) end defimpl Poison.Decoder, for: GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1_ReplicaConfig do def decode(value, options) do GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1_ReplicaConfig.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.MachineLearning.V1.Model.GoogleCloudMlV1_ReplicaConfig do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
40.359375
197
0.743709
73eefbec17350cd96c4a27ce321b4c5d1adf55c2
2,412
ex
Elixir
clients/network_management/lib/google_api/network_management/v1/model/vpn_gateway_info.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "Apache-2.0" ]
null
null
null
clients/network_management/lib/google_api/network_management/v1/model/vpn_gateway_info.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "Apache-2.0" ]
null
null
null
clients/network_management/lib/google_api/network_management/v1/model/vpn_gateway_info.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.NetworkManagement.V1.Model.VpnGatewayInfo do @moduledoc """ For display only. Metadata associated with a Compute Engine VPN gateway. ## Attributes * `displayName` (*type:* `String.t`, *default:* `nil`) - Name of a VPN gateway. * `ipAddress` (*type:* `String.t`, *default:* `nil`) - IP address of the VPN gateway. * `networkUri` (*type:* `String.t`, *default:* `nil`) - URI of a Compute Engine network where the VPN gateway is configured. * `region` (*type:* `String.t`, *default:* `nil`) - Name of a GCP region where this VPN gateway is configured. * `uri` (*type:* `String.t`, *default:* `nil`) - URI of a VPN gateway. * `vpnTunnelUri` (*type:* `String.t`, *default:* `nil`) - A VPN tunnel that is associated with this VPN gateway. There may be multiple VPN tunnels configured on a VPN gateway, and only the one relevant to the test is displayed. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :displayName => String.t() | nil, :ipAddress => String.t() | nil, :networkUri => String.t() | nil, :region => String.t() | nil, :uri => String.t() | nil, :vpnTunnelUri => String.t() | nil } field(:displayName) field(:ipAddress) field(:networkUri) field(:region) field(:uri) field(:vpnTunnelUri) end defimpl Poison.Decoder, for: GoogleApi.NetworkManagement.V1.Model.VpnGatewayInfo do def decode(value, options) do GoogleApi.NetworkManagement.V1.Model.VpnGatewayInfo.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.NetworkManagement.V1.Model.VpnGatewayInfo do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.903226
231
0.692786
73ef3cdf3a233237ae75158a7bdaa86de0f713e1
149
exs
Elixir
priv/repo/migrations/20180706005343_remove_subscribed_channels.exs
shanesveller/grapevine
fe74ade1adff88dfe4c1ab55fee3902dbb4664fe
[ "MIT" ]
null
null
null
priv/repo/migrations/20180706005343_remove_subscribed_channels.exs
shanesveller/grapevine
fe74ade1adff88dfe4c1ab55fee3902dbb4664fe
[ "MIT" ]
null
null
null
priv/repo/migrations/20180706005343_remove_subscribed_channels.exs
shanesveller/grapevine
fe74ade1adff88dfe4c1ab55fee3902dbb4664fe
[ "MIT" ]
null
null
null
defmodule Grapevine.Repo.Migrations.RemoveSubscribedChannels do use Ecto.Migration def change do drop table(:subscribed_channels) end end
18.625
63
0.798658
73ef6c4fa1447bd9f8d47837bcab0779601ae080
1,152
ex
Elixir
lib/entry.ex
narck/gblex
e1938621968d0586a13c36cbba264f757057ffe1
[ "MIT" ]
null
null
null
lib/entry.ex
narck/gblex
e1938621968d0586a13c36cbba264f757057ffe1
[ "MIT" ]
2
2017-04-24T11:47:03.000Z
2017-05-14T12:48:35.000Z
lib/entry.ex
narck/gblex
e1938621968d0586a13c36cbba264f757057ffe1
[ "MIT" ]
null
null
null
defmodule Gblex.Entry do @enforce_keys [:date, :slug, :markdown, :title] defstruct [:date, :slug, :title, :markdown, :html] @doc """ Reads a `filename` into a tuple containing an `%Gblex.Entry{}` struct. Files come directly from `File.ls!` and have no path prefix (it is prepended). """ def read_entry(filename) do entry_name = filename |> String.split(".") |> List.first markdown = "entries/#{filename}" |> File.read! %Gblex.Entry{markdown: markdown, title: title(entry_name), date: date(entry_name), slug: slug(entry_name) } end defp slug(filename) do filename |> String.downcase |> String.replace("'", "") |> String.replace("`", "") |> String.replace(" ", "-") end defp date(filename) do filename |> String.splitter("-") |> Enum.take(3) |> Enum.join("-") |> Date.from_iso8601! end defp title(filename) do filename |> String.split("-") |> List.last |> String.replace("`", "") end end
20.945455
74
0.522569
73ef71e2a5c63f7320c90a77aee42af61c4a7402
2,274
ex
Elixir
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do @moduledoc """ The request message for EntityTypes.BatchCreateEntities. ## Attributes - entities ([GoogleCloudDialogflowV2EntityTypeEntity]): Required. The entities to create. Defaults to: `null`. - languageCode (String.t): Optional. The language of entity synonyms defined in &#x60;entities&#x60;. If not specified, the agent&#39;s default language is used. [More than a dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages must be enabled in the agent, before they can be used. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :entities => list(GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2EntityTypeEntity.t()), :languageCode => any() } field( :entities, as: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2EntityTypeEntity, type: :list ) field(:languageCode) end defimpl Poison.Decoder, for: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do def decode(value, options) do GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.677419
348
0.755937
73ef9f0842804d71994c124d729ffb3a88a061b0
2,904
exs
Elixir
test/acceptances/mapping_test.exs
williamtran29/tirex_aws
8affc13d32978db47e083bec7ae11c5546f89395
[ "Apache-2.0" ]
null
null
null
test/acceptances/mapping_test.exs
williamtran29/tirex_aws
8affc13d32978db47e083bec7ae11c5546f89395
[ "Apache-2.0" ]
null
null
null
test/acceptances/mapping_test.exs
williamtran29/tirex_aws
8affc13d32978db47e083bec7ae11c5546f89395
[ "Apache-2.0" ]
null
null
null
defmodule Acceptances.MappingTest do use ExUnit.Case use Tirexs.Mapping alias Tirexs.{HTTP, Resources} setup_all do HTTP.delete("bear_test") && :ok end test "mappings definition (basic)" do index = [index: "bear_test", type: "bear_type"] mappings do indexes "mn_opts_", [type: "object"] do indexes "uk", [type: "object"] do indexes "credentials", [type: "object"] do indexes "available_from", type: "long" indexes "buy", type: "object" indexes "dld", type: "object" indexes "str", type: "object" indexes "t2p", type: "object" indexes "sby", type: "object" indexes "spl", type: "object" indexes "spd", type: "object" indexes "pre", type: "object" indexes "fst", type: "object" end end end indexes "rev_history_", type: "object" end {:ok, _, body} = Tirexs.Mapping.create_resource(index) assert body[:acknowledged] == true end test "create mapping and settings" do HTTP.delete("articles") index = [index: "articles", type: "article"] settings do analysis do analyzer "autocomplete_analyzer", [ filter: ["lowercase", "asciifolding", "edge_ngram"], tokenizer: "whitespace" ] filter "edge_ngram", [type: "edgeNGram", min_gram: 1, max_gram: 15] end end mappings dynamic: "false", _parent: [type: "parent"] do indexes "country", type: "string" indexes "city", type: "string" indexes "suburb", type: "string" indexes "road", type: "string" indexes "postcode", type: "string", index: "not_analyzed" indexes "housenumber", type: "string", index: "not_analyzed" indexes "coordinates", type: "geo_point" indexes "full_address", type: "string", analyzer: "autocomplete_analyzer" end Tirexs.Mapping.create_resource(index) Resources.bump!._refresh("articles") {:ok, 200, response} = HTTP.get("articles") settings = response[:articles][:settings] mappings = response[:articles][:mappings] %{index: %{analysis: analyzer}} = settings assert %{analyzer: %{autocomplete_analyzer: %{filter: ["lowercase", "asciifolding", "edge_ngram"], tokenizer: "whitespace"}}, filter: %{edge_ngram: %{max_gram: "15", min_gram: "1", type: "edgeNGram"}}} == analyzer %{article: properties} = mappings assert %{dynamic: "false", _parent: %{type: "parent"}, _routing: %{required: true}, properties: %{city: %{type: "string"}, coordinates: %{type: "geo_point"}, country: %{type: "string"}, full_address: %{analyzer: "autocomplete_analyzer", type: "string"}, housenumber: %{index: "not_analyzed", type: "string"}, postcode: %{index: "not_analyzed", type: "string"}, road: %{type: "string"}, suburb: %{type: "string"}}} == properties end end
35.414634
431
0.611915
73efa32b931848fa57e872e649af7434d92b7d4b
245
ex
Elixir
test/support/cms/V3/Database/mock_tag_table.ex
noizu-labs/KitchenSinkAdvanced
6d91b5dd4f59cd9838f87a64605a0ef87f4301c8
[ "MIT" ]
null
null
null
test/support/cms/V3/Database/mock_tag_table.ex
noizu-labs/KitchenSinkAdvanced
6d91b5dd4f59cd9838f87a64605a0ef87f4301c8
[ "MIT" ]
null
null
null
test/support/cms/V3/Database/mock_tag_table.ex
noizu-labs/KitchenSinkAdvanced
6d91b5dd4f59cd9838f87a64605a0ef87f4301c8
[ "MIT" ]
null
null
null
defmodule Noizu.Support.V3.CMS.Database.Article.Tag.MockTable do @moduledoc false require Noizu.Testing.Mnesia.TableMocker Noizu.Testing.Mnesia.TableMocker.customize() do @table Noizu.V3.CMS.Database.Article.Tag.Table end end
30.625
65
0.771429
73efa6df20057d1a51e12b97dae758754235fa81
2,026
ex
Elixir
clients/secret_manager/lib/google_api/secret_manager/v1/model/list_secrets_response.ex
kolorahl/elixir-google-api
46bec1e092eb84c6a79d06c72016cb1a13777fa6
[ "Apache-2.0" ]
null
null
null
clients/secret_manager/lib/google_api/secret_manager/v1/model/list_secrets_response.ex
kolorahl/elixir-google-api
46bec1e092eb84c6a79d06c72016cb1a13777fa6
[ "Apache-2.0" ]
null
null
null
clients/secret_manager/lib/google_api/secret_manager/v1/model/list_secrets_response.ex
kolorahl/elixir-google-api
46bec1e092eb84c6a79d06c72016cb1a13777fa6
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.SecretManager.V1.Model.ListSecretsResponse do @moduledoc """ Response message for SecretManagerService.ListSecrets. ## Attributes * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - A token to retrieve the next page of results. Pass this value in ListSecretsRequest.page_token to retrieve the next page. * `secrets` (*type:* `list(GoogleApi.SecretManager.V1.Model.Secret.t)`, *default:* `nil`) - The list of Secrets sorted in reverse by create_time (newest first). * `totalSize` (*type:* `integer()`, *default:* `nil`) - The total number of Secrets. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :nextPageToken => String.t(), :secrets => list(GoogleApi.SecretManager.V1.Model.Secret.t()), :totalSize => integer() } field(:nextPageToken) field(:secrets, as: GoogleApi.SecretManager.V1.Model.Secret, type: :list) field(:totalSize) end defimpl Poison.Decoder, for: GoogleApi.SecretManager.V1.Model.ListSecretsResponse do def decode(value, options) do GoogleApi.SecretManager.V1.Model.ListSecretsResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.SecretManager.V1.Model.ListSecretsResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.836364
156
0.727542
73efae52b0215e9a0f851759679b172828a6a8a6
130,249
ex
Elixir
clients/monitoring/lib/google_api/monitoring/v3/api/projects.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/monitoring/lib/google_api/monitoring/v3/api/projects.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
clients/monitoring/lib/google_api/monitoring/v3/api/projects.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.Monitoring.V3.Api.Projects do @moduledoc """ API calls for all endpoints tagged `Projects`. """ alias GoogleApi.Monitoring.V3.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Creates a new alerting policy. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project in which to create the alerting policy. The format is projects/[PROJECT_ID].Note that this field names the parent container in which the alerting policy will be written, not the name of the created policy. The alerting policy that is returned will have a name that contains a normalized representation of this name as a prefix but adds a suffix of the form /alertPolicies/[POLICY_ID], identifying the policy in the container. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.AlertPolicy.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.AlertPolicy{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_alert_policies_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.AlertPolicy.t()} | {:error, Tesla.Env.t()} def monitoring_projects_alert_policies_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/alertPolicies", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.AlertPolicy{}]) end @doc """ Deletes an alerting policy. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The alerting policy to delete. The format is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] For more information, see AlertPolicy. * `alert_policies_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_alert_policies_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_alert_policies_delete( connection, projects_id, alert_policies_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v3/projects/{projectsId}/alertPolicies/{alertPoliciesId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "alertPoliciesId" => URI.encode(alert_policies_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Gets a single alerting policy. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The alerting policy to retrieve. The format is projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] * `alert_policies_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.AlertPolicy{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_alert_policies_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.AlertPolicy.t()} | {:error, Tesla.Env.t()} def monitoring_projects_alert_policies_get( connection, projects_id, alert_policies_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/alertPolicies/{alertPoliciesId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "alertPoliciesId" => URI.encode(alert_policies_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.AlertPolicy{}]) end @doc """ Lists the existing alerting policies for the project. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project whose alert policies are to be listed. The format is projects/[PROJECT_ID] Note that this field names the parent container in which the alerting policies to be listed are stored. To retrieve a single alerting policy by name, use the GetAlertPolicy operation, instead. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:filter` (*type:* `String.t`) - If provided, this field specifies the criteria that must be met by alert policies to be included in the response.For more details, see sorting and filtering. * `:orderBy` (*type:* `String.t`) - A comma-separated list of fields by which to sort the result. Supports the same set of field references as the filter field. Entries can be prefixed with a minus sign to sort by the field in descending order.For more details, see sorting and filtering. * `:pageSize` (*type:* `integer()`) - The maximum number of results to return in a single response. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListAlertPoliciesResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_alert_policies_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListAlertPoliciesResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_alert_policies_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :orderBy => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/alertPolicies", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListAlertPoliciesResponse{}] ) end @doc """ Updates an alerting policy. You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via updateMask. Returns the updated alerting policy. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `alertPolicy.name`. Required if the policy exists. The resource name for this policy. The syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] [ALERT_POLICY_ID] is assigned by Stackdriver Monitoring when the policy is created. When calling the alertPolicies.create method, do not include the name field in the alerting policy passed as part of the request. * `alert_policies_id` (*type:* `String.t`) - Part of `alertPolicy.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:updateMask` (*type:* `String.t`) - Optional. A list of alerting policy field names. If this field is not empty, each listed field in the existing alerting policy is set to the value of the corresponding field in the supplied policy (alert_policy), or to the field's default value if the field is not in the supplied alerting policy. Fields not listed retain their previous value.Examples of valid field masks include display_name, documentation, documentation.content, documentation.mime_type, user_labels, user_label.nameofkey, enabled, conditions, combiner, etc.If this field is empty, then the supplied alerting policy replaces the existing policy. It is the same as deleting the existing policy and adding the supplied policy, except for the following: The new policy will have the same [ALERT_POLICY_ID] as the former policy. This gives you continuity with the former policy in your notifications and incidents. Conditions in the new policy will keep their former [CONDITION_ID] if the supplied condition includes the name field with that [CONDITION_ID]. If the supplied condition omits the name field, then a new [CONDITION_ID] is created. * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.AlertPolicy.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.AlertPolicy{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_alert_policies_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.AlertPolicy.t()} | {:error, Tesla.Env.t()} def monitoring_projects_alert_policies_patch( connection, projects_id, alert_policies_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v3/projects/{projectsId}/alertPolicies/{alertPoliciesId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "alertPoliciesId" => URI.encode(alert_policies_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.AlertPolicy{}]) end @doc """ Stackdriver Monitoring Agent only: Creates a new time series.<aside class="caution">This method is only for use by the Stackdriver Monitoring Agent. Use projects.timeSeries.create instead.</aside> ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project in which to create the time series. The format is "projects/PROJECT_ID_OR_NUMBER". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.CreateCollectdTimeSeriesRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.CreateCollectdTimeSeriesResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_collectd_time_series_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.CreateCollectdTimeSeriesResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_collectd_time_series_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/collectdTimeSeries", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.CreateCollectdTimeSeriesResponse{}] ) end @doc """ Creates a new group. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project in which to create the group. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:validateOnly` (*type:* `boolean()`) - If true, validate this request but do not create the group. * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.Group.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Group{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_create(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Monitoring.V3.Model.Group.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :validateOnly => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/groups", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Group{}]) end @doc """ Deletes an existing group. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The group to delete. The format is "projects/{project_id_or_number}/groups/{group_id}". * `groups_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:recursive` (*type:* `boolean()`) - If this field is true, then the request means to delete a group with all its descendants. Otherwise, the request means to delete a group only when it has no descendants. The default value is false. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_delete( connection, projects_id, groups_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :recursive => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v3/projects/{projectsId}/groups/{groupsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "groupsId" => URI.encode(groups_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Gets a single group. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The group to retrieve. The format is "projects/{project_id_or_number}/groups/{group_id}". * `groups_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Group{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Group.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_get( connection, projects_id, groups_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/groups/{groupsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "groupsId" => URI.encode(groups_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Group{}]) end @doc """ Lists the existing groups. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project whose groups are to be listed. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:ancestorsOfGroup` (*type:* `String.t`) - A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns groups that are ancestors of the specified group. The groups are returned in order, starting with the immediate parent and ending with the most distant ancestor. If the specified group has no immediate parent, the results are empty. * `:childrenOfGroup` (*type:* `String.t`) - A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns groups whose parentName field contains the group name. If no groups have this parent, the results are empty. * `:descendantsOfGroup` (*type:* `String.t`) - A group name: "projects/{project_id_or_number}/groups/{group_id}". Returns the descendants of the specified group. This is a superset of the results returned by the childrenOfGroup filter, and includes children-of-children, and so forth. * `:pageSize` (*type:* `integer()`) - A positive number that is the maximum number of results to return. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListGroupsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Monitoring.V3.Model.ListGroupsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_list(connection, projects_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :ancestorsOfGroup => :query, :childrenOfGroup => :query, :descendantsOfGroup => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/groups", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListGroupsResponse{}]) end @doc """ Updates an existing group. You can change any group attributes except name. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `group.name`. Output only. The name of this group. The format is "projects/{project_id_or_number}/groups/{group_id}". When creating a group, this field is ignored and a new name is created consisting of the project specified in the call to CreateGroup and a unique {group_id} that is generated automatically. * `groups_id` (*type:* `String.t`) - Part of `group.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:validateOnly` (*type:* `boolean()`) - If true, validate this request but do not update the existing group. * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.Group.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Group{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_update( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Group.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_update( connection, projects_id, groups_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :validateOnly => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v3/projects/{projectsId}/groups/{groupsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "groupsId" => URI.encode(groups_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Group{}]) end @doc """ Lists the monitored resources that are members of a group. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The group whose members are listed. The format is "projects/{project_id_or_number}/groups/{group_id}". * `groups_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:filter` (*type:* `String.t`) - An optional list filter describing the members to be returned. The filter may reference the type, labels, and metadata of monitored resources that comprise the group. For example, to return only resources representing Compute Engine VM instances, use this filter: resource.type = "gce_instance" * `:interval.endTime` (*type:* `DateTime.t`) - Required. The end of the time interval. * `:interval.startTime` (*type:* `DateTime.t`) - Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time. * `:pageSize` (*type:* `integer()`) - A positive number that is the maximum number of results to return. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListGroupMembersResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_groups_members_list( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListGroupMembersResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_groups_members_list( connection, projects_id, groups_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :"interval.endTime" => :query, :"interval.startTime" => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/groups/{groupsId}/members", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "groupsId" => URI.encode(groups_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListGroupMembersResponse{}] ) end @doc """ Creates a new metric descriptor. User-created metric descriptors define custom metrics. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.MetricDescriptor.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.MetricDescriptor{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_metric_descriptors_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.MetricDescriptor.t()} | {:error, Tesla.Env.t()} def monitoring_projects_metric_descriptors_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/metricDescriptors", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.MetricDescriptor{}]) end @doc """ Deletes a metric descriptor. Only user-created custom metrics can be deleted. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The metric descriptor on which to execute the request. The format is "projects/{project_id_or_number}/metricDescriptors/{metric_id}". An example of {metric_id} is: "custom.googleapis.com/my_test_metric". * `metric_descriptors_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_metric_descriptors_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_metric_descriptors_delete( connection, projects_id, metric_descriptors_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v3/projects/{projectsId}/metricDescriptors/{metricDescriptorsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "metricDescriptorsId" => URI.encode(metric_descriptors_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Gets a single metric descriptor. This method does not require a Stackdriver account. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The metric descriptor on which to execute the request. The format is "projects/{project_id_or_number}/metricDescriptors/{metric_id}". An example value of {metric_id} is "compute.googleapis.com/instance/disk/read_bytes_count". * `metric_descriptors_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.MetricDescriptor{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_metric_descriptors_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.MetricDescriptor.t()} | {:error, Tesla.Env.t()} def monitoring_projects_metric_descriptors_get( connection, projects_id, metric_descriptors_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/metricDescriptors/{metricDescriptorsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "metricDescriptorsId" => URI.encode(metric_descriptors_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.MetricDescriptor{}]) end @doc """ Lists metric descriptors that match a filter. This method does not require a Stackdriver account. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:filter` (*type:* `String.t`) - If this field is empty, all custom and system-defined metric descriptors are returned. Otherwise, the filter specifies which metric descriptors are to be returned. For example, the following filter matches all custom metrics: metric.type = starts_with("custom.googleapis.com/") * `:pageSize` (*type:* `integer()`) - A positive number that is the maximum number of results to return. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListMetricDescriptorsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_metric_descriptors_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListMetricDescriptorsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_metric_descriptors_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/metricDescriptors", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListMetricDescriptorsResponse{}] ) end @doc """ Gets a single monitored resource descriptor. This method does not require a Stackdriver account. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The monitored resource descriptor to get. The format is "projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}". The {resource_type} is a predefined type, such as cloudsql_database. * `monitored_resource_descriptors_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.MonitoredResourceDescriptor{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_monitored_resource_descriptors_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.MonitoredResourceDescriptor.t()} | {:error, Tesla.Env.t()} def monitoring_projects_monitored_resource_descriptors_get( connection, projects_id, monitored_resource_descriptors_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url( "/v3/projects/{projectsId}/monitoredResourceDescriptors/{monitoredResourceDescriptorsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "monitoredResourceDescriptorsId" => URI.encode(monitored_resource_descriptors_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.MonitoredResourceDescriptor{}] ) end @doc """ Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:filter` (*type:* `String.t`) - An optional filter describing the descriptors to be returned. The filter can reference the descriptor's type and labels. For example, the following filter returns only Google Compute Engine descriptors that have an id label: resource.type = starts_with("gce_") AND resource.label:id * `:pageSize` (*type:* `integer()`) - A positive number that is the maximum number of results to return. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListMonitoredResourceDescriptorsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_monitored_resource_descriptors_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListMonitoredResourceDescriptorsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_monitored_resource_descriptors_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/monitoredResourceDescriptors", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListMonitoredResourceDescriptorsResponse{}] ) end @doc """ Gets a single channel descriptor. The descriptor indicates which fields are expected / permitted for a notification channel of the given type. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The channel type for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}. * `notification_channel_descriptors_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.NotificationChannelDescriptor{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channel_descriptors_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.NotificationChannelDescriptor.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channel_descriptors_get( connection, projects_id, notification_channel_descriptors_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url( "/v3/projects/{projectsId}/notificationChannelDescriptors/{notificationChannelDescriptorsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelDescriptorsId" => URI.encode(notification_channel_descriptors_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.NotificationChannelDescriptor{}] ) end @doc """ Lists the descriptors for supported channel types. The use of descriptors makes it possible for new channel types to be dynamically added. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The REST resource name of the parent from which to retrieve the notification channel descriptors. The expected syntax is: projects/[PROJECT_ID] Note that this names the parent container in which to look for the descriptors; to retrieve a single descriptor by name, use the GetNotificationChannelDescriptor operation, instead. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - The maximum number of results to return in a single response. If not set to a positive number, a reasonable value will be chosen by the service. * `:pageToken` (*type:* `String.t`) - If non-empty, page_token must contain a value returned as the next_page_token in a previous response to request the next set of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListNotificationChannelDescriptorsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channel_descriptors_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListNotificationChannelDescriptorsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channel_descriptors_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/notificationChannelDescriptors", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListNotificationChannelDescriptorsResponse{}] ) end @doc """ Creates a new notification channel, representing a single notification endpoint such as an email address, SMS number, or PagerDuty service. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is: projects/[PROJECT_ID] Note that this names the container into which the channel will be written. This does not name the newly created channel. The resulting channel's name will have a normalized version of this field as a prefix, but will add /notificationChannels/[CHANNEL_ID] to identify the channel. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.NotificationChannel.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.NotificationChannel{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.NotificationChannel.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/notificationChannels", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.NotificationChannel{}]) end @doc """ Deletes a notification channel. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The channel for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]. * `notification_channels_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:force` (*type:* `boolean()`) - If true, the notification channel will be deleted regardless of its use in alert policies (the policies will be updated to remove the channel). If false, channels that are still referenced by an existing alerting policy will fail to be deleted in a delete operation. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_delete( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :force => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Gets a single notification channel. The channel includes the relevant configuration details with which the channel was created. However, the response may truncate or omit passwords, API keys, or other private key matter and thus the response may not be 100% identical to the information that was supplied in the call to the create method. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The channel for which to execute the request. The format is projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]. * `notification_channels_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.NotificationChannel{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.NotificationChannel.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_get( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.NotificationChannel{}]) end @doc """ Requests a verification code for an already verified channel that can then be used in a call to VerifyNotificationChannel() on a different channel with an equivalent identity in the same or in a different project. This makes it possible to copy a channel between projects without requiring manual reverification of the channel. If the channel is not in the verified state, this method will fail (in other words, this may only be used if the SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been used to put the given channel into the verified state).There is no guarantee that the verification codes returned by this method will be of a similar structure or form as the ones that are delivered to the channel via SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both the codes delivered via SendNotificationChannelVerificationCode() and returned from GetNotificationChannelVerificationCode(), it is typically the case that the verification codes delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return a much longer, websafe base 64 encoded string that has a longer expiration time. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The notification channel for which a verification code is to be generated and retrieved. This must name a channel that is already verified; if the specified channel is not verified, the request will fail. * `notification_channels_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.GetNotificationChannelVerificationCodeRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.GetNotificationChannelVerificationCodeResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_get_verification_code( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.GetNotificationChannelVerificationCodeResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_get_verification_code( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}:getVerificationCode", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.GetNotificationChannelVerificationCodeResponse{}] ) end @doc """ Lists the notification channels that have been created for the project. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is projects/[PROJECT_ID]. That is, this names the container in which to look for the notification channels; it does not name a specific channel. To query a specific channel by REST resource name, use the GetNotificationChannel operation. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:filter` (*type:* `String.t`) - If provided, this field specifies the criteria that must be met by notification channels to be included in the response.For more details, see sorting and filtering. * `:orderBy` (*type:* `String.t`) - A comma-separated list of fields by which to sort the result. Supports the same set of fields as in filter. Entries can be prefixed with a minus sign to sort in descending rather than ascending order.For more details, see sorting and filtering. * `:pageSize` (*type:* `integer()`) - The maximum number of results to return in a single response. If not set to a positive number, a reasonable value will be chosen by the service. * `:pageToken` (*type:* `String.t`) - If non-empty, page_token must contain a value returned as the next_page_token in a previous response to request the next set of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListNotificationChannelsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListNotificationChannelsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :orderBy => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/notificationChannels", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListNotificationChannelsResponse{}] ) end @doc """ Updates a notification channel. Fields not specified in the field mask remain unchanged. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `notificationChannel.name`. The full REST resource name for this channel. The syntax is: projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID] The [CHANNEL_ID] is automatically assigned by the server on creation. * `notification_channels_id` (*type:* `String.t`) - Part of `notificationChannel.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:updateMask` (*type:* `String.t`) - The fields to update. * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.NotificationChannel.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.NotificationChannel{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.NotificationChannel.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_patch( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.NotificationChannel{}]) end @doc """ Causes a verification code to be delivered to the channel. The code can then be supplied in VerifyNotificationChannel to verify the channel. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The notification channel to which to send a verification code. * `notification_channels_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.SendNotificationChannelVerificationCodeRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_send_verification_code( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_send_verification_code( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}:sendVerificationCode", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Verifies a NotificationChannel by proving receipt of the code delivered to the channel as a result of calling SendNotificationChannelVerificationCode. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The notification channel to verify. * `notification_channels_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.VerifyNotificationChannelRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.NotificationChannel{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_notification_channels_verify( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.NotificationChannel.t()} | {:error, Tesla.Env.t()} def monitoring_projects_notification_channels_verify( connection, projects_id, notification_channels_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v3/projects/{projectsId}/notificationChannels/{notificationChannelsId}:verify", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "notificationChannelsId" => URI.encode(notification_channels_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.NotificationChannel{}]) end @doc """ Creates or adds data to one or more time series. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.CreateTimeSeriesRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_time_series_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_time_series_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/timeSeries", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Lists time series that match a filter. This method does not require a Stackdriver account. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The project on which to execute the request. The format is "projects/{project_id_or_number}". * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:aggregation.alignmentPeriod` (*type:* `String.t`) - The alignment period for per-time series alignment. If present, alignmentPeriod must be at least 60 seconds. After per-time series alignment, each time series will contain data points only on the period boundaries. If perSeriesAligner is not specified or equals ALIGN_NONE, then this field is ignored. If perSeriesAligner is specified and does not equal ALIGN_NONE, then this field must be defined; otherwise an error is returned. * `:aggregation.crossSeriesReducer` (*type:* `String.t`) - The approach to be used to combine time series. Not all reducer functions may be applied to all time series, depending on the metric type and the value type of the original time series. Reduction may change the metric type of value type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If crossSeriesReducer is specified, then perSeriesAligner must be specified and not equal ALIGN_NONE and alignmentPeriod must be specified; otherwise, an error is returned. * `:aggregation.groupByFields` (*type:* `list(String.t)`) - The set of fields to preserve when crossSeriesReducer is specified. The groupByFields determine how the time series are partitioned into subsets prior to applying the aggregation function. Each subset contains time series that have the same value for each of the grouping fields. Each individual time series is a member of exactly one subset. The crossSeriesReducer is applied to each subset of time series. It is not possible to reduce across different resource types, so this field implicitly contains resource.type. Fields not specified in groupByFields are aggregated away. If groupByFields is not specified and all the time series have the same resource type, then the time series are aggregated into a single output time series. If crossSeriesReducer is not defined, this field is ignored. * `:aggregation.perSeriesAligner` (*type:* `String.t`) - The approach to be used to align individual time series. Not all alignment functions may be applied to all time series, depending on the metric type and value type of the original time series. Alignment may change the metric type or the value type of the time series.Time series data must be aligned in order to perform cross-time series reduction. If crossSeriesReducer is specified, then perSeriesAligner must be specified and not equal ALIGN_NONE and alignmentPeriod must be specified; otherwise, an error is returned. * `:filter` (*type:* `String.t`) - A monitoring filter that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example: metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.labels.instance_name = "my-instance-name" * `:interval.endTime` (*type:* `DateTime.t`) - Required. The end of the time interval. * `:interval.startTime` (*type:* `DateTime.t`) - Optional. The beginning of the time interval. The default value for the start time is the end time. The start time must not be later than the end time. * `:orderBy` (*type:* `String.t`) - Unsupported: must be left blank. The points in each time series are returned in reverse time order. * `:pageSize` (*type:* `integer()`) - A positive number that is the maximum number of results to return. If page_size is empty or more than 100,000 results, the effective page_size is 100,000 results. If view is set to FULL, this is the maximum number of Points returned. If view is set to HEADERS, this is the maximum number of TimeSeries returned. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return additional results from the previous method call. * `:view` (*type:* `String.t`) - Specifies which information is returned about the time series. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListTimeSeriesResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_time_series_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Monitoring.V3.Model.ListTimeSeriesResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_time_series_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :"aggregation.alignmentPeriod" => :query, :"aggregation.crossSeriesReducer" => :query, :"aggregation.groupByFields" => :query, :"aggregation.perSeriesAligner" => :query, :filter => :query, :"interval.endTime" => :query, :"interval.startTime" => :query, :orderBy => :query, :pageSize => :query, :pageToken => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/timeSeries", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListTimeSeriesResponse{}]) end @doc """ Creates a new uptime check configuration. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `parent`. The project in which to create the uptime check. The format is projects/[PROJECT_ID]. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.UptimeCheckConfig.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_uptime_check_configs_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.UptimeCheckConfig.t()} | {:error, Tesla.Env.t()} def monitoring_projects_uptime_check_configs_create( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v3/projects/{projectsId}/uptimeCheckConfigs", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}]) end @doc """ Deletes an uptime check configuration. Note that this method will fail if the uptime check configuration is referenced by an alert policy or other dependent configs that would be rendered invalid by the deletion. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The uptime check configuration to delete. The format is projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]. * `uptime_check_configs_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_uptime_check_configs_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.Empty.t()} | {:error, Tesla.Env.t()} def monitoring_projects_uptime_check_configs_delete( connection, projects_id, uptime_check_configs_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v3/projects/{projectsId}/uptimeCheckConfigs/{uptimeCheckConfigsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "uptimeCheckConfigsId" => URI.encode(uptime_check_configs_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.Empty{}]) end @doc """ Gets a single uptime check configuration. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. The uptime check configuration to retrieve. The format is projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]. * `uptime_check_configs_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_uptime_check_configs_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.UptimeCheckConfig.t()} | {:error, Tesla.Env.t()} def monitoring_projects_uptime_check_configs_get( connection, projects_id, uptime_check_configs_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/uptimeCheckConfigs/{uptimeCheckConfigsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "uptimeCheckConfigsId" => URI.encode(uptime_check_configs_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}]) end @doc """ Lists the existing valid uptime check configurations for the project, leaving out any invalid configurations. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `parent`. The project whose uptime check configurations are listed. The format is projects/[PROJECT_ID]. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - The maximum number of results to return in a single response. The server may further constrain the maximum number of results returned in a single page. If the page_size is <=0, the server will decide the number of results to be returned. * `:pageToken` (*type:* `String.t`) - If this field is not empty then it must contain the nextPageToken value returned by a previous call to this method. Using this field causes the method to return more results from the previous method call. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.ListUptimeCheckConfigsResponse{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_uptime_check_configs_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.ListUptimeCheckConfigsResponse.t()} | {:error, Tesla.Env.t()} def monitoring_projects_uptime_check_configs_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v3/projects/{projectsId}/uptimeCheckConfigs", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Monitoring.V3.Model.ListUptimeCheckConfigsResponse{}] ) end @doc """ Updates an uptime check configuration. You can either replace the entire configuration with a new one or replace only certain fields in the current configuration by specifying the fields to be updated via "updateMask". Returns the updated configuration. ## Parameters * `connection` (*type:* `GoogleApi.Monitoring.V3.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `uptimeCheckConfig.name`. A unique resource name for this UptimeCheckConfig. The format is:projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID].This field should be omitted when creating the uptime check configuration; on create, the resource name is assigned by the server and included in the response. * `uptime_check_configs_id` (*type:* `String.t`) - Part of `uptimeCheckConfig.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:updateMask` (*type:* `String.t`) - Optional. If present, only the listed fields in the current uptime check configuration are updated with values from the new configuration. If this field is empty, then the current configuration is completely replaced with the new configuration. * `:body` (*type:* `GoogleApi.Monitoring.V3.Model.UptimeCheckConfig.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}}` on success * `{:error, info}` on failure """ @spec monitoring_projects_uptime_check_configs_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Monitoring.V3.Model.UptimeCheckConfig.t()} | {:error, Tesla.Env.t()} def monitoring_projects_uptime_check_configs_patch( connection, projects_id, uptime_check_configs_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v3/projects/{projectsId}/uptimeCheckConfigs/{uptimeCheckConfigsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "uptimeCheckConfigsId" => URI.encode(uptime_check_configs_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Monitoring.V3.Model.UptimeCheckConfig{}]) end end
50.484109
1,300
0.6384
73efb1d68f33ee34be4ee10182ed6cb54722fdf1
200
exs
Elixir
test/oli_web/controllers/static_page_controller_test.exs
DevShashi1993/oli-torus
e6e0b66f0973f9790a5785731b22db6fb1c50a73
[ "MIT" ]
45
2020-04-17T15:40:27.000Z
2022-03-25T00:13:30.000Z
test/oli_web/controllers/static_page_controller_test.exs
DevShashi1993/oli-torus
e6e0b66f0973f9790a5785731b22db6fb1c50a73
[ "MIT" ]
944
2020-02-13T02:37:01.000Z
2022-03-31T17:50:07.000Z
test/oli_web/controllers/static_page_controller_test.exs
DevShashi1993/oli-torus
e6e0b66f0973f9790a5785731b22db6fb1c50a73
[ "MIT" ]
23
2020-07-28T03:36:13.000Z
2022-03-17T14:29:02.000Z
defmodule OliWeb.StaticPageControllerTest do use OliWeb.ConnCase test "GET /", %{conn: conn} do conn = get(conn, "/") assert html_response(conn, 200) =~ "Welcome to OLI Torus!" end end
22.222222
62
0.675
73efb87746ec59e1b04fd0e94f3f8906e9fbbe98
563
ex
Elixir
lib/console_web/views/config_profile_view.ex
maco2035/console
2a9a65678b8c671c7d92cdb62dfcfc71b84957c5
[ "Apache-2.0" ]
83
2018-05-31T14:49:10.000Z
2022-03-27T16:49:49.000Z
lib/console_web/views/config_profile_view.ex
maco2035/console
2a9a65678b8c671c7d92cdb62dfcfc71b84957c5
[ "Apache-2.0" ]
267
2018-05-22T23:19:02.000Z
2022-03-31T04:31:06.000Z
lib/console_web/views/config_profile_view.ex
maco2035/console
2a9a65678b8c671c7d92cdb62dfcfc71b84957c5
[ "Apache-2.0" ]
18
2018-11-20T05:15:54.000Z
2022-03-28T08:20:13.000Z
defmodule ConsoleWeb.ConfigProfileView do use ConsoleWeb, :view alias ConsoleWeb.ConfigProfileView def render("show.json", %{config_profile: config_profile}) do render_one(config_profile, ConfigProfileView, "config_profile.json") end def render("config_profile.json", %{config_profile: config_profile}) do %{ id: config_profile.id, name: config_profile.name, organization_id: config_profile.organization_id, adr_allowed: config_profile.adr_allowed, cf_list_enabled: config_profile.cf_list_enabled } end end
29.631579
73
0.751332
73efd0a7ac389684bcedbcab74ce83b579c944b4
207
exs
Elixir
src/priv/repo/migrations/20211004013501_create_pokemons.exs
ivanrosolen/how-to-elixir-phoenix
0ee910a1662e5c6cc1a6c781be6eeef99839badb
[ "MIT" ]
null
null
null
src/priv/repo/migrations/20211004013501_create_pokemons.exs
ivanrosolen/how-to-elixir-phoenix
0ee910a1662e5c6cc1a6c781be6eeef99839badb
[ "MIT" ]
null
null
null
src/priv/repo/migrations/20211004013501_create_pokemons.exs
ivanrosolen/how-to-elixir-phoenix
0ee910a1662e5c6cc1a6c781be6eeef99839badb
[ "MIT" ]
null
null
null
defmodule Ivan.Repo.Migrations.CreatePokemons do use Ecto.Migration def change do create table(:pokemons) do add :name, :string add :type, :string timestamps() end end end
14.785714
48
0.657005
73f01a7765dd6b9d5ced4a15f5fa1d4c2db613da
731
ex
Elixir
backend/apps/login_token_cache/lib/login_token_cache.ex
KyivKrishnaAcademy/students_crm_v2
e0ad9b3c5e52dfef5ab8f9179f3c593f935786e6
[ "MIT" ]
null
null
null
backend/apps/login_token_cache/lib/login_token_cache.ex
KyivKrishnaAcademy/students_crm_v2
e0ad9b3c5e52dfef5ab8f9179f3c593f935786e6
[ "MIT" ]
50
2018-07-29T09:17:35.000Z
2019-02-26T05:23:34.000Z
backend/apps/login_token_cache/lib/login_token_cache.ex
KyivKrishnaAcademy/students_crm_v2
e0ad9b3c5e52dfef5ab8f9179f3c593f935786e6
[ "MIT" ]
null
null
null
defmodule LoginTokenCache do @moduledoc false def get(key) do value = ConCache.get(:login_token_cache, key) ConCache.delete(:login_token_cache, key) responce(value) end def generate(value) do generate(value, 1) end defp generate(value, seq_number) do key = random_string(5 + div(seq_number, 5)) case ConCache.insert_new(:login_token_cache, key, value) do :ok -> key {:error, :already_exists} -> generate(value, seq_number + 1) end end defp random_string(length) do length |> :crypto.strong_rand_bytes() |> Base.encode32() |> binary_part(0, length) end defp responce(nil), do: {:error, :no_token_found} defp responce(value), do: {:ok, value} end
20.885714
66
0.666211
73f0519b00d216e9f039bd6b34731dd9c981b451
9,848
ex
Elixir
gherkin/elixir/lib/gherkin/pickle_compiler/pickle_compiler.ex
lamkr/cucumber-common
914bc5cd72198eb4dd93d7228f2e167a16e23ac3
[ "MIT" ]
3,974
2015-01-01T10:21:24.000Z
2021-05-07T09:51:49.000Z
gherkin/elixir/lib/gherkin/pickle_compiler/pickle_compiler.ex
lamkr/cucumber-common
914bc5cd72198eb4dd93d7228f2e167a16e23ac3
[ "MIT" ]
1,298
2015-01-01T08:19:06.000Z
2021-05-07T17:12:31.000Z
gherkin/elixir/lib/gherkin/pickle_compiler/pickle_compiler.ex
lamkr/cucumber-common
914bc5cd72198eb4dd93d7228f2e167a16e23ac3
[ "MIT" ]
923
2015-01-02T16:14:05.000Z
2021-05-05T05:59:48.000Z
defmodule CucumberGherkin.PickleCompiler do @moduledoc false defstruct id_gen: nil, pickles: [], language: nil, uri: nil alias CucumberMessages.GherkinDocument.Feature, as: FeatureMessage alias CucumberMessages.GherkinDocument.Feature.Scenario, as: ScenarioMessage alias CucumberMessages.GherkinDocument.Feature.Step, as: StepMessage alias CucumberMessages.GherkinDocument.Feature.TableRow, as: TableRowMessage alias CucumberMessages.Pickle, as: PickleMessage alias CucumberMessages.Pickle.PickleStep, as: PickleStepMessage alias CucumberMessages.Pickle.PickleTag, as: PickleTagMessage alias CucumberMessages.GherkinDocument.Feature.Tag, as: TagMessage alias CucumberMessages.GherkinDocument.Feature.FeatureChild, as: FeatureChildMessage alias CucumberMessages.GherkinDocument.Feature.FeatureChild.Rule, as: RuleMessage alias CucumberMessages.GherkinDocument.Feature.Scenario.Examples, as: ExampleMessage alias CucumberMessages.PickleStepArgument.PickleTable, as: PickleTableMessage alias CucumberMessages.PickleStepArgument.PickleTable.PickleTableRow.PickleTableCell, as: PickleTableCellMessage alias CucumberMessages.PickleStepArgument.PickleTable.PickleTableRow, as: PickleTableRowMessage alias CucumberMessages.GherkinDocument.Feature.Step.DataTable, as: DataTableMessage @me __MODULE__ def compile(%CucumberGherkin.AstBuilder{gherkin_doc: gherkin_doc, id_gen: id_generator}, uri) do me = %@me{id_gen: id_generator, uri: uri} case compile_feature(gherkin_doc.feature, me) do %{pickles: pickles} -> pickles [] -> [] end end defp compile_feature(nil, %@me{pickles: p} = _compiler_acc), do: p defp compile_feature(%FeatureMessage{} = f, %@me{} = compiler_acc) do meta_info = %{ feature_backgr_steps: [], rule_backgr_steps: [], pickles: [], feature_tags: f.tags, compiler_acc: %{compiler_acc | language: f.language} } Enum.reduce(f.children, meta_info, fn child, m_acc -> case child.value do {:background, bg} -> %{m_acc | feature_backgr_steps: bg.steps} {:rule, rule} -> compile_rule(m_acc, rule) {:scenario, s} -> compile_scenario(m_acc, s, :feature_backgr_steps) end end) end defp compile_rule(meta_info, %RuleMessage{} = r) do resetted_meta_info = %{meta_info | rule_backgr_steps: meta_info.feature_backgr_steps} rule_tags = meta_info.feature_tags ++ r.tags Enum.reduce(r.children, resetted_meta_info, fn %FeatureChildMessage{value: {:background, bg}}, m_acc -> %{m_acc | rule_backgr_steps: m_acc.rule_backgr_steps ++ bg.steps} %FeatureChildMessage{value: {:scenario, s}}, m_acc -> %{m_acc | feature_tags: rule_tags} |> compile_scenario(s, :rule_backgr_steps) end) end # Match for a normal scenario. NOT a scenario outline. NO examples. defp compile_scenario(m, %ScenarioMessage{examples: []} = s, feature_or_rule_bg_steps?) do {steps, semi_updated_acc} = case s.steps do [] -> {[], m.compiler_acc} list_of_steps -> (Map.fetch!(m, feature_or_rule_bg_steps?) ++ list_of_steps) |> pickle_steps(m.compiler_acc) end pickle_tags = [m.feature_tags | s.tags] |> List.flatten() |> pickle_tags() {id, updated_compiler_acc} = get_id_and_update_compiler_acc(semi_updated_acc) new_msg = %PickleMessage{ id: id, uri: m.compiler_acc.uri, name: s.name, language: m.compiler_acc.language, steps: steps, tags: pickle_tags, ast_node_ids: [s.id] } %{m | pickles: [new_msg | m.pickles], compiler_acc: updated_compiler_acc} end # When there are examples, it is a scenario outline defp compile_scenario(m, %ScenarioMessage{examples: examples} = s, feature_or_rule_bg_steps?) do Enum.reduce(examples, m, fn %ExampleMessage{} = example, m_acc -> scenario_outline_create_pickles( m_acc, example, s, feature_or_rule_bg_steps?, example.table_header ) end) end defp scenario_outline_create_pickles(m, _e, _s, _f_or_bg?, nil), do: m defp scenario_outline_create_pickles(m, example, s, f_or_bg?, table_header) do Enum.reduce(example.table_body, m, fn value_row, m_acc -> {steps, updated_acc} = case s.steps do [] -> {[], m_acc.compiler_acc} _steplist -> Map.fetch!(m_acc, f_or_bg?) |> pickle_steps(m_acc.compiler_acc) end {updated_steps, updated_acc} = Enum.reduce(s.steps, {steps, updated_acc}, fn scen_outline_step, {step_acc, c_acc} -> {newly_created_step, new_c_acc} = pickle_step_creator(scen_outline_step, table_header.cells, value_row, c_acc) {step_acc ++ [newly_created_step], new_c_acc} end) tags = m_acc.feature_tags ++ s.tags ++ example.tags pickle_tags = tags |> List.flatten() |> pickle_tags() {id, updated_acc} = get_id_and_update_compiler_acc(updated_acc) new_msg = %PickleMessage{ id: id, uri: m_acc.compiler_acc.uri, name: interpolate(s.name, table_header.cells, value_row.cells), language: m_acc.compiler_acc.language, steps: updated_steps, tags: pickle_tags, ast_node_ids: [s.id, value_row.id] } %{m_acc | pickles: [new_msg | m_acc.pickles], compiler_acc: updated_acc} end) end #################### # Helper functions # #################### defp pickle_tags(list_of_tag_messages), do: Enum.map(list_of_tag_messages, &pickle_tag/1) defp pickle_tag(%TagMessage{} = t), do: %PickleTagMessage{ast_node_id: t.id, name: t.name} defp pickle_steps(step_messages, %@me{} = acc) do {reversed_msges, new_acc} = Enum.reduce(step_messages, {[], acc}, fn message, {pickle_steps_acc, compiler_acc} -> {pickle_step, updated_acc} = pickle_step(message, compiler_acc) {[pickle_step | pickle_steps_acc], updated_acc} end) {Enum.reverse(reversed_msges), new_acc} end defp pickle_step(%StepMessage{} = m, %@me{} = acc), do: pickle_step_creator(m, [], nil, acc) defp pickle_step_creator(%StepMessage{} = m, variable_cells, values_row, %@me{} = acc) do value_cells = case values_row do nil -> [] data -> data.cells end step_text = interpolate(m.text, variable_cells, value_cells) {id, updated_compiler_acc} = get_id_and_update_compiler_acc(acc) message = %PickleStepMessage{id: id, ast_node_ids: [m.id], text: step_text} |> add_ast_node_id(values_row) |> add_datatable(m, variable_cells, value_cells) |> add_doc_string(m, variable_cells, value_cells) {message, updated_compiler_acc} end defp interpolate(text, variable_cells, value_cells) do variable_cells |> Enum.zip(value_cells) |> Enum.reduce(text, fn {variable_cell, value_cell}, text -> String.replace(text, "<#{variable_cell.value}>", value_cell.value) end) end defp pickle_data_table_creator(%DataTableMessage{} = data_table, variable_cells, value_cells) do table_row_messages = Enum.reduce(data_table.rows, [], fn %TableRowMessage{} = row, pickle_table_rows_acc -> new_cells = Enum.reduce(row.cells, [], fn cell, pickle_table_cell_acc -> new_table_cell_message = %PickleTableCellMessage{ value: interpolate(cell.value, variable_cells, value_cells) } [new_table_cell_message | pickle_table_cell_acc] end) |> Enum.reverse() [%PickleTableRowMessage{cells: new_cells} | pickle_table_rows_acc] end) |> Enum.reverse() %PickleTableMessage{rows: table_row_messages} end alias CucumberMessages.PickleStepArgument.PickleDocString, as: PickleDocStringMessage alias CucumberMessages.GherkinDocument.Feature.Step.DocString, as: DocStringMessage defp pickle_doc_string_creator(%DocStringMessage{} = d, variable_cells, value_cells) do content = interpolate(d.content, variable_cells, value_cells) media_type = case d.media_type do "" -> "" media_type -> interpolate(media_type, variable_cells, value_cells) end %PickleDocStringMessage{content: content, media_type: media_type} end #################################################### # Extra Helper functions to reduce "If nil" horror # #################################################### defp add_ast_node_id(%PickleStepMessage{} = m, nil), do: m defp add_ast_node_id(%PickleStepMessage{ast_node_ids: ids} = m, %TableRowMessage{} = row), do: %{m | ast_node_ids: ids ++ [row.id]} defp add_datatable(%PickleStepMessage{} = m, %StepMessage{argument: nil}, _, _), do: m defp add_datatable(%PickleStepMessage{} = m, %StepMessage{argument: {:doc_string, _}}, _, _), do: m defp add_datatable( %PickleStepMessage{} = m, %StepMessage{argument: {:data_table, d}}, variable_cells, value_cells ) do result = pickle_data_table_creator(d, variable_cells, value_cells) %{m | argument: result} end defp add_doc_string(%PickleStepMessage{} = m, %StepMessage{argument: nil}, _, _), do: m defp add_doc_string(%PickleStepMessage{} = m, %StepMessage{argument: {:data_table, _}}, _, _), do: m defp add_doc_string( %PickleStepMessage{} = m, %StepMessage{argument: {:doc_string, d}}, variable_cells, value_cells ) do result = pickle_doc_string_creator(d, variable_cells, value_cells) %{m | argument: result} end defp get_id_and_update_compiler_acc(%@me{id_gen: gen} = compiler_acc) do {id, updated_generator} = CucumberGherkin.IdGenerator.get_id(gen) updated_acc = %{compiler_acc | id_gen: updated_generator} {id, updated_acc} end end
35.681159
98
0.677498
73f06ca194c9165431aaf7dd44e3c7b92b1eb342
2,269
exs
Elixir
test/changelog_web/controllers/news_item_comment_controller_test.exs
axelson/changelog.com
bad9f461aabbde0faa938f7b2ae643ed47d1df9b
[ "MIT" ]
1
2021-01-06T18:21:45.000Z
2021-01-06T18:21:45.000Z
test/changelog_web/controllers/news_item_comment_controller_test.exs
codexn/changelog.com
25ce501ee62eef76731c38d590667e8132096ba8
[ "MIT" ]
null
null
null
test/changelog_web/controllers/news_item_comment_controller_test.exs
codexn/changelog.com
25ce501ee62eef76731c38d590667e8132096ba8
[ "MIT" ]
null
null
null
defmodule ChangelogWeb.NewsItemCommentControllerTest do use ChangelogWeb.ConnCase import Mock alias Changelog.{NewsItemComment, Notifier} @tag :as_user test "previewing a comment", %{conn: conn} do conn = post(conn, Routes.news_item_comment_path(conn, :preview), md: "## Ohai!") assert html_response(conn, 200) =~ "<h2>Ohai!</h2>" end test "does not create with no user", %{conn: conn} do item = insert(:published_news_item) count_before = count(NewsItemComment) conn = post(conn, Routes.news_item_comment_path(conn, :create), news_item_comment: %{content: "how dare thee!", item_id: item.id} ) assert redirected_to(conn) == Routes.sign_in_path(conn, :new) assert count(NewsItemComment) == count_before end @tag :as_inserted_user test "does not create with no item id", %{conn: conn} do count_before = count(NewsItemComment) conn = post(conn, Routes.news_item_comment_path(conn, :create), news_item_comment: %{content: "yickie"} ) assert redirected_to(conn) == Routes.root_path(conn, :index) assert count(NewsItemComment) == count_before end @tag :as_inserted_user test "creates comment and notifies", %{conn: conn} do item = insert(:published_news_item) with_mock(Notifier, notify: fn _ -> true end) do conn = post(conn, Routes.news_item_comment_path(conn, :create), news_item_comment: %{content: "how dare thee!", item_id: item.id} ) assert redirected_to(conn) == Routes.root_path(conn, :index) assert count(NewsItemComment) == 1 assert called(Notifier.notify(:_)) end end @tag :as_inserted_user test "does not allow setting of author_id", %{conn: conn} do item = insert(:published_news_item) other = insert(:person) with_mock(Notifier, notify: fn _ -> true end) do conn = post(conn, Routes.news_item_comment_path(conn, :create), news_item_comment: %{content: "how dare thee!", item_id: item.id, author_id: other.id} ) assert redirected_to(conn) == Routes.root_path(conn, :index) comment = Repo.one(NewsItemComment) assert comment.author_id != other.id assert called(Notifier.notify(:_)) end end end
30.662162
96
0.672984
73f072ceec333510395cb5a8ab0003ce92c81537
1,137
exs
Elixir
dev/hello_world/config/config.exs
toff63/aws_setup_template
4b9e4780cd6fd5810c9d31376ff8febd35ea84e1
[ "MIT" ]
3
2019-08-10T11:25:40.000Z
2019-08-11T12:15:27.000Z
dev/hello_world/config/config.exs
toff63/aws_setup_template
4b9e4780cd6fd5810c9d31376ff8febd35ea84e1
[ "MIT" ]
null
null
null
dev/hello_world/config/config.exs
toff63/aws_setup_template
4b9e4780cd6fd5810c9d31376ff8febd35ea84e1
[ "MIT" ]
1
2019-08-09T21:03:02.000Z
2019-08-09T21:03:02.000Z
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # third-party users, it should be done in your "mix.exs" file. # You can configure your application as: # # config :hello_world, key: :value # # and access this configuration in your application as: # # Application.get_env(:hello_world, :key) # # You can also configure a third-party app: # # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env()}.exs"
36.677419
73
0.752858
73f089302bd69a73fc48d141e5f7bf1d66e023b4
121
ex
Elixir
lib/bgsite_official/repo.ex
N-Patarov/bgsite_official
9ed082dd8c6c5dbc83e0bc50ec63095a72ee2854
[ "Apache-2.0" ]
1
2021-08-05T12:44:37.000Z
2021-08-05T12:44:37.000Z
lib/bgsite_official/repo.ex
N-Patarov/bgsite_official
9ed082dd8c6c5dbc83e0bc50ec63095a72ee2854
[ "Apache-2.0" ]
16
2021-02-20T19:22:45.000Z
2021-06-14T13:59:01.000Z
lib/bgsite_official/repo.ex
N-Patarov/bgsite_official
9ed082dd8c6c5dbc83e0bc50ec63095a72ee2854
[ "Apache-2.0" ]
3
2021-05-17T17:54:43.000Z
2021-11-03T15:30:30.000Z
defmodule BgsiteOfficial.Repo do use Ecto.Repo, otp_app: :bgsite_official, adapter: Ecto.Adapters.Postgres end
20.166667
35
0.760331
73f09b00bd1596866b8aa6bf2854c9e91bf8f288
133
exs
Elixir
test/beiin_test.exs
cgmcintyr/beiin
db447610b938e734baae50a5263a7a1828e871b7
[ "MIT" ]
null
null
null
test/beiin_test.exs
cgmcintyr/beiin
db447610b938e734baae50a5263a7a1828e871b7
[ "MIT" ]
null
null
null
test/beiin_test.exs
cgmcintyr/beiin
db447610b938e734baae50a5263a7a1828e871b7
[ "MIT" ]
null
null
null
defmodule Beiin.Test do use ExUnit.Case doctest Beiin test "greets the world" do assert Beiin.hello() == :world end end
14.777778
34
0.691729
73f0b3422482dd0e5191f62a1d5e8f68b8151e83
6,678
ex
Elixir
lib/oli_web/live/users/author_detail_view.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
1
2022-03-17T20:35:47.000Z
2022-03-17T20:35:47.000Z
lib/oli_web/live/users/author_detail_view.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
9
2021-11-02T16:52:09.000Z
2022-03-25T15:14:01.000Z
lib/oli_web/live/users/author_detail_view.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
null
null
null
defmodule OliWeb.Users.AuthorsDetailView do use Surface.LiveView, layout: {OliWeb.LayoutView, "live.html"} use OliWeb.Common.Modal import OliWeb.Common.Utils alias Oli.Accounts alias Oli.Accounts.{Author, SystemRole} alias OliWeb.Accounts.Modals.{ LockAccountModal, UnlockAccountModal, DeleteAccountModal, GrantAdminModal, RevokeAdminModal, ConfirmEmailModal } alias OliWeb.Common.Breadcrumb alias OliWeb.Common.Properties.{Groups, Group, ReadOnly} alias OliWeb.Pow.AuthorContext alias OliWeb.Router.Helpers, as: Routes alias OliWeb.Users.Actions prop author, :any data breadcrumbs, :any data title, :string, default: "Author Details" data user, :struct, default: nil data modal, :any, default: nil data csrf_token, :any defp set_breadcrumbs(author) do OliWeb.Admin.AdminView.breadcrumb() |> OliWeb.Users.AuthorsView.breadcrumb() |> breadcrumb(author) end def breadcrumb(previous, %Author{id: id} = author) do name = name(author.name, author.given_name, author.family_name) previous ++ [ Breadcrumb.new(%{ full_title: name, link: Routes.live_path(OliWeb.Endpoint, __MODULE__, id) }) ] end def mount( %{"user_id" => user_id}, %{"csrf_token" => csrf_token, "current_author_id" => author_id}, socket ) do author = Accounts.get_author(author_id) case Accounts.get_author(user_id) do nil -> {:ok, redirect(socket, to: Routes.static_page_path(OliWeb.Endpoint, :not_found))} user -> {:ok, assign(socket, breadcrumbs: set_breadcrumbs(user), author: author, user: user, csrf_token: csrf_token )} end end def render(assigns) do ~F""" <div> {render_modal(assigns)} <Groups> <Group label="Details" description="User details"> <ReadOnly label="Name" value={@user.name}/> <ReadOnly label="First Name" value={@user.given_name}/> <ReadOnly label="Last Name" value={@user.family_name}/> <ReadOnly label="Email" value={@user.email}/> <ReadOnly label="Role" value={role(@user.system_role_id)}/> </Group> <Group label="Actions" description="Actions that can be taken for this user"> {#if @user.id != @author.id and @user.email != System.get_env("ADMIN_EMAIL", "[email protected]")} <Actions user={@user} csrf_token={@csrf_token} for_author={true}/> {/if} </Group> </Groups> </div> """ end def handle_event("show_confirm_email_modal", _, socket) do modal = %{ component: ConfirmEmailModal, assigns: %{ id: "confirm_email", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event( "confirm_email", _, socket ) do email_confirmed_at = DateTime.truncate(DateTime.utc_now(), :second) case Accounts.update_author(socket.assigns.user, %{email_confirmed_at: email_confirmed_at}) do {:ok, user} -> {:noreply, socket |> assign(user: user) |> hide_modal()} {:error, _error} -> {:noreply, put_flash(socket, :error, "Error confirming author's email")} end end def handle_event("show_unlock_account_modal", _, socket) do modal = %{ component: UnlockAccountModal, assigns: %{ id: "unlock_account", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event( "unlock_account", %{"id" => id}, socket ) do author = Accounts.get_author!(id) AuthorContext.unlock(author) {:noreply, socket |> assign(user: Accounts.get_author!(id)) |> hide_modal()} end def handle_event("show_delete_account_modal", _, socket) do modal = %{ component: DeleteAccountModal, assigns: %{ id: "delete_account", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event( "delete_account", %{"id" => id}, socket ) do author = Accounts.get_author!(id) case Accounts.delete_author(author) do {:ok, _} -> {:noreply, socket |> put_flash(:info, "Author successfully deleted.") |> push_redirect(to: Routes.live_path(OliWeb.Endpoint, OliWeb.Users.AuthorsView))} {:error, _error} -> {:noreply, put_flash(socket, :error, "Author couldn't be deleted.")} end end def handle_event("show_lock_account_modal", _, socket) do modal = %{ component: LockAccountModal, assigns: %{ id: "lock_account", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event( "lock_account", %{"id" => id}, socket ) do author = Accounts.get_author!(id) AuthorContext.lock(author) {:noreply, socket |> assign(user: Accounts.get_author!(id)) |> hide_modal()} end def handle_event("show_grant_admin_modal", _, socket) do modal = %{ component: GrantAdminModal, assigns: %{ id: "grant_admin", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event("grant_admin", %{"id" => id}, socket) do admin_role_id = SystemRole.role_id().admin author = Accounts.get_author!(id) {:noreply, socket |> change_system_role(author, admin_role_id) |> hide_modal()} end def handle_event("show_revoke_admin_modal", _, socket) do modal = %{ component: RevokeAdminModal, assigns: %{ id: "revoke_admin", user: socket.assigns.user } } {:noreply, assign(socket, modal: modal)} end def handle_event("revoke_admin", %{"id" => id}, socket) do author_role_id = SystemRole.role_id().author author = Accounts.get_author!(id) {:noreply, socket |> change_system_role(author, author_role_id) |> hide_modal()} end defp change_system_role(socket, author, role_id) do case Accounts.update_author(author, %{system_role_id: role_id}) do {:ok, author} -> assign(socket, user: author) {:error, _} -> put_flash(socket, :error, "Could not edit author") end end defp role(system_role_id) do admin_role_id = SystemRole.role_id().admin case system_role_id do ^admin_role_id -> "Administrator" _ -> "Author" end end end
24.372263
108
0.606469
73f0c7c53846bf1c224f8ddc4847586a33c2c3d4
1,608
exs
Elixir
mix.exs
discordapp/sorted_set_nif
f2212fb7f9c7407ecb174aab0c0cc4f6b96616ed
[ "MIT" ]
901
2019-05-17T16:15:52.000Z
2020-03-23T03:25:32.000Z
mix.exs
sthagen/sorted_set_nif
f2212fb7f9c7407ecb174aab0c0cc4f6b96616ed
[ "MIT" ]
10
2019-05-18T05:02:31.000Z
2020-01-30T01:44:03.000Z
mix.exs
sthagen/sorted_set_nif
f2212fb7f9c7407ecb174aab0c0cc4f6b96616ed
[ "MIT" ]
38
2019-05-17T17:59:59.000Z
2020-03-08T09:32:32.000Z
defmodule SortedSet.MixProject do use Mix.Project def project do [ app: :sorted_set_nif, name: "SortedSet", version: "1.2.0", elixir: "~> 1.5", start_permanent: Mix.env() == :prod, compilers: Mix.compilers(), deps: deps(), docs: docs(), elixirc_paths: elixirc_paths(Mix.env()), package: package() ] end def application do [ extra_applications: [:logger] ] end defp deps do [ {:rustler, "~> 0.22.0"}, {:jemalloc_info, "~> 0.3", app: false}, {:ex_doc, "~> 0.19", only: [:dev], runtime: false}, {:benchee, "~> 1.0", only: [:dev]}, {:benchee_html, "~> 1.0", only: [:dev]}, {:stream_data, "~> 0.4", only: [:test]}, {:dialyxir, "~> 1.0.0", only: [:dev], runtime: false} ] end defp docs do [ name: "SortedSet", extras: ["README.md"], main: "readme", source_url: "https://github.com/discord/sorted_set" ] end defp elixirc_paths(:test) do elixirc_paths(:default) ++ ["test/support"] end defp elixirc_paths(_) do ["lib"] end defp package do [ name: :sorted_set_nif, description: "SortedSet is a fast and efficient Rust backed sorted set.", files: ["lib", "native/sorted_set_nif/Cargo.toml", "native/sorted_set_nif/README.md", "native/sorted_set_nif/src", ".formatter.exs", "README*", "LICENSE*", "mix.exs"], maintainers: ["Discord Core Infrastructure"], licenses: ["MIT"], links: %{ "GitHub" => "https://github.com/discord/sorted_set_nif" } ] end end
24
173
0.560323
73f0cbc2601487a45f2b2d6ad681013aae2a70bd
474
exs
Elixir
config/test.exs
kmikko/phoenix-starter
679af9ddea22e207c037c7de94a5e7fc775389d3
[ "MIT" ]
null
null
null
config/test.exs
kmikko/phoenix-starter
679af9ddea22e207c037c7de94a5e7fc775389d3
[ "MIT" ]
null
null
null
config/test.exs
kmikko/phoenix-starter
679af9ddea22e207c037c7de94a5e7fc775389d3
[ "MIT" ]
null
null
null
use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :app, AppWeb.Endpoint, http: [port: 4001], server: false # Print only warnings and errors during test config :logger, level: :warn # Configure your database config :app, App.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "app_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox
23.7
56
0.723629
73f0e3dc7210837678af0cb0e021b9bf3f97b9f9
7,423
ex
Elixir
deps/plug/lib/plug/test.ex
rpillar/Top5_Elixir
9c450d2e9b291108ff1465dc066dfe442dbca822
[ "MIT" ]
null
null
null
deps/plug/lib/plug/test.ex
rpillar/Top5_Elixir
9c450d2e9b291108ff1465dc066dfe442dbca822
[ "MIT" ]
null
null
null
deps/plug/lib/plug/test.ex
rpillar/Top5_Elixir
9c450d2e9b291108ff1465dc066dfe442dbca822
[ "MIT" ]
null
null
null
defmodule Plug.Test do @moduledoc """ Conveniences for testing plugs. This module can be used in your test cases, like this: use ExUnit.Case, async: true use Plug.Test Using this module will: * import all the functions from this module * import all the functions from the `Plug.Conn` module By default, Plug tests checks for invalid header keys, e.g. header keys which include uppercase letters, and raises a `Plug.Conn.InvalidHeaderError` when it finds one. To disable it, set :validate_header_keys_during_test to false on the app config. config :plug, :validate_header_keys_during_test, true """ @doc false defmacro __using__(_) do quote do import Plug.Test import Plug.Conn end end alias Plug.Conn @typep params :: binary | list | map | nil @doc """ Creates a test connection. The request `method` and `path` are required arguments. `method` may be any value that implements `to_string/1` and it will properly converted and normalized (e.g., `:get` or `"post"`). The `params_or_body` field must be one of: * `nil` - meaning there is no body; * a binary - containing a request body. For such cases, `:headers` must be given as option with a content-type; * a map or list - containing the parameters which will automatically set the content-type to multipart. The map or list may contain other lists or maps and all entries will be normalized to string keys; ## Examples conn(:get, "/foo?bar=10") conn(:get, "/foo", %{bar: 10}) conn(:post, "/") conn("patch", "/", "") |> put_req_header("content-type", "application/json") """ @spec conn(String.Chars.t(), binary, params) :: Conn.t() def conn(method, path, params_or_body \\ nil) do Plug.Adapters.Test.Conn.conn(%Plug.Conn{}, method, path, params_or_body) end @doc """ Returns the sent response. This function is useful when the code being invoked crashes and there is a need to verify a particular response was sent even with the crash. It returns a tuple with `{status, headers, body}`. """ def sent_resp(%Conn{adapter: {Plug.Adapters.Test.Conn, %{ref: ref}}}) do case receive_resp(ref) do :no_resp -> raise "no sent response available for the given connection. " <> "Maybe the application did not send anything?" response -> case receive_resp(ref) do :no_resp -> send(self(), {ref, response}) response _otherwise -> raise "a response for the given connection has been sent more than once" end end end defp receive_resp(ref) do receive do {^ref, response} -> response after 0 -> :no_resp end end @doc """ Return the informational requests that have been sent. This function depends on gathering the messages sent by the test adapter when informational messages, such as an early hint, are sent. Calling this function will clear the informational request messages from the inbox for the process. To assert on multiple informs, the result of the function should be stored in a variable. ## Examples conn = conn(:get, "/foo", "bar=10") informs = Plug.Test.sent_informs(conn) assert {"/static/application.css", [{"accept", "text/css"}]} in informs assert {"/static/application.js", [{"accept", "application/javascript"}]} in informs """ def sent_informs(%Conn{adapter: {Plug.Adapters.Test.Conn, %{ref: ref}}}) do Enum.reverse(receive_informs(ref, [])) end defp receive_informs(ref, informs) do receive do {^ref, :inform, response} -> receive_informs(ref, [response | informs]) after 0 -> informs end end @doc """ Return the assets that have been pushed. This function depends on gathering the messages sent by the test adapter when assets are pushed. Calling this function will clear the pushed message from the inbox for the process. To assert on multiple pushes, the result of the function should be stored in a variable. ## Examples conn = conn(:get, "/foo?bar=10") pushes = Plug.Test.sent_pushes(conn) assert {"/static/application.css", [{"accept", "text/css"}]} in pushes assert {"/static/application.js", [{"accept", "application/javascript"}]} in pushes """ def sent_pushes(%Conn{adapter: {Plug.Adapters.Test.Conn, %{ref: ref}}}) do Enum.reverse(receive_pushes(ref, [])) end defp receive_pushes(ref, pushes) do receive do {^ref, :push, response} -> receive_pushes(ref, [response | pushes]) after 0 -> pushes end end @doc """ Puts the http protocol. """ def put_http_protocol(conn, http_protocol) do update_in(conn.adapter, fn {adapter, payload} -> {adapter, Map.put(payload, :http_protocol, http_protocol)} end) end @doc """ Puts the peer data. """ def put_peer_data(conn, peer_data) do update_in(conn.adapter, fn {adapter, payload} -> {adapter, Map.put(payload, :peer_data, peer_data)} end) end @doc """ Puts a request cookie. """ @spec put_req_cookie(Conn.t(), binary, binary) :: Conn.t() def put_req_cookie(conn, key, value) when is_binary(key) and is_binary(value) do conn = delete_req_cookie(conn, key) %{conn | req_headers: [{"cookie", "#{key}=#{value}"} | conn.req_headers]} end @doc """ Deletes a request cookie. """ @spec delete_req_cookie(Conn.t(), binary) :: Conn.t() def delete_req_cookie(%Conn{req_cookies: %Plug.Conn.Unfetched{}} = conn, key) when is_binary(key) do key = "#{key}=" size = byte_size(key) fun = &match?({"cookie", value} when binary_part(value, 0, size) == key, &1) %{conn | req_headers: Enum.reject(conn.req_headers, fun)} end def delete_req_cookie(_conn, key) when is_binary(key) do raise ArgumentError, message: "cannot put/delete request cookies after cookies were fetched" end @doc """ Moves cookies from a connection into a new connection for subsequent requests. This function copies the cookie information in `old_conn` into `new_conn`, emulating multiple requests done by clients where cookies are always passed forward, and returns the new version of `new_conn`. """ @spec recycle_cookies(Conn.t(), Conn.t()) :: Conn.t() def recycle_cookies(new_conn, old_conn) do Enum.reduce(Plug.Conn.fetch_cookies(old_conn).cookies, new_conn, fn {key, value}, acc -> put_req_cookie(acc, to_string(key), value) end) end @doc """ Initializes the session with the given contents. If the session has already been initialized, the new contents will be merged with the previous ones. """ @spec init_test_session(Conn.t(), %{(String.t() | atom) => any}) :: Conn.t() def init_test_session(conn, session) do conn = if conn.private[:plug_session_fetch] do Conn.fetch_session(conn) else conn |> Conn.put_private(:plug_session, %{}) |> Conn.put_private(:plug_session_fetch, :done) end Enum.reduce(session, conn, fn {key, value}, conn -> Conn.put_session(conn, key, value) end) end end
31.99569
97
0.64381
73f12124c59e165d37f39378a45e4e69bc54d2f5
3,813
ex
Elixir
lib/koans/12_pattern_matching.ex
loicginoux/elixir-koans
11a15fd55771fed43823db9429d6fa8ba60fa73f
[ "MIT" ]
null
null
null
lib/koans/12_pattern_matching.ex
loicginoux/elixir-koans
11a15fd55771fed43823db9429d6fa8ba60fa73f
[ "MIT" ]
null
null
null
lib/koans/12_pattern_matching.ex
loicginoux/elixir-koans
11a15fd55771fed43823db9429d6fa8ba60fa73f
[ "MIT" ]
null
null
null
defmodule PatternMatching do use Koans @intro "PatternMatching" koan "One matches one" do assert match?(1, 1) end koan "Patterns can be used to pull things apart" do [head | tail] = [1, 2, 3, 4] assert head == 1 assert tail == [2, 3, 4] end koan "And then put them back together" do head = 1 tail = [2, 3, 4] assert [1, 2, 3, 4] == [head | tail] end koan "Some values can be ignored" do [_first, _second, third, _fourth] = [1, 2, 3, 4] assert third == 3 end koan "Strings come apart just as easily" do "Shopping list: " <> items = "Shopping list: eggs, milk" assert items == "eggs, milk" end koan "Maps support partial pattern matching" do %{make: make} = %{type: "car", year: 2016, make: "Honda", color: "black"} assert make == "Honda" end koan "Lists must match exactly" do assert_raise MatchError, fn -> [a, b] = [1,2,3] end end koan "So does the keyword lists" do kw_list = [type: "car", year: 2016, make: "Honda"] [_type | [_year | [tuple]]] = kw_list assert tuple == {:make, "Honda"} end koan "The pattern can make assertions about what it expects" do assert match?([1, _second, _third], [1,2,3]) end def make_noise(%{type: "cat"}), do: "Meow" def make_noise(%{type: "dog"}), do: "Woof" def make_noise(_anything), do: "Eh?" koan "Functions perform pattern matching on their arguments" do cat = %{type: "cat"} dog = %{type: "dog"} snake = %{type: "snake"} assert make_noise(cat) == "Meow" assert make_noise(dog) == "Woof" assert make_noise(snake) == "Eh?" end koan "And they will only run the code that matches the argument" do name = fn ("duck") -> "Donald" ("mouse") -> "Mickey" (_other) -> "I need a name!" end assert name.("mouse") == "Mickey" assert name.("duck") == "Donald" assert name.("donkey") == "I need a name!" end koan "Errors are shaped differently than successful results" do dog = %{type: "dog"} result = case Map.fetch(dog, :type) do {:ok, value} -> value :error -> "not present" end assert result == "dog" end defmodule Animal do defstruct [:kind, :name] end koan "You can pattern match into the fields of a struct" do %Animal{name: name} = %Animal{kind: "dog", name: "Max"} assert name == "Max" end defmodule Plane do defstruct passengers: 0, maker: :boeing end def plane?(%Plane{}), do: true def plane?(_), do: false koan "...or onto the type of the struct itself" do assert plane?(%Plane{passengers: 417, maker: :boeing}) == true assert plane?(%Animal{}) == false end koan "Structs will even match with a regular map" do %{name: name} = %Animal{kind: "dog", name: "Max"} assert name == "Max" end koan "A value can be bound to a variable" do a = 1 assert a == 1 end koan "A variable can be rebound" do a = 1 a = 2 assert a == 2 end koan "A variable can be pinned to use its value when matching instead of binding to a new value" do pinned_variable = 1 example = fn (^pinned_variable) -> "The number One" (2) -> "The number Two" (number) -> "The number #{number}" end assert example.(1) == "The number One" assert example.(2) == "The number Two" assert example.(3) == "The number 3" end koan "Pinning works anywhere one would match, including 'case'" do pinned_variable = 1 result = case 1 do ^pinned_variable -> "same" other -> "different #{other}" end assert result == "same" end koan "Trying to rebind a pinned variable will result in an error" do a = 1 assert_raise MatchError, fn() -> ^a = 2 end end end
23.537037
101
0.593234
73f1387fdc039c08042ccc80fb33fe4ba6c828ee
336
exs
Elixir
app/priv/repo/migrations/20200328114129_create_sponsors.exs
nathanjohnson320/noodl
2e449aab15b54fc5a1dc45ebf4b79e7b64b7c967
[ "MIT" ]
1
2021-01-20T20:00:50.000Z
2021-01-20T20:00:50.000Z
app/priv/repo/migrations/20200328114129_create_sponsors.exs
nathanjohnson320/noodl
2e449aab15b54fc5a1dc45ebf4b79e7b64b7c967
[ "MIT" ]
null
null
null
app/priv/repo/migrations/20200328114129_create_sponsors.exs
nathanjohnson320/noodl
2e449aab15b54fc5a1dc45ebf4b79e7b64b7c967
[ "MIT" ]
null
null
null
defmodule Noodl.Repo.Migrations.CreateSponsors do use Ecto.Migration def change do create table(:sponsors, primary_key: false) do add :id, :binary_id, primary_key: true add :name, :string add :description, :string add :image, :string add :company_info, :text timestamps() end end end
21
50
0.660714
73f14dac344a964e4ac226e63088bd735aa6f3e4
1,117
exs
Elixir
config/config.exs
CodeSteak/Bf2nasm
f3b9090133b66c4902a2f6dcee048d911e4a872b
[ "MIT" ]
8
2017-05-26T15:47:52.000Z
2022-01-04T23:13:57.000Z
config/config.exs
CodeSteak/Bf2nasm
f3b9090133b66c4902a2f6dcee048d911e4a872b
[ "MIT" ]
null
null
null
config/config.exs
CodeSteak/Bf2nasm
f3b9090133b66c4902a2f6dcee048d911e4a872b
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # 3rd-party users, it should be done in your "mix.exs" file. # You can configure for your application as: # # config :bf2nasm, key: :value # # And access this configuration in your application as: # # Application.get_env(:bf2nasm, :key) # # Or configure a 3rd-party app: # # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs"
36.032258
73
0.751119
73f15b76249fb8a4504b74ff5ae26b67855420c7
1,328
ex
Elixir
farmbot_ext/lib/farmbot_ext/api/sync_group.ex
Arti4ever/farmbot_os
a238c1d5ae78c08d1f5894cac41ed61035fb3266
[ "MIT" ]
1
2021-04-22T10:18:50.000Z
2021-04-22T10:18:50.000Z
farmbot_ext/lib/farmbot_ext/api/sync_group.ex
Arti4ever/farmbot_os
a238c1d5ae78c08d1f5894cac41ed61035fb3266
[ "MIT" ]
null
null
null
farmbot_ext/lib/farmbot_ext/api/sync_group.ex
Arti4ever/farmbot_os
a238c1d5ae78c08d1f5894cac41ed61035fb3266
[ "MIT" ]
null
null
null
defmodule FarmbotExt.API.SyncGroup do @moduledoc "Handles dependency ordering." alias FarmbotCore.Asset.{ Device, FarmEvent, FarmwareEnv, FirstPartyFarmware, FarmwareInstallation, FbosConfig, FirmwareConfig, Peripheral, PinBinding, Point, PointGroup, # PublicKey, Regimen, SensorReading, Sensor, Sequence, Tool } def all_groups, do: group_0() ++ group_1() ++ group_2() ++ group_3() ++ group_4() @doc "Assets in Group 0 are required for FarmBot to operate." def group_0, do: [ Device, FbosConfig, FirmwareConfig, FarmwareEnv, FirstPartyFarmware, FarmwareInstallation ] @doc "Group 1 should have no external requirements" def group_1, do: [ Peripheral, Point, SensorReading, Sensor, Tool ] @doc "Group 2 relies on assets in Group 1" def group_2, do: [ # Requires Peripheral, Point, Sensor, SensorReading, Tool Sequence, PointGroup ] @doc "Group 3 relies on assets in Group 2" def group_3, do: [ # Requires Sequence Regimen, # Requires Sequence PinBinding ] @doc "Group 4 relies on assets in Group 3" def group_4, do: [ # Requires Regimen and Sequence FarmEvent ] end
18.704225
83
0.615211
73f1678bb5b60582524a774d01336826fa404498
290
ex
Elixir
test/support/name_struct.ex
GregMefford/logger_json
3332c7cdd7a5dc57f85771809c03ff1469a2901a
[ "MIT" ]
148
2017-04-10T06:22:02.000Z
2022-03-31T11:19:14.000Z
test/support/name_struct.ex
GregMefford/logger_json
3332c7cdd7a5dc57f85771809c03ff1469a2901a
[ "MIT" ]
81
2017-04-09T15:17:03.000Z
2022-03-01T16:25:32.000Z
test/support/name_struct.ex
GregMefford/logger_json
3332c7cdd7a5dc57f85771809c03ff1469a2901a
[ "MIT" ]
62
2018-05-31T06:49:55.000Z
2022-01-24T09:15:04.000Z
defmodule NameStruct do @moduledoc """ Needed for tests on structs that implement the Jason.Encoder protocol. Defining this struct in the test module wouldn't work, since the .exs files are not within the compilation folders. """ @derive Jason.Encoder defstruct [:name] end
24.166667
77
0.744828
73f185cbca6e9eae272c9e2449bd780663aa08ff
2,832
exs
Elixir
test/acceptance/ast/links_images/simple_pure_links_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
null
null
null
test/acceptance/ast/links_images/simple_pure_links_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
null
null
null
test/acceptance/ast/links_images/simple_pure_links_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
1
2020-03-31T19:53:15.000Z
2020-03-31T19:53:15.000Z
defmodule Acceptance.Ast.LinksImages.SimplePureLinksTest do use Support.AcceptanceTestCase import Support.Helpers, only: [as_ast: 1, as_ast: 2, parse_html: 1] @moduletag :ast describe "simple pure links not yet enabled" do test "issue deprecation warning surpressed" do markdown = "https://github.com/pragdave/earmark" html = "<p>https://github.com/pragdave/earmark</p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown, pure_links: false) == {:ok, [ast], messages} end test "explicitly enabled" do markdown = "https://github.com/pragdave/earmark" html = "<p><a href=\"https://github.com/pragdave/earmark\">https://github.com/pragdave/earmark</a></p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end end describe "enabled pure links" do test "two in a row" do markdown = "https://github.com/pragdave/earmark https://github.com/RobertDober/extractly" html = "<p><a href=\"https://github.com/pragdave/earmark\">https://github.com/pragdave/earmark</a> <a href=\"https://github.com/RobertDober/extractly\">https://github.com/RobertDober/extractly</a></p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end test "more text" do markdown = "Header http://wikipedia.org in between <http://hex.pm> Trailer" html = "<p>Header <a href=\"http://wikipedia.org\">http://wikipedia.org</a> in between <a href=\"http://hex.pm\">http://hex.pm</a> Trailer</p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end test "more links" do markdown = "[Erlang](https://erlang.org) & https://elixirforum.com" html = "<p><a href=\"https://erlang.org\">Erlang</a> &amp; <a href=\"https://elixirforum.com\">https://elixirforum.com</a></p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end test "be aware of the double up" do markdown = "[https://erlang.org](https://erlang.org)" html = "<p><a href=\"https://erlang.org\">https://erlang.org</a></p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end test "inner pure_links disabling does not leak out" do markdown = "[https://erlang.org](https://erlang.org) https://elixir.lang" html = "<p><a href=\"https://erlang.org\">https://erlang.org</a> <a href=\"https://elixir.lang\">https://elixir.lang</a></p>\n" ast = parse_html(html) messages = [] assert as_ast(markdown) == {:ok, [ast], messages} end end end # SPDX-License-Identifier: Apache-2.0
36.307692
209
0.613701
73f1aa47612ce772f54514e55e88f0c98d6b290a
89
exs
Elixir
test/tempo_test.exs
LostKobrakai/tempo
09882266b3ed319daad715c8d3e475a28c475e60
[ "Apache-2.0" ]
null
null
null
test/tempo_test.exs
LostKobrakai/tempo
09882266b3ed319daad715c8d3e475a28c475e60
[ "Apache-2.0" ]
null
null
null
test/tempo_test.exs
LostKobrakai/tempo
09882266b3ed319daad715c8d3e475a28c475e60
[ "Apache-2.0" ]
null
null
null
defmodule TempoTest do use ExUnit.Case doctest Tempo test "Parsing" do end end
9.888889
22
0.719101
73f1fd1e51f0f0d7e8530e7f78aa564abec6d159
2,675
ex
Elixir
lib/ratatouille/renderer/element/panel.ex
CyberFlameGO/ratatouille
cc7b6a37e0b1757cd89cc5084343814a79dd86dc
[ "MIT" ]
504
2019-01-13T21:53:21.000Z
2022-03-31T20:58:21.000Z
lib/ratatouille/renderer/element/panel.ex
iboard/ratatouille
cc7b6a37e0b1757cd89cc5084343814a79dd86dc
[ "MIT" ]
28
2019-01-26T21:00:23.000Z
2021-12-28T19:06:15.000Z
lib/ratatouille/renderer/element/panel.ex
iboard/ratatouille
cc7b6a37e0b1757cd89cc5084343814a79dd86dc
[ "MIT" ]
21
2019-02-21T09:08:27.000Z
2021-12-20T15:51:10.000Z
defmodule Ratatouille.Renderer.Element.Panel do @moduledoc false @behaviour Ratatouille.Renderer alias ExTermbox.Position alias Ratatouille.Renderer.{Border, Box, Canvas, Element, Text} @default_padding 1 @border_width 1 @margin_y 1 @title_offset_x 2 @impl true def render( %Canvas{render_box: box} = canvas, %Element{attributes: %{height: :fill} = attrs} = element, render_fn ) do new_attrs = %{attrs | height: Box.height(box)} render(canvas, %Element{element | attributes: new_attrs}, render_fn) end def render( %Canvas{render_box: box} = canvas, %Element{attributes: attrs, children: children}, render_fn ) do fill_empty? = !is_nil(attrs[:height]) constrained_canvas = constrain_canvas(canvas, attrs[:height]) padding = attrs[:padding] || @default_padding rendered_canvas = constrained_canvas |> Canvas.padded(padding + @border_width) |> render_fn.(children) |> wrapper_canvas(constrained_canvas, fill_empty?) |> render_features(attrs) %Canvas{ rendered_canvas | render_box: %Box{ box | top_left: %Position{ x: box.top_left.x, y: rendered_canvas.render_box.bottom_right.y + @margin_y } } } end defp render_features(canvas, attrs) do canvas |> Border.render(attrs[:border]) |> render_title(attrs) end defp render_title(canvas, nil), do: canvas defp render_title(%Canvas{render_box: box} = canvas, %{title: title} = attr) when is_binary(title) do Text.render(canvas, title_position(box), title, attr) end defp render_title(canvas, _), do: canvas defp title_position(box), do: Position.translate_x(box.top_left, @title_offset_x) defp wrapper_canvas(rendered_canvas, original_canvas, fill?) do %Canvas{ rendered_canvas | render_box: wrapper_box( rendered_canvas.render_box, original_canvas.render_box, fill? ) } end defp wrapper_box(_rendered_box, original_box, true), do: original_box defp wrapper_box(rendered_box, original_box, false), do: %Box{ original_box | bottom_right: %Position{ x: original_box.bottom_right.x, y: rendered_box.top_left.y } } defp constrain_canvas(%Canvas{render_box: box} = canvas, height), do: %Canvas{canvas | render_box: constrain_box(box, height)} defp constrain_box(box, nil), do: box defp constrain_box(%Box{top_left: top_left} = box, height) do Box.from_dimensions(Box.width(box), height, top_left) end end
26.22549
78
0.649346
73f20b9f2518510a4ee5cfb61b034fe41330034c
1,435
ex
Elixir
apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_pipeline_supervisor.ex
Annopaolo/astarte
f8190e8bf044759a9b84bdeb5786a55b6f793a4f
[ "Apache-2.0" ]
191
2018-03-30T13:23:08.000Z
2022-03-02T12:05:32.000Z
apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_pipeline_supervisor.ex
Annopaolo/astarte
f8190e8bf044759a9b84bdeb5786a55b6f793a4f
[ "Apache-2.0" ]
402
2018-03-30T13:37:00.000Z
2022-03-31T16:47:10.000Z
apps/astarte_data_updater_plant/lib/astarte_data_updater_plant/data_pipeline_supervisor.ex
Annopaolo/astarte
f8190e8bf044759a9b84bdeb5786a55b6f793a4f
[ "Apache-2.0" ]
24
2018-03-30T13:29:48.000Z
2022-02-28T11:10:26.000Z
# # This file is part of Astarte. # # Copyright 2020 Ispirata Srl # # 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. # defmodule Astarte.DataUpdaterPlant.DataPipelineSupervisor do use Supervisor alias Astarte.DataUpdaterPlant.ConsumersSupervisor alias Astarte.DataUpdaterPlant.AMQPEventsProducer alias Astarte.DataUpdaterPlant.RPC.Handler alias Astarte.RPC.Protocol.DataUpdaterPlant, as: Protocol def start_link(init_arg) do Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__) end @impl true def init(_init_arg) do children = [ {Registry, [keys: :unique, name: Registry.MessageTracker]}, {Registry, [keys: :unique, name: Registry.DataUpdater]}, AMQPEventsProducer, ConsumersSupervisor, {Astarte.RPC.AMQP.Server, [amqp_queue: Protocol.amqp_queue(), handler: Handler]}, Astarte.RPC.AMQP.Client ] Supervisor.init(children, strategy: :rest_for_one) end end
31.195652
87
0.749826
73f23a790b9efcbcbeb6962393ae5c7170a031f1
2,291
ex
Elixir
lib/boss.ex
inaka/beam_olympics-solver
a32fa18a4a7e03900b7274c4a0c4e8b82f1a9768
[ "Apache-2.0" ]
1
2018-10-11T06:58:02.000Z
2018-10-11T06:58:02.000Z
lib/boss.ex
inaka/beam_olympics-solver
a32fa18a4a7e03900b7274c4a0c4e8b82f1a9768
[ "Apache-2.0" ]
null
null
null
lib/boss.ex
inaka/beam_olympics-solver
a32fa18a4a7e03900b7274c4a0c4e8b82f1a9768
[ "Apache-2.0" ]
null
null
null
defmodule Boss do @moduledoc """ Main interface against beam_olympics server """ @typedoc """ A function spec """ @type spec :: %{ input: [String.t], output: String.t } @typedoc """ A Task, as defined by beam_olympics """ @type task :: %{ name: module, desc: String.t, spec: spec, score: pos_integer } @typedoc """ Individual player statistics """ @type player_stats :: %{ name: String.t, done: non_neg_integer, score: integer } @typedoc """ Game statistics """ @type stats :: %{ tasks: pos_integer, players: [player_stats] } @doc """ Signs up to the game. It uses node name as player name. """ @spec signup() :: {:ok, task} | {:error, :conflict} def signup do call {:signup, player} end @doc """ Returns the current task """ @spec task() :: {:ok, task} | {:error, :ended | :forbidden | :notfound} def task do call {:task, player} end @doc """ Submits a solution """ @spec submit(term) :: {:ok, task} | :the_end | {:error, :invalid | :timeout | :ended | :forbidden | :notfound} | {:failures, [term,...]} def submit(solution) do call {:submit, player, solution} end @doc """ Skips a task """ @spec skip() :: {:ok, task} | :the_end | {:error, :ended | :forbidden | :notfound} def skip do call {:skip, player} end @doc """ Returns the player score """ @spec score() :: {:ok, integer} | {:error, :forbidden | :notfound} def score do call {:score, player} end @doc """ Returns the game stats """ @spec stats() :: stats def stats do call :stats end @doc """ Renders the leaderboard and refreshes it periodically """ def leaderboard do BossLeaderBoard.start end defp call(msg) do server_node = Application.get_env(:boss, :server, '[email protected]') GenServer.call({:bo_server, server_node}, msg, 60_000) end defp player do [name|_] = String.split(Atom.to_string(node), "@") name end end
20.63964
75
0.520733
73f2480d586abb4c40bf46a4d76c4ed5a377626a
2,272
exs
Elixir
test/features/visitor_searches_posts_test.exs
RyanWillDev/tilex
1fef06ca37434c9448c97e5a7387af2e7039b46c
[ "MIT" ]
null
null
null
test/features/visitor_searches_posts_test.exs
RyanWillDev/tilex
1fef06ca37434c9448c97e5a7387af2e7039b46c
[ "MIT" ]
null
null
null
test/features/visitor_searches_posts_test.exs
RyanWillDev/tilex
1fef06ca37434c9448c97e5a7387af2e7039b46c
[ "MIT" ]
null
null
null
defmodule VisiorSearchesPosts do use Tilex.IntegrationCase, async: true def fill_in_search(session, query) do session |> visit("/") |> find(Query.css(".site_nav__search .site_nav__link")) |> Element.click() session |> fill_in(Query.text_field("q"), with: query) |> click(Query.button("Search")) end test "with no found posts", %{session: session} do Factory.insert!(:post, title: "elixir is awesome") fill_in_search(session, "ruby on rails") search_result_header = get_text(session, "#search") assert search_result_header == "0 posts about ruby on rails" end test "with 2 found posts", %{session: session} do ["Elixir Rules", "Because JavaScript", "Hashrocket Rules"] |> Enum.each(&Factory.insert!(:post, title: &1)) fill_in_search(session, "rules") search_result_header = get_text(session, "#search") body = get_text(session, "body") assert search_result_header == "2 posts about rules" assert find(session, Query.css("article.post", count: 2)) assert body =~ ~r/Elixir Rules/ assert body =~ ~r/Hashrocket Rules/ refute body =~ ~r/Because JavaScript/ end test "with paginated query results", %{session: session} do max_posts_on_page = Application.get_env(:tilex, :page_size) 1..(max_posts_on_page * 2) |> Enum.map(&"Random Elixir Post #{&1}") |> Enum.each(&Factory.insert!(:post, title: &1)) Factory.insert!(:post, title: "No Match") fill_in_search(session, "Elixir") first_page_first_post = get_first_post_on_page_title(session) search_result_header = get_text(session, "#search") assert search_result_header == "10 posts about Elixir" assert find(session, Query.css("article.post", count: max_posts_on_page)) visit(session, "/?_utf8=✓&page=2&q=Elixir") second_page_first_post = get_first_post_on_page_title(session) search_result_header = get_text(session, "#search") assert search_result_header == "10 posts about Elixir" refute first_page_first_post == second_page_first_post assert find(session, Query.css("article.post", count: max_posts_on_page)) end defp get_first_post_on_page_title(session) do get_text(session, "#home > section:first-child article.post h1 a") end end
32.457143
77
0.696743
73f24d49aebb8683028e3193ffc49d4a79601e9e
1,197
ex
Elixir
lib/learnrls/endpoint.ex
mbuhot/ecto_row_level_security
41ef5a7e2aa51c51cf80f4f5f9f99a09481a60dd
[ "MIT" ]
15
2017-01-06T05:52:23.000Z
2022-02-14T10:05:42.000Z
lib/learnrls/endpoint.ex
mbuhot/ecto_row_level_security
41ef5a7e2aa51c51cf80f4f5f9f99a09481a60dd
[ "MIT" ]
1
2019-09-09T06:23:35.000Z
2020-10-25T21:36:51.000Z
lib/learnrls/endpoint.ex
mbuhot/ecto_row_level_security
41ef5a7e2aa51c51cf80f4f5f9f99a09481a60dd
[ "MIT" ]
null
null
null
defmodule Learnrls.Endpoint do use Phoenix.Endpoint, otp_app: :learnrls socket "/socket", Learnrls.UserSocket # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phoenix.digest # when deploying your static files in production. plug Plug.Static, at: "/", from: :learnrls, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. if code_reloading? do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader end plug Plug.RequestId plug Plug.Logger plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Poison plug Plug.MethodOverride plug Plug.Head # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. plug Plug.Session, store: :cookie, key: "_learnrls_key", signing_salt: "D7ctpNhX" plug Learnrls.Router end
27.837209
69
0.715957
73f24f564f0ba759981910d69ebfa2dd0dced2fc
53
ex
Elixir
web/views/layout_view.ex
joaoevangelista/iss-phoenix
ad30fa88ebe1172a1e14f22896edf73e97490ce5
[ "MIT" ]
null
null
null
web/views/layout_view.ex
joaoevangelista/iss-phoenix
ad30fa88ebe1172a1e14f22896edf73e97490ce5
[ "MIT" ]
null
null
null
web/views/layout_view.ex
joaoevangelista/iss-phoenix
ad30fa88ebe1172a1e14f22896edf73e97490ce5
[ "MIT" ]
null
null
null
defmodule ISS.LayoutView do use ISS.Web, :view end
13.25
27
0.754717
73f26944795f0071244a7781a1cb2d1e2be65734
1,214
ex
Elixir
lib/ex_micro_blog_web/live/user_live_index.ex
CassiusPacheco/ex_micro_blog
e96cb65a76bdc17313457dadb8075e3d9ac2e4f5
[ "MIT" ]
3
2020-04-21T22:48:23.000Z
2020-05-12T19:58:31.000Z
lib/ex_micro_blog_web/live/user_live_index.ex
CassiusPacheco/ex_micro_blog
e96cb65a76bdc17313457dadb8075e3d9ac2e4f5
[ "MIT" ]
1
2021-05-11T11:22:49.000Z
2021-05-11T11:22:49.000Z
lib/ex_micro_blog_web/live/user_live_index.ex
CassiusPacheco/ex_micro_blog
e96cb65a76bdc17313457dadb8075e3d9ac2e4f5
[ "MIT" ]
null
null
null
defmodule ExMicroBlogWeb.UserLive.Index do use Phoenix.LiveView alias ExMicroBlog.Accounts def render(assigns) do Phoenix.View.render(ExMicroBlogWeb.UserView, "index.html", assigns) end def mount(_, %{"current_user_id" => current_user_id}, socket) when is_nil(current_user_id) do setup(nil, socket) end def mount(_params, %{"current_user_id" => current_user_id}, socket) do current_user = Accounts.get_user!(current_user_id) setup(current_user, socket) end # Helpers defp setup(current_user, socket) do if connected?(socket) and not is_nil(current_user) do Accounts.subscribe(current_user.id) end {:ok, assign_values(socket, current_user)} end defp assign_values(socket, current_user) do case current_user do nil -> assign(socket, current_user: nil, users: Accounts.list_users(nil)) user -> assign(socket, current_user: user, users: Accounts.list_users(user.id)) end end # Handle Events def handle_info({Accounts, _event, _object}, socket) do # TODO: it's best to update it in a smarter way than re-fetching it all. {:noreply, assign_values(socket, socket.assigns.current_user)} end end
25.829787
79
0.707578
73f26b777c7fc918c2396eb24d4dcea2f035755d
458
exs
Elixir
test/mafia_interface_web/views/error_view_test.exs
menxs/mafia_interface
311f709e512dca4e26b0c0faccf5dfe07df20673
[ "MIT" ]
null
null
null
test/mafia_interface_web/views/error_view_test.exs
menxs/mafia_interface
311f709e512dca4e26b0c0faccf5dfe07df20673
[ "MIT" ]
null
null
null
test/mafia_interface_web/views/error_view_test.exs
menxs/mafia_interface
311f709e512dca4e26b0c0faccf5dfe07df20673
[ "MIT" ]
1
2022-03-28T06:09:12.000Z
2022-03-28T06:09:12.000Z
defmodule MafiaInterfaceWeb.ErrorViewTest do use MafiaInterfaceWeb.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do assert render_to_string(MafiaInterfaceWeb.ErrorView, "404.html", []) == "Not Found" end test "renders 500.html" do assert render_to_string(MafiaInterfaceWeb.ErrorView, "500.html", []) == "Internal Server Error" end end
28.625
87
0.729258
73f27cc0b420ff9ccaf3562a475f368416f6b830
991
ex
Elixir
exercism/file-sniffer/file_sniffer.ex
defndaines/elixir_bits
78a9c2dc0c9946df715a662ef62cd437fdd9e3d1
[ "Apache-2.0" ]
null
null
null
exercism/file-sniffer/file_sniffer.ex
defndaines/elixir_bits
78a9c2dc0c9946df715a662ef62cd437fdd9e3d1
[ "Apache-2.0" ]
null
null
null
exercism/file-sniffer/file_sniffer.ex
defndaines/elixir_bits
78a9c2dc0c9946df715a662ef62cd437fdd9e3d1
[ "Apache-2.0" ]
null
null
null
defmodule FileSniffer do def type_from_extension("exe"), do: "application/octet-stream" def type_from_extension("bmp"), do: "image/bmp" def type_from_extension("png"), do: "image/png" def type_from_extension("jpg"), do: "image/jpg" def type_from_extension("gif"), do: "image/gif" def type_from_binary(<<0x7F, 0x45, 0x4C, 0x46, _::binary>>) do "application/octet-stream" end def type_from_binary(<<0x42, 0x4D, _::binary>>) do "image/bmp" end def type_from_binary(<<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _::binary>>) do "image/png" end def type_from_binary(<<0xFF, 0xD8, 0xFF, _::binary>>) do "image/jpg" end def type_from_binary(<<0x47, 0x49, 0x46, _::binary>>) do "image/gif" end def verify(file_binary, extension) do case {type_from_binary(file_binary), type_from_extension(extension)} do {type, type} -> {:ok, type} _ -> {:error, "Warning, file format and file extension do not match."} end end end
28.314286
88
0.67003
73f2880f255221c2e9e6299b1e6bc1178d907016
2,321
ex
Elixir
lib/ex_unit_embedded.ex
hauleth/ex_unit_embedded
2969a813487d5e5582d4a2b2b78654451ab26aae
[ "Apache-2.0" ]
2
2020-03-03T10:41:33.000Z
2020-03-03T14:47:50.000Z
lib/ex_unit_embedded.ex
hauleth/ex_unit_embedded
2969a813487d5e5582d4a2b2b78654451ab26aae
[ "Apache-2.0" ]
null
null
null
lib/ex_unit_embedded.ex
hauleth/ex_unit_embedded
2969a813487d5e5582d4a2b2b78654451ab26aae
[ "Apache-2.0" ]
null
null
null
# Copyright 2018 Łukasz Niemier # # 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. defmodule ExUnitEmbedded do @moduledoc """ Documentation for ExUnitEmbedded. """ defmodule Macros do defmacro test(message, var \\ quote(do: _), contents) do contents = case contents do [do: block] -> quote do import ExUnit.Assertions unquote(block) :ok end _ -> quote do import ExUnit.Assertions try(unquote(contents)) :ok end end var = Macro.escape(var) contents = Macro.escape(contents, unquote: true) quote bind_quoted: [var: var, contents: contents, message: message] do if @ex_unit_embedded_enabled do name = :"embedded #{message}" def unquote(name)(unquote(var)), do: unquote(contents) @ex_unit_embedded_tests {message, name} end end end end defmacro __using__(opts) do envs = opts |> Keyword.get(:envs, [:test]) |> List.wrap() quote do import unquote(Macros), only: [test: 2, test: 3] @ex_unit_embedded_enabled Mix.env() in unquote(envs) if @ex_unit_embedded_enabled do Module.register_attribute(__MODULE__, :ex_unit_embedded_tests, accumulate: true, persist: true ) end end end defmacro unittest(mod) do quote bind_quoted: [mod: mod] do tests = Keyword.get(mod.module_info(:attributes), :ex_unit_embedded_tests, []) for {message, function} <- tests do name = ExUnit.Case.register_test(__ENV__, :embedded, message, []) def unquote(name)(env), do: apply(unquote(mod), unquote(function), [env]) end end end end
26.988372
84
0.619561
73f28eb888c384b1e0c70239b5c69664affd0c93
560
exs
Elixir
test/mssqlex/login_test.exs
rzane/mssqlex
f23bd7d5ac07ce220cab9a92517596b4de493188
[ "Apache-2.0" ]
null
null
null
test/mssqlex/login_test.exs
rzane/mssqlex
f23bd7d5ac07ce220cab9a92517596b4de493188
[ "Apache-2.0" ]
null
null
null
test/mssqlex/login_test.exs
rzane/mssqlex
f23bd7d5ac07ce220cab9a92517596b4de493188
[ "Apache-2.0" ]
null
null
null
defmodule Mssqlex.LoginTest do use ExUnit.Case, async: false alias Mssqlex.Result test "Given valid details, connects to database" do assert {:ok, pid} = Mssqlex.start_link([]) assert {:ok, _, %Result{num_rows: 1, rows: [["test"]]}} = Mssqlex.query(pid, "SELECT 'test'", []) end test "Given invalid details, errors" do Process.flag(:trap_exit, true) assert {:ok, pid} = Mssqlex.start_link(password: "badpass") assert_receive {:EXIT, ^pid, %Mssqlex.Error{odbc_code: :invalid_authorization}} end end
28
70
0.65
73f29e35ae57b9d8188d56db91aabd1a19da9c6a
2,409
ex
Elixir
lib/mpeg_audio_frame_parser/impl.ex
rfwatson/elixir-mp3-frame-parser
7e5661e2f5c39bed7ba587ba746ac1dd233b8717
[ "Unlicense" ]
1
2018-07-19T19:00:41.000Z
2018-07-19T19:00:41.000Z
lib/mpeg_audio_frame_parser/impl.ex
rfwatson/mpeg-audio-frame-parser
7e5661e2f5c39bed7ba587ba746ac1dd233b8717
[ "Unlicense" ]
null
null
null
lib/mpeg_audio_frame_parser/impl.ex
rfwatson/mpeg-audio-frame-parser
7e5661e2f5c39bed7ba587ba746ac1dd233b8717
[ "Unlicense" ]
null
null
null
defmodule MPEGAudioFrameParser.Impl do alias MPEGAudioFrameParser.Frame require Logger @sync_word 0b11111111111 @initial_state %{leftover: <<>>, current_frame: nil, frames: []} def init() do {:ok, @initial_state} end def add_packet(state, packet) do process_bytes(state, packet) end def pop_frame(%{frames: []} = state) do {:ok, nil, state} end def pop_frame(state) do {frame, rest} = List.pop_at(state.frames, -1) {:ok, frame, %{state | frames: rest}} end def flush(state) do {:ok, state.frames, @initial_state} end # Private Functions # Synced, and the current frame is complete: defp process_bytes(%{current_frame: %Frame{complete: true}} = state, packet) do frames = [state.current_frame | state.frames] process_bytes(%{state | current_frame: nil, frames: frames}, packet) end # No data left, or not enough to be able to validate next frame. Return: defp process_bytes(state, packet) when bit_size(packet) < 32 do {:ok, %{state | leftover: packet}} end # Leftover from previous call available. Prepend to this packet: defp process_bytes(%{leftover: leftover} = state, packet) when bit_size(leftover) > 0 do process_bytes(%{state | leftover: <<>>}, <<leftover::bits, packet::bits>>) end # Not synced, found a sync word. Create a new frame struct: defp process_bytes(%{current_frame: nil} = state, <<@sync_word::size(11), header::size(21), rest::bits>>) do header = <<@sync_word::size(11), header::size(21)>> frame = Frame.from_header(header) process_bytes(%{state | current_frame: frame}, rest) end # Not synced, no sync word found. Discard a byte: defp process_bytes(%{current_frame: nil} = state, packet) do <<_byte, rest::bits>> = packet process_bytes(state, rest) end # Synced, but with an invalid header. Discard a byte: defp process_bytes(%{current_frame: %Frame{valid: false}} = state, packet) do data = <<state.current_frame.data, packet::bits>> <<_byte, rest::bits>> = data process_bytes(%{state | current_frame: nil}, rest) end # Synced, current frame not complete and we have bytes available. Add bytes to frame: defp process_bytes(%{current_frame: %Frame{complete: false}} = state, packet) do {:ok, frame, rest} = Frame.add_bytes(state.current_frame, packet) process_bytes(%{state | current_frame: frame}, rest) end end
31.285714
110
0.681196
73f2b136468e0e118c28b8ec37ff9a88dd12520f
145,977
ex
Elixir
lib/codes/codes_t50.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
lib/codes/codes_t50.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
lib/codes/codes_t50.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
defmodule IcdCode.ICDCode.Codes_T50 do alias IcdCode.ICDCode def _T500X1A do %ICDCode{full_code: "T500X1A", category_code: "T50", short_code: "0X1A", full_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), initial encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), initial encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), initial encounter" } end def _T500X1D do %ICDCode{full_code: "T500X1D", category_code: "T50", short_code: "0X1D", full_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), subsequent encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), subsequent encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), subsequent encounter" } end def _T500X1S do %ICDCode{full_code: "T500X1S", category_code: "T50", short_code: "0X1S", full_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), sequela", short_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), sequela", category_name: "Poisoning by mineralocorticoids and their antagonists, accidental (unintentional), sequela" } end def _T500X2A do %ICDCode{full_code: "T500X2A", category_code: "T50", short_code: "0X2A", full_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, initial encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, initial encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, initial encounter" } end def _T500X2D do %ICDCode{full_code: "T500X2D", category_code: "T50", short_code: "0X2D", full_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, subsequent encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, subsequent encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, subsequent encounter" } end def _T500X2S do %ICDCode{full_code: "T500X2S", category_code: "T50", short_code: "0X2S", full_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, sequela", short_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, sequela", category_name: "Poisoning by mineralocorticoids and their antagonists, intentional self-harm, sequela" } end def _T500X3A do %ICDCode{full_code: "T500X3A", category_code: "T50", short_code: "0X3A", full_name: "Poisoning by mineralocorticoids and their antagonists, assault, initial encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, assault, initial encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, assault, initial encounter" } end def _T500X3D do %ICDCode{full_code: "T500X3D", category_code: "T50", short_code: "0X3D", full_name: "Poisoning by mineralocorticoids and their antagonists, assault, subsequent encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, assault, subsequent encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, assault, subsequent encounter" } end def _T500X3S do %ICDCode{full_code: "T500X3S", category_code: "T50", short_code: "0X3S", full_name: "Poisoning by mineralocorticoids and their antagonists, assault, sequela", short_name: "Poisoning by mineralocorticoids and their antagonists, assault, sequela", category_name: "Poisoning by mineralocorticoids and their antagonists, assault, sequela" } end def _T500X4A do %ICDCode{full_code: "T500X4A", category_code: "T50", short_code: "0X4A", full_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, initial encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, initial encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, initial encounter" } end def _T500X4D do %ICDCode{full_code: "T500X4D", category_code: "T50", short_code: "0X4D", full_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, subsequent encounter", short_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, subsequent encounter", category_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, subsequent encounter" } end def _T500X4S do %ICDCode{full_code: "T500X4S", category_code: "T50", short_code: "0X4S", full_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, sequela", short_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, sequela", category_name: "Poisoning by mineralocorticoids and their antagonists, undetermined, sequela" } end def _T500X5A do %ICDCode{full_code: "T500X5A", category_code: "T50", short_code: "0X5A", full_name: "Adverse effect of mineralocorticoids and their antagonists, initial encounter", short_name: "Adverse effect of mineralocorticoids and their antagonists, initial encounter", category_name: "Adverse effect of mineralocorticoids and their antagonists, initial encounter" } end def _T500X5D do %ICDCode{full_code: "T500X5D", category_code: "T50", short_code: "0X5D", full_name: "Adverse effect of mineralocorticoids and their antagonists, subsequent encounter", short_name: "Adverse effect of mineralocorticoids and their antagonists, subsequent encounter", category_name: "Adverse effect of mineralocorticoids and their antagonists, subsequent encounter" } end def _T500X5S do %ICDCode{full_code: "T500X5S", category_code: "T50", short_code: "0X5S", full_name: "Adverse effect of mineralocorticoids and their antagonists, sequela", short_name: "Adverse effect of mineralocorticoids and their antagonists, sequela", category_name: "Adverse effect of mineralocorticoids and their antagonists, sequela" } end def _T500X6A do %ICDCode{full_code: "T500X6A", category_code: "T50", short_code: "0X6A", full_name: "Underdosing of mineralocorticoids and their antagonists, initial encounter", short_name: "Underdosing of mineralocorticoids and their antagonists, initial encounter", category_name: "Underdosing of mineralocorticoids and their antagonists, initial encounter" } end def _T500X6D do %ICDCode{full_code: "T500X6D", category_code: "T50", short_code: "0X6D", full_name: "Underdosing of mineralocorticoids and their antagonists, subsequent encounter", short_name: "Underdosing of mineralocorticoids and their antagonists, subsequent encounter", category_name: "Underdosing of mineralocorticoids and their antagonists, subsequent encounter" } end def _T500X6S do %ICDCode{full_code: "T500X6S", category_code: "T50", short_code: "0X6S", full_name: "Underdosing of mineralocorticoids and their antagonists, sequela", short_name: "Underdosing of mineralocorticoids and their antagonists, sequela", category_name: "Underdosing of mineralocorticoids and their antagonists, sequela" } end def _T501X1A do %ICDCode{full_code: "T501X1A", category_code: "T50", short_code: "1X1A", full_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), initial encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), initial encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), initial encounter" } end def _T501X1D do %ICDCode{full_code: "T501X1D", category_code: "T50", short_code: "1X1D", full_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), subsequent encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), subsequent encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), subsequent encounter" } end def _T501X1S do %ICDCode{full_code: "T501X1S", category_code: "T50", short_code: "1X1S", full_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), sequela", short_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), sequela", category_name: "Poisoning by loop [high-ceiling] diuretics, accidental (unintentional), sequela" } end def _T501X2A do %ICDCode{full_code: "T501X2A", category_code: "T50", short_code: "1X2A", full_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, initial encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, initial encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, initial encounter" } end def _T501X2D do %ICDCode{full_code: "T501X2D", category_code: "T50", short_code: "1X2D", full_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, subsequent encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, subsequent encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, subsequent encounter" } end def _T501X2S do %ICDCode{full_code: "T501X2S", category_code: "T50", short_code: "1X2S", full_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, sequela", short_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, sequela", category_name: "Poisoning by loop [high-ceiling] diuretics, intentional self-harm, sequela" } end def _T501X3A do %ICDCode{full_code: "T501X3A", category_code: "T50", short_code: "1X3A", full_name: "Poisoning by loop [high-ceiling] diuretics, assault, initial encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, assault, initial encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, assault, initial encounter" } end def _T501X3D do %ICDCode{full_code: "T501X3D", category_code: "T50", short_code: "1X3D", full_name: "Poisoning by loop [high-ceiling] diuretics, assault, subsequent encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, assault, subsequent encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, assault, subsequent encounter" } end def _T501X3S do %ICDCode{full_code: "T501X3S", category_code: "T50", short_code: "1X3S", full_name: "Poisoning by loop [high-ceiling] diuretics, assault, sequela", short_name: "Poisoning by loop [high-ceiling] diuretics, assault, sequela", category_name: "Poisoning by loop [high-ceiling] diuretics, assault, sequela" } end def _T501X4A do %ICDCode{full_code: "T501X4A", category_code: "T50", short_code: "1X4A", full_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, initial encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, initial encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, initial encounter" } end def _T501X4D do %ICDCode{full_code: "T501X4D", category_code: "T50", short_code: "1X4D", full_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, subsequent encounter", short_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, subsequent encounter", category_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, subsequent encounter" } end def _T501X4S do %ICDCode{full_code: "T501X4S", category_code: "T50", short_code: "1X4S", full_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, sequela", short_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, sequela", category_name: "Poisoning by loop [high-ceiling] diuretics, undetermined, sequela" } end def _T501X5A do %ICDCode{full_code: "T501X5A", category_code: "T50", short_code: "1X5A", full_name: "Adverse effect of loop [high-ceiling] diuretics, initial encounter", short_name: "Adverse effect of loop [high-ceiling] diuretics, initial encounter", category_name: "Adverse effect of loop [high-ceiling] diuretics, initial encounter" } end def _T501X5D do %ICDCode{full_code: "T501X5D", category_code: "T50", short_code: "1X5D", full_name: "Adverse effect of loop [high-ceiling] diuretics, subsequent encounter", short_name: "Adverse effect of loop [high-ceiling] diuretics, subsequent encounter", category_name: "Adverse effect of loop [high-ceiling] diuretics, subsequent encounter" } end def _T501X5S do %ICDCode{full_code: "T501X5S", category_code: "T50", short_code: "1X5S", full_name: "Adverse effect of loop [high-ceiling] diuretics, sequela", short_name: "Adverse effect of loop [high-ceiling] diuretics, sequela", category_name: "Adverse effect of loop [high-ceiling] diuretics, sequela" } end def _T501X6A do %ICDCode{full_code: "T501X6A", category_code: "T50", short_code: "1X6A", full_name: "Underdosing of loop [high-ceiling] diuretics, initial encounter", short_name: "Underdosing of loop [high-ceiling] diuretics, initial encounter", category_name: "Underdosing of loop [high-ceiling] diuretics, initial encounter" } end def _T501X6D do %ICDCode{full_code: "T501X6D", category_code: "T50", short_code: "1X6D", full_name: "Underdosing of loop [high-ceiling] diuretics, subsequent encounter", short_name: "Underdosing of loop [high-ceiling] diuretics, subsequent encounter", category_name: "Underdosing of loop [high-ceiling] diuretics, subsequent encounter" } end def _T501X6S do %ICDCode{full_code: "T501X6S", category_code: "T50", short_code: "1X6S", full_name: "Underdosing of loop [high-ceiling] diuretics, sequela", short_name: "Underdosing of loop [high-ceiling] diuretics, sequela", category_name: "Underdosing of loop [high-ceiling] diuretics, sequela" } end def _T502X1A do %ICDCode{full_code: "T502X1A", category_code: "T50", short_code: "2X1A", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), initial encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), initial encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), initial encounter" } end def _T502X1D do %ICDCode{full_code: "T502X1D", category_code: "T50", short_code: "2X1D", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), subsequent encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), subsequent encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), subsequent encounter" } end def _T502X1S do %ICDCode{full_code: "T502X1S", category_code: "T50", short_code: "2X1S", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), sequela", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), sequela", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, accidental (unintentional), sequela" } end def _T502X2A do %ICDCode{full_code: "T502X2A", category_code: "T50", short_code: "2X2A", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, initial encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, initial encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, initial encounter" } end def _T502X2D do %ICDCode{full_code: "T502X2D", category_code: "T50", short_code: "2X2D", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, subsequent encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, subsequent encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, subsequent encounter" } end def _T502X2S do %ICDCode{full_code: "T502X2S", category_code: "T50", short_code: "2X2S", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, sequela", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, sequela", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, intentional self-harm, sequela" } end def _T502X3A do %ICDCode{full_code: "T502X3A", category_code: "T50", short_code: "2X3A", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, initial encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, initial encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, initial encounter" } end def _T502X3D do %ICDCode{full_code: "T502X3D", category_code: "T50", short_code: "2X3D", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, subsequent encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, subsequent encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, subsequent encounter" } end def _T502X3S do %ICDCode{full_code: "T502X3S", category_code: "T50", short_code: "2X3S", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, sequela", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, sequela", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, assault, sequela" } end def _T502X4A do %ICDCode{full_code: "T502X4A", category_code: "T50", short_code: "2X4A", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, initial encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, initial encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, initial encounter" } end def _T502X4D do %ICDCode{full_code: "T502X4D", category_code: "T50", short_code: "2X4D", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, subsequent encounter", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, subsequent encounter", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, subsequent encounter" } end def _T502X4S do %ICDCode{full_code: "T502X4S", category_code: "T50", short_code: "2X4S", full_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, sequela", short_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, sequela", category_name: "Poisoning by carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, undetermined, sequela" } end def _T502X5A do %ICDCode{full_code: "T502X5A", category_code: "T50", short_code: "2X5A", full_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter", short_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter", category_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter" } end def _T502X5D do %ICDCode{full_code: "T502X5D", category_code: "T50", short_code: "2X5D", full_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter", short_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter", category_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter" } end def _T502X5S do %ICDCode{full_code: "T502X5S", category_code: "T50", short_code: "2X5S", full_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela", short_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela", category_name: "Adverse effect of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela" } end def _T502X6A do %ICDCode{full_code: "T502X6A", category_code: "T50", short_code: "2X6A", full_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter", short_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter", category_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, initial encounter" } end def _T502X6D do %ICDCode{full_code: "T502X6D", category_code: "T50", short_code: "2X6D", full_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter", short_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter", category_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, subsequent encounter" } end def _T502X6S do %ICDCode{full_code: "T502X6S", category_code: "T50", short_code: "2X6S", full_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela", short_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela", category_name: "Underdosing of carbonic-anhydrase inhibitors, benzothiadiazides and other diuretics, sequela" } end def _T503X1A do %ICDCode{full_code: "T503X1A", category_code: "T50", short_code: "3X1A", full_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), initial encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), initial encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), initial encounter" } end def _T503X1D do %ICDCode{full_code: "T503X1D", category_code: "T50", short_code: "3X1D", full_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), subsequent encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), subsequent encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), subsequent encounter" } end def _T503X1S do %ICDCode{full_code: "T503X1S", category_code: "T50", short_code: "3X1S", full_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), sequela", short_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), sequela", category_name: "Poisoning by electrolytic, caloric and water-balance agents, accidental (unintentional), sequela" } end def _T503X2A do %ICDCode{full_code: "T503X2A", category_code: "T50", short_code: "3X2A", full_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, initial encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, initial encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, initial encounter" } end def _T503X2D do %ICDCode{full_code: "T503X2D", category_code: "T50", short_code: "3X2D", full_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, subsequent encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, subsequent encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, subsequent encounter" } end def _T503X2S do %ICDCode{full_code: "T503X2S", category_code: "T50", short_code: "3X2S", full_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, sequela", short_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, sequela", category_name: "Poisoning by electrolytic, caloric and water-balance agents, intentional self-harm, sequela" } end def _T503X3A do %ICDCode{full_code: "T503X3A", category_code: "T50", short_code: "3X3A", full_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, initial encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, initial encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, initial encounter" } end def _T503X3D do %ICDCode{full_code: "T503X3D", category_code: "T50", short_code: "3X3D", full_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, subsequent encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, subsequent encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, subsequent encounter" } end def _T503X3S do %ICDCode{full_code: "T503X3S", category_code: "T50", short_code: "3X3S", full_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, sequela", short_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, sequela", category_name: "Poisoning by electrolytic, caloric and water-balance agents, assault, sequela" } end def _T503X4A do %ICDCode{full_code: "T503X4A", category_code: "T50", short_code: "3X4A", full_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, initial encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, initial encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, initial encounter" } end def _T503X4D do %ICDCode{full_code: "T503X4D", category_code: "T50", short_code: "3X4D", full_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, subsequent encounter", short_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, subsequent encounter", category_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, subsequent encounter" } end def _T503X4S do %ICDCode{full_code: "T503X4S", category_code: "T50", short_code: "3X4S", full_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, sequela", short_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, sequela", category_name: "Poisoning by electrolytic, caloric and water-balance agents, undetermined, sequela" } end def _T503X5A do %ICDCode{full_code: "T503X5A", category_code: "T50", short_code: "3X5A", full_name: "Adverse effect of electrolytic, caloric and water-balance agents, initial encounter", short_name: "Adverse effect of electrolytic, caloric and water-balance agents, initial encounter", category_name: "Adverse effect of electrolytic, caloric and water-balance agents, initial encounter" } end def _T503X5D do %ICDCode{full_code: "T503X5D", category_code: "T50", short_code: "3X5D", full_name: "Adverse effect of electrolytic, caloric and water-balance agents, subsequent encounter", short_name: "Adverse effect of electrolytic, caloric and water-balance agents, subsequent encounter", category_name: "Adverse effect of electrolytic, caloric and water-balance agents, subsequent encounter" } end def _T503X5S do %ICDCode{full_code: "T503X5S", category_code: "T50", short_code: "3X5S", full_name: "Adverse effect of electrolytic, caloric and water-balance agents, sequela", short_name: "Adverse effect of electrolytic, caloric and water-balance agents, sequela", category_name: "Adverse effect of electrolytic, caloric and water-balance agents, sequela" } end def _T503X6A do %ICDCode{full_code: "T503X6A", category_code: "T50", short_code: "3X6A", full_name: "Underdosing of electrolytic, caloric and water-balance agents, initial encounter", short_name: "Underdosing of electrolytic, caloric and water-balance agents, initial encounter", category_name: "Underdosing of electrolytic, caloric and water-balance agents, initial encounter" } end def _T503X6D do %ICDCode{full_code: "T503X6D", category_code: "T50", short_code: "3X6D", full_name: "Underdosing of electrolytic, caloric and water-balance agents, subsequent encounter", short_name: "Underdosing of electrolytic, caloric and water-balance agents, subsequent encounter", category_name: "Underdosing of electrolytic, caloric and water-balance agents, subsequent encounter" } end def _T503X6S do %ICDCode{full_code: "T503X6S", category_code: "T50", short_code: "3X6S", full_name: "Underdosing of electrolytic, caloric and water-balance agents, sequela", short_name: "Underdosing of electrolytic, caloric and water-balance agents, sequela", category_name: "Underdosing of electrolytic, caloric and water-balance agents, sequela" } end def _T504X1A do %ICDCode{full_code: "T504X1A", category_code: "T50", short_code: "4X1A", full_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), initial encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), initial encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), initial encounter" } end def _T504X1D do %ICDCode{full_code: "T504X1D", category_code: "T50", short_code: "4X1D", full_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), subsequent encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), subsequent encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), subsequent encounter" } end def _T504X1S do %ICDCode{full_code: "T504X1S", category_code: "T50", short_code: "4X1S", full_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), sequela", short_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), sequela", category_name: "Poisoning by drugs affecting uric acid metabolism, accidental (unintentional), sequela" } end def _T504X2A do %ICDCode{full_code: "T504X2A", category_code: "T50", short_code: "4X2A", full_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, initial encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, initial encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, initial encounter" } end def _T504X2D do %ICDCode{full_code: "T504X2D", category_code: "T50", short_code: "4X2D", full_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, subsequent encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, subsequent encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, subsequent encounter" } end def _T504X2S do %ICDCode{full_code: "T504X2S", category_code: "T50", short_code: "4X2S", full_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, sequela", short_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, sequela", category_name: "Poisoning by drugs affecting uric acid metabolism, intentional self-harm, sequela" } end def _T504X3A do %ICDCode{full_code: "T504X3A", category_code: "T50", short_code: "4X3A", full_name: "Poisoning by drugs affecting uric acid metabolism, assault, initial encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, assault, initial encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, assault, initial encounter" } end def _T504X3D do %ICDCode{full_code: "T504X3D", category_code: "T50", short_code: "4X3D", full_name: "Poisoning by drugs affecting uric acid metabolism, assault, subsequent encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, assault, subsequent encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, assault, subsequent encounter" } end def _T504X3S do %ICDCode{full_code: "T504X3S", category_code: "T50", short_code: "4X3S", full_name: "Poisoning by drugs affecting uric acid metabolism, assault, sequela", short_name: "Poisoning by drugs affecting uric acid metabolism, assault, sequela", category_name: "Poisoning by drugs affecting uric acid metabolism, assault, sequela" } end def _T504X4A do %ICDCode{full_code: "T504X4A", category_code: "T50", short_code: "4X4A", full_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, initial encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, initial encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, initial encounter" } end def _T504X4D do %ICDCode{full_code: "T504X4D", category_code: "T50", short_code: "4X4D", full_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, subsequent encounter", short_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, subsequent encounter", category_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, subsequent encounter" } end def _T504X4S do %ICDCode{full_code: "T504X4S", category_code: "T50", short_code: "4X4S", full_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, sequela", short_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, sequela", category_name: "Poisoning by drugs affecting uric acid metabolism, undetermined, sequela" } end def _T504X5A do %ICDCode{full_code: "T504X5A", category_code: "T50", short_code: "4X5A", full_name: "Adverse effect of drugs affecting uric acid metabolism, initial encounter", short_name: "Adverse effect of drugs affecting uric acid metabolism, initial encounter", category_name: "Adverse effect of drugs affecting uric acid metabolism, initial encounter" } end def _T504X5D do %ICDCode{full_code: "T504X5D", category_code: "T50", short_code: "4X5D", full_name: "Adverse effect of drugs affecting uric acid metabolism, subsequent encounter", short_name: "Adverse effect of drugs affecting uric acid metabolism, subsequent encounter", category_name: "Adverse effect of drugs affecting uric acid metabolism, subsequent encounter" } end def _T504X5S do %ICDCode{full_code: "T504X5S", category_code: "T50", short_code: "4X5S", full_name: "Adverse effect of drugs affecting uric acid metabolism, sequela", short_name: "Adverse effect of drugs affecting uric acid metabolism, sequela", category_name: "Adverse effect of drugs affecting uric acid metabolism, sequela" } end def _T504X6A do %ICDCode{full_code: "T504X6A", category_code: "T50", short_code: "4X6A", full_name: "Underdosing of drugs affecting uric acid metabolism, initial encounter", short_name: "Underdosing of drugs affecting uric acid metabolism, initial encounter", category_name: "Underdosing of drugs affecting uric acid metabolism, initial encounter" } end def _T504X6D do %ICDCode{full_code: "T504X6D", category_code: "T50", short_code: "4X6D", full_name: "Underdosing of drugs affecting uric acid metabolism, subsequent encounter", short_name: "Underdosing of drugs affecting uric acid metabolism, subsequent encounter", category_name: "Underdosing of drugs affecting uric acid metabolism, subsequent encounter" } end def _T504X6S do %ICDCode{full_code: "T504X6S", category_code: "T50", short_code: "4X6S", full_name: "Underdosing of drugs affecting uric acid metabolism, sequela", short_name: "Underdosing of drugs affecting uric acid metabolism, sequela", category_name: "Underdosing of drugs affecting uric acid metabolism, sequela" } end def _T505X1A do %ICDCode{full_code: "T505X1A", category_code: "T50", short_code: "5X1A", full_name: "Poisoning by appetite depressants, accidental (unintentional), initial encounter", short_name: "Poisoning by appetite depressants, accidental (unintentional), initial encounter", category_name: "Poisoning by appetite depressants, accidental (unintentional), initial encounter" } end def _T505X1D do %ICDCode{full_code: "T505X1D", category_code: "T50", short_code: "5X1D", full_name: "Poisoning by appetite depressants, accidental (unintentional), subsequent encounter", short_name: "Poisoning by appetite depressants, accidental (unintentional), subsequent encounter", category_name: "Poisoning by appetite depressants, accidental (unintentional), subsequent encounter" } end def _T505X1S do %ICDCode{full_code: "T505X1S", category_code: "T50", short_code: "5X1S", full_name: "Poisoning by appetite depressants, accidental (unintentional), sequela", short_name: "Poisoning by appetite depressants, accidental (unintentional), sequela", category_name: "Poisoning by appetite depressants, accidental (unintentional), sequela" } end def _T505X2A do %ICDCode{full_code: "T505X2A", category_code: "T50", short_code: "5X2A", full_name: "Poisoning by appetite depressants, intentional self-harm, initial encounter", short_name: "Poisoning by appetite depressants, intentional self-harm, initial encounter", category_name: "Poisoning by appetite depressants, intentional self-harm, initial encounter" } end def _T505X2D do %ICDCode{full_code: "T505X2D", category_code: "T50", short_code: "5X2D", full_name: "Poisoning by appetite depressants, intentional self-harm, subsequent encounter", short_name: "Poisoning by appetite depressants, intentional self-harm, subsequent encounter", category_name: "Poisoning by appetite depressants, intentional self-harm, subsequent encounter" } end def _T505X2S do %ICDCode{full_code: "T505X2S", category_code: "T50", short_code: "5X2S", full_name: "Poisoning by appetite depressants, intentional self-harm, sequela", short_name: "Poisoning by appetite depressants, intentional self-harm, sequela", category_name: "Poisoning by appetite depressants, intentional self-harm, sequela" } end def _T505X3A do %ICDCode{full_code: "T505X3A", category_code: "T50", short_code: "5X3A", full_name: "Poisoning by appetite depressants, assault, initial encounter", short_name: "Poisoning by appetite depressants, assault, initial encounter", category_name: "Poisoning by appetite depressants, assault, initial encounter" } end def _T505X3D do %ICDCode{full_code: "T505X3D", category_code: "T50", short_code: "5X3D", full_name: "Poisoning by appetite depressants, assault, subsequent encounter", short_name: "Poisoning by appetite depressants, assault, subsequent encounter", category_name: "Poisoning by appetite depressants, assault, subsequent encounter" } end def _T505X3S do %ICDCode{full_code: "T505X3S", category_code: "T50", short_code: "5X3S", full_name: "Poisoning by appetite depressants, assault, sequela", short_name: "Poisoning by appetite depressants, assault, sequela", category_name: "Poisoning by appetite depressants, assault, sequela" } end def _T505X4A do %ICDCode{full_code: "T505X4A", category_code: "T50", short_code: "5X4A", full_name: "Poisoning by appetite depressants, undetermined, initial encounter", short_name: "Poisoning by appetite depressants, undetermined, initial encounter", category_name: "Poisoning by appetite depressants, undetermined, initial encounter" } end def _T505X4D do %ICDCode{full_code: "T505X4D", category_code: "T50", short_code: "5X4D", full_name: "Poisoning by appetite depressants, undetermined, subsequent encounter", short_name: "Poisoning by appetite depressants, undetermined, subsequent encounter", category_name: "Poisoning by appetite depressants, undetermined, subsequent encounter" } end def _T505X4S do %ICDCode{full_code: "T505X4S", category_code: "T50", short_code: "5X4S", full_name: "Poisoning by appetite depressants, undetermined, sequela", short_name: "Poisoning by appetite depressants, undetermined, sequela", category_name: "Poisoning by appetite depressants, undetermined, sequela" } end def _T505X5A do %ICDCode{full_code: "T505X5A", category_code: "T50", short_code: "5X5A", full_name: "Adverse effect of appetite depressants, initial encounter", short_name: "Adverse effect of appetite depressants, initial encounter", category_name: "Adverse effect of appetite depressants, initial encounter" } end def _T505X5D do %ICDCode{full_code: "T505X5D", category_code: "T50", short_code: "5X5D", full_name: "Adverse effect of appetite depressants, subsequent encounter", short_name: "Adverse effect of appetite depressants, subsequent encounter", category_name: "Adverse effect of appetite depressants, subsequent encounter" } end def _T505X5S do %ICDCode{full_code: "T505X5S", category_code: "T50", short_code: "5X5S", full_name: "Adverse effect of appetite depressants, sequela", short_name: "Adverse effect of appetite depressants, sequela", category_name: "Adverse effect of appetite depressants, sequela" } end def _T505X6A do %ICDCode{full_code: "T505X6A", category_code: "T50", short_code: "5X6A", full_name: "Underdosing of appetite depressants, initial encounter", short_name: "Underdosing of appetite depressants, initial encounter", category_name: "Underdosing of appetite depressants, initial encounter" } end def _T505X6D do %ICDCode{full_code: "T505X6D", category_code: "T50", short_code: "5X6D", full_name: "Underdosing of appetite depressants, subsequent encounter", short_name: "Underdosing of appetite depressants, subsequent encounter", category_name: "Underdosing of appetite depressants, subsequent encounter" } end def _T505X6S do %ICDCode{full_code: "T505X6S", category_code: "T50", short_code: "5X6S", full_name: "Underdosing of appetite depressants, sequela", short_name: "Underdosing of appetite depressants, sequela", category_name: "Underdosing of appetite depressants, sequela" } end def _T506X1A do %ICDCode{full_code: "T506X1A", category_code: "T50", short_code: "6X1A", full_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), initial encounter", short_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), initial encounter", category_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), initial encounter" } end def _T506X1D do %ICDCode{full_code: "T506X1D", category_code: "T50", short_code: "6X1D", full_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), subsequent encounter", short_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), subsequent encounter", category_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), subsequent encounter" } end def _T506X1S do %ICDCode{full_code: "T506X1S", category_code: "T50", short_code: "6X1S", full_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), sequela", short_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), sequela", category_name: "Poisoning by antidotes and chelating agents, accidental (unintentional), sequela" } end def _T506X2A do %ICDCode{full_code: "T506X2A", category_code: "T50", short_code: "6X2A", full_name: "Poisoning by antidotes and chelating agents, intentional self-harm, initial encounter", short_name: "Poisoning by antidotes and chelating agents, intentional self-harm, initial encounter", category_name: "Poisoning by antidotes and chelating agents, intentional self-harm, initial encounter" } end def _T506X2D do %ICDCode{full_code: "T506X2D", category_code: "T50", short_code: "6X2D", full_name: "Poisoning by antidotes and chelating agents, intentional self-harm, subsequent encounter", short_name: "Poisoning by antidotes and chelating agents, intentional self-harm, subsequent encounter", category_name: "Poisoning by antidotes and chelating agents, intentional self-harm, subsequent encounter" } end def _T506X2S do %ICDCode{full_code: "T506X2S", category_code: "T50", short_code: "6X2S", full_name: "Poisoning by antidotes and chelating agents, intentional self-harm, sequela", short_name: "Poisoning by antidotes and chelating agents, intentional self-harm, sequela", category_name: "Poisoning by antidotes and chelating agents, intentional self-harm, sequela" } end def _T506X3A do %ICDCode{full_code: "T506X3A", category_code: "T50", short_code: "6X3A", full_name: "Poisoning by antidotes and chelating agents, assault, initial encounter", short_name: "Poisoning by antidotes and chelating agents, assault, initial encounter", category_name: "Poisoning by antidotes and chelating agents, assault, initial encounter" } end def _T506X3D do %ICDCode{full_code: "T506X3D", category_code: "T50", short_code: "6X3D", full_name: "Poisoning by antidotes and chelating agents, assault, subsequent encounter", short_name: "Poisoning by antidotes and chelating agents, assault, subsequent encounter", category_name: "Poisoning by antidotes and chelating agents, assault, subsequent encounter" } end def _T506X3S do %ICDCode{full_code: "T506X3S", category_code: "T50", short_code: "6X3S", full_name: "Poisoning by antidotes and chelating agents, assault, sequela", short_name: "Poisoning by antidotes and chelating agents, assault, sequela", category_name: "Poisoning by antidotes and chelating agents, assault, sequela" } end def _T506X4A do %ICDCode{full_code: "T506X4A", category_code: "T50", short_code: "6X4A", full_name: "Poisoning by antidotes and chelating agents, undetermined, initial encounter", short_name: "Poisoning by antidotes and chelating agents, undetermined, initial encounter", category_name: "Poisoning by antidotes and chelating agents, undetermined, initial encounter" } end def _T506X4D do %ICDCode{full_code: "T506X4D", category_code: "T50", short_code: "6X4D", full_name: "Poisoning by antidotes and chelating agents, undetermined, subsequent encounter", short_name: "Poisoning by antidotes and chelating agents, undetermined, subsequent encounter", category_name: "Poisoning by antidotes and chelating agents, undetermined, subsequent encounter" } end def _T506X4S do %ICDCode{full_code: "T506X4S", category_code: "T50", short_code: "6X4S", full_name: "Poisoning by antidotes and chelating agents, undetermined, sequela", short_name: "Poisoning by antidotes and chelating agents, undetermined, sequela", category_name: "Poisoning by antidotes and chelating agents, undetermined, sequela" } end def _T506X5A do %ICDCode{full_code: "T506X5A", category_code: "T50", short_code: "6X5A", full_name: "Adverse effect of antidotes and chelating agents, initial encounter", short_name: "Adverse effect of antidotes and chelating agents, initial encounter", category_name: "Adverse effect of antidotes and chelating agents, initial encounter" } end def _T506X5D do %ICDCode{full_code: "T506X5D", category_code: "T50", short_code: "6X5D", full_name: "Adverse effect of antidotes and chelating agents, subsequent encounter", short_name: "Adverse effect of antidotes and chelating agents, subsequent encounter", category_name: "Adverse effect of antidotes and chelating agents, subsequent encounter" } end def _T506X5S do %ICDCode{full_code: "T506X5S", category_code: "T50", short_code: "6X5S", full_name: "Adverse effect of antidotes and chelating agents, sequela", short_name: "Adverse effect of antidotes and chelating agents, sequela", category_name: "Adverse effect of antidotes and chelating agents, sequela" } end def _T506X6A do %ICDCode{full_code: "T506X6A", category_code: "T50", short_code: "6X6A", full_name: "Underdosing of antidotes and chelating agents, initial encounter", short_name: "Underdosing of antidotes and chelating agents, initial encounter", category_name: "Underdosing of antidotes and chelating agents, initial encounter" } end def _T506X6D do %ICDCode{full_code: "T506X6D", category_code: "T50", short_code: "6X6D", full_name: "Underdosing of antidotes and chelating agents, subsequent encounter", short_name: "Underdosing of antidotes and chelating agents, subsequent encounter", category_name: "Underdosing of antidotes and chelating agents, subsequent encounter" } end def _T506X6S do %ICDCode{full_code: "T506X6S", category_code: "T50", short_code: "6X6S", full_name: "Underdosing of antidotes and chelating agents, sequela", short_name: "Underdosing of antidotes and chelating agents, sequela", category_name: "Underdosing of antidotes and chelating agents, sequela" } end def _T507X1A do %ICDCode{full_code: "T507X1A", category_code: "T50", short_code: "7X1A", full_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), initial encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), initial encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), initial encounter" } end def _T507X1D do %ICDCode{full_code: "T507X1D", category_code: "T50", short_code: "7X1D", full_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), subsequent encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), subsequent encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), subsequent encounter" } end def _T507X1S do %ICDCode{full_code: "T507X1S", category_code: "T50", short_code: "7X1S", full_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), sequela", short_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), sequela", category_name: "Poisoning by analeptics and opioid receptor antagonists, accidental (unintentional), sequela" } end def _T507X2A do %ICDCode{full_code: "T507X2A", category_code: "T50", short_code: "7X2A", full_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, initial encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, initial encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, initial encounter" } end def _T507X2D do %ICDCode{full_code: "T507X2D", category_code: "T50", short_code: "7X2D", full_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, subsequent encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, subsequent encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, subsequent encounter" } end def _T507X2S do %ICDCode{full_code: "T507X2S", category_code: "T50", short_code: "7X2S", full_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, sequela", short_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, sequela", category_name: "Poisoning by analeptics and opioid receptor antagonists, intentional self-harm, sequela" } end def _T507X3A do %ICDCode{full_code: "T507X3A", category_code: "T50", short_code: "7X3A", full_name: "Poisoning by analeptics and opioid receptor antagonists, assault, initial encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, assault, initial encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, assault, initial encounter" } end def _T507X3D do %ICDCode{full_code: "T507X3D", category_code: "T50", short_code: "7X3D", full_name: "Poisoning by analeptics and opioid receptor antagonists, assault, subsequent encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, assault, subsequent encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, assault, subsequent encounter" } end def _T507X3S do %ICDCode{full_code: "T507X3S", category_code: "T50", short_code: "7X3S", full_name: "Poisoning by analeptics and opioid receptor antagonists, assault, sequela", short_name: "Poisoning by analeptics and opioid receptor antagonists, assault, sequela", category_name: "Poisoning by analeptics and opioid receptor antagonists, assault, sequela" } end def _T507X4A do %ICDCode{full_code: "T507X4A", category_code: "T50", short_code: "7X4A", full_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, initial encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, initial encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, initial encounter" } end def _T507X4D do %ICDCode{full_code: "T507X4D", category_code: "T50", short_code: "7X4D", full_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, subsequent encounter", short_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, subsequent encounter", category_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, subsequent encounter" } end def _T507X4S do %ICDCode{full_code: "T507X4S", category_code: "T50", short_code: "7X4S", full_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, sequela", short_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, sequela", category_name: "Poisoning by analeptics and opioid receptor antagonists, undetermined, sequela" } end def _T507X5A do %ICDCode{full_code: "T507X5A", category_code: "T50", short_code: "7X5A", full_name: "Adverse effect of analeptics and opioid receptor antagonists, initial encounter", short_name: "Adverse effect of analeptics and opioid receptor antagonists, initial encounter", category_name: "Adverse effect of analeptics and opioid receptor antagonists, initial encounter" } end def _T507X5D do %ICDCode{full_code: "T507X5D", category_code: "T50", short_code: "7X5D", full_name: "Adverse effect of analeptics and opioid receptor antagonists, subsequent encounter", short_name: "Adverse effect of analeptics and opioid receptor antagonists, subsequent encounter", category_name: "Adverse effect of analeptics and opioid receptor antagonists, subsequent encounter" } end def _T507X5S do %ICDCode{full_code: "T507X5S", category_code: "T50", short_code: "7X5S", full_name: "Adverse effect of analeptics and opioid receptor antagonists, sequela", short_name: "Adverse effect of analeptics and opioid receptor antagonists, sequela", category_name: "Adverse effect of analeptics and opioid receptor antagonists, sequela" } end def _T507X6A do %ICDCode{full_code: "T507X6A", category_code: "T50", short_code: "7X6A", full_name: "Underdosing of analeptics and opioid receptor antagonists, initial encounter", short_name: "Underdosing of analeptics and opioid receptor antagonists, initial encounter", category_name: "Underdosing of analeptics and opioid receptor antagonists, initial encounter" } end def _T507X6D do %ICDCode{full_code: "T507X6D", category_code: "T50", short_code: "7X6D", full_name: "Underdosing of analeptics and opioid receptor antagonists, subsequent encounter", short_name: "Underdosing of analeptics and opioid receptor antagonists, subsequent encounter", category_name: "Underdosing of analeptics and opioid receptor antagonists, subsequent encounter" } end def _T507X6S do %ICDCode{full_code: "T507X6S", category_code: "T50", short_code: "7X6S", full_name: "Underdosing of analeptics and opioid receptor antagonists, sequela", short_name: "Underdosing of analeptics and opioid receptor antagonists, sequela", category_name: "Underdosing of analeptics and opioid receptor antagonists, sequela" } end def _T508X1A do %ICDCode{full_code: "T508X1A", category_code: "T50", short_code: "8X1A", full_name: "Poisoning by diagnostic agents, accidental (unintentional), initial encounter", short_name: "Poisoning by diagnostic agents, accidental (unintentional), initial encounter", category_name: "Poisoning by diagnostic agents, accidental (unintentional), initial encounter" } end def _T508X1D do %ICDCode{full_code: "T508X1D", category_code: "T50", short_code: "8X1D", full_name: "Poisoning by diagnostic agents, accidental (unintentional), subsequent encounter", short_name: "Poisoning by diagnostic agents, accidental (unintentional), subsequent encounter", category_name: "Poisoning by diagnostic agents, accidental (unintentional), subsequent encounter" } end def _T508X1S do %ICDCode{full_code: "T508X1S", category_code: "T50", short_code: "8X1S", full_name: "Poisoning by diagnostic agents, accidental (unintentional), sequela", short_name: "Poisoning by diagnostic agents, accidental (unintentional), sequela", category_name: "Poisoning by diagnostic agents, accidental (unintentional), sequela" } end def _T508X2A do %ICDCode{full_code: "T508X2A", category_code: "T50", short_code: "8X2A", full_name: "Poisoning by diagnostic agents, intentional self-harm, initial encounter", short_name: "Poisoning by diagnostic agents, intentional self-harm, initial encounter", category_name: "Poisoning by diagnostic agents, intentional self-harm, initial encounter" } end def _T508X2D do %ICDCode{full_code: "T508X2D", category_code: "T50", short_code: "8X2D", full_name: "Poisoning by diagnostic agents, intentional self-harm, subsequent encounter", short_name: "Poisoning by diagnostic agents, intentional self-harm, subsequent encounter", category_name: "Poisoning by diagnostic agents, intentional self-harm, subsequent encounter" } end def _T508X2S do %ICDCode{full_code: "T508X2S", category_code: "T50", short_code: "8X2S", full_name: "Poisoning by diagnostic agents, intentional self-harm, sequela", short_name: "Poisoning by diagnostic agents, intentional self-harm, sequela", category_name: "Poisoning by diagnostic agents, intentional self-harm, sequela" } end def _T508X3A do %ICDCode{full_code: "T508X3A", category_code: "T50", short_code: "8X3A", full_name: "Poisoning by diagnostic agents, assault, initial encounter", short_name: "Poisoning by diagnostic agents, assault, initial encounter", category_name: "Poisoning by diagnostic agents, assault, initial encounter" } end def _T508X3D do %ICDCode{full_code: "T508X3D", category_code: "T50", short_code: "8X3D", full_name: "Poisoning by diagnostic agents, assault, subsequent encounter", short_name: "Poisoning by diagnostic agents, assault, subsequent encounter", category_name: "Poisoning by diagnostic agents, assault, subsequent encounter" } end def _T508X3S do %ICDCode{full_code: "T508X3S", category_code: "T50", short_code: "8X3S", full_name: "Poisoning by diagnostic agents, assault, sequela", short_name: "Poisoning by diagnostic agents, assault, sequela", category_name: "Poisoning by diagnostic agents, assault, sequela" } end def _T508X4A do %ICDCode{full_code: "T508X4A", category_code: "T50", short_code: "8X4A", full_name: "Poisoning by diagnostic agents, undetermined, initial encounter", short_name: "Poisoning by diagnostic agents, undetermined, initial encounter", category_name: "Poisoning by diagnostic agents, undetermined, initial encounter" } end def _T508X4D do %ICDCode{full_code: "T508X4D", category_code: "T50", short_code: "8X4D", full_name: "Poisoning by diagnostic agents, undetermined, subsequent encounter", short_name: "Poisoning by diagnostic agents, undetermined, subsequent encounter", category_name: "Poisoning by diagnostic agents, undetermined, subsequent encounter" } end def _T508X4S do %ICDCode{full_code: "T508X4S", category_code: "T50", short_code: "8X4S", full_name: "Poisoning by diagnostic agents, undetermined, sequela", short_name: "Poisoning by diagnostic agents, undetermined, sequela", category_name: "Poisoning by diagnostic agents, undetermined, sequela" } end def _T508X5A do %ICDCode{full_code: "T508X5A", category_code: "T50", short_code: "8X5A", full_name: "Adverse effect of diagnostic agents, initial encounter", short_name: "Adverse effect of diagnostic agents, initial encounter", category_name: "Adverse effect of diagnostic agents, initial encounter" } end def _T508X5D do %ICDCode{full_code: "T508X5D", category_code: "T50", short_code: "8X5D", full_name: "Adverse effect of diagnostic agents, subsequent encounter", short_name: "Adverse effect of diagnostic agents, subsequent encounter", category_name: "Adverse effect of diagnostic agents, subsequent encounter" } end def _T508X5S do %ICDCode{full_code: "T508X5S", category_code: "T50", short_code: "8X5S", full_name: "Adverse effect of diagnostic agents, sequela", short_name: "Adverse effect of diagnostic agents, sequela", category_name: "Adverse effect of diagnostic agents, sequela" } end def _T508X6A do %ICDCode{full_code: "T508X6A", category_code: "T50", short_code: "8X6A", full_name: "Underdosing of diagnostic agents, initial encounter", short_name: "Underdosing of diagnostic agents, initial encounter", category_name: "Underdosing of diagnostic agents, initial encounter" } end def _T508X6D do %ICDCode{full_code: "T508X6D", category_code: "T50", short_code: "8X6D", full_name: "Underdosing of diagnostic agents, subsequent encounter", short_name: "Underdosing of diagnostic agents, subsequent encounter", category_name: "Underdosing of diagnostic agents, subsequent encounter" } end def _T508X6S do %ICDCode{full_code: "T508X6S", category_code: "T50", short_code: "8X6S", full_name: "Underdosing of diagnostic agents, sequela", short_name: "Underdosing of diagnostic agents, sequela", category_name: "Underdosing of diagnostic agents, sequela" } end def _T50A11A do %ICDCode{full_code: "T50A11A", category_code: "T50", short_code: "A11A", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), initial encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), initial encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), initial encounter" } end def _T50A11D do %ICDCode{full_code: "T50A11D", category_code: "T50", short_code: "A11D", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), subsequent encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), subsequent encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), subsequent encounter" } end def _T50A11S do %ICDCode{full_code: "T50A11S", category_code: "T50", short_code: "A11S", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), sequela", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), sequela", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, accidental (unintentional), sequela" } end def _T50A12A do %ICDCode{full_code: "T50A12A", category_code: "T50", short_code: "A12A", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, initial encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, initial encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, initial encounter" } end def _T50A12D do %ICDCode{full_code: "T50A12D", category_code: "T50", short_code: "A12D", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, subsequent encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, subsequent encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, subsequent encounter" } end def _T50A12S do %ICDCode{full_code: "T50A12S", category_code: "T50", short_code: "A12S", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, sequela", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, sequela", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, intentional self-harm, sequela" } end def _T50A13A do %ICDCode{full_code: "T50A13A", category_code: "T50", short_code: "A13A", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, initial encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, initial encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, initial encounter" } end def _T50A13D do %ICDCode{full_code: "T50A13D", category_code: "T50", short_code: "A13D", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, subsequent encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, subsequent encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, subsequent encounter" } end def _T50A13S do %ICDCode{full_code: "T50A13S", category_code: "T50", short_code: "A13S", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, sequela", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, sequela", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, assault, sequela" } end def _T50A14A do %ICDCode{full_code: "T50A14A", category_code: "T50", short_code: "A14A", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, initial encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, initial encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, initial encounter" } end def _T50A14D do %ICDCode{full_code: "T50A14D", category_code: "T50", short_code: "A14D", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, subsequent encounter", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, subsequent encounter", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, subsequent encounter" } end def _T50A14S do %ICDCode{full_code: "T50A14S", category_code: "T50", short_code: "A14S", full_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, sequela", short_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, sequela", category_name: "Poisoning by pertussis vaccine, including combinations with a pertussis component, undetermined, sequela" } end def _T50A15A do %ICDCode{full_code: "T50A15A", category_code: "T50", short_code: "A15A", full_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, initial encounter", short_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, initial encounter", category_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, initial encounter" } end def _T50A15D do %ICDCode{full_code: "T50A15D", category_code: "T50", short_code: "A15D", full_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, subsequent encounter", short_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, subsequent encounter", category_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, subsequent encounter" } end def _T50A15S do %ICDCode{full_code: "T50A15S", category_code: "T50", short_code: "A15S", full_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, sequela", short_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, sequela", category_name: "Adverse effect of pertussis vaccine, including combinations with a pertussis component, sequela" } end def _T50A16A do %ICDCode{full_code: "T50A16A", category_code: "T50", short_code: "A16A", full_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, initial encounter", short_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, initial encounter", category_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, initial encounter" } end def _T50A16D do %ICDCode{full_code: "T50A16D", category_code: "T50", short_code: "A16D", full_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, subsequent encounter", short_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, subsequent encounter", category_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, subsequent encounter" } end def _T50A16S do %ICDCode{full_code: "T50A16S", category_code: "T50", short_code: "A16S", full_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, sequela", short_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, sequela", category_name: "Underdosing of pertussis vaccine, including combinations with a pertussis component, sequela" } end def _T50A21A do %ICDCode{full_code: "T50A21A", category_code: "T50", short_code: "A21A", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), initial encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), initial encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), initial encounter" } end def _T50A21D do %ICDCode{full_code: "T50A21D", category_code: "T50", short_code: "A21D", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), subsequent encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), subsequent encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), subsequent encounter" } end def _T50A21S do %ICDCode{full_code: "T50A21S", category_code: "T50", short_code: "A21S", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), sequela", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), sequela", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, accidental (unintentional), sequela" } end def _T50A22A do %ICDCode{full_code: "T50A22A", category_code: "T50", short_code: "A22A", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, initial encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, initial encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, initial encounter" } end def _T50A22D do %ICDCode{full_code: "T50A22D", category_code: "T50", short_code: "A22D", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, subsequent encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, subsequent encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, subsequent encounter" } end def _T50A22S do %ICDCode{full_code: "T50A22S", category_code: "T50", short_code: "A22S", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, sequela", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, sequela", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, intentional self-harm, sequela" } end def _T50A23A do %ICDCode{full_code: "T50A23A", category_code: "T50", short_code: "A23A", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, initial encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, initial encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, initial encounter" } end def _T50A23D do %ICDCode{full_code: "T50A23D", category_code: "T50", short_code: "A23D", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, subsequent encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, subsequent encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, subsequent encounter" } end def _T50A23S do %ICDCode{full_code: "T50A23S", category_code: "T50", short_code: "A23S", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, sequela", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, sequela", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, assault, sequela" } end def _T50A24A do %ICDCode{full_code: "T50A24A", category_code: "T50", short_code: "A24A", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, initial encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, initial encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, initial encounter" } end def _T50A24D do %ICDCode{full_code: "T50A24D", category_code: "T50", short_code: "A24D", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, subsequent encounter", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, subsequent encounter", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, subsequent encounter" } end def _T50A24S do %ICDCode{full_code: "T50A24S", category_code: "T50", short_code: "A24S", full_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, sequela", short_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, sequela", category_name: "Poisoning by mixed bacterial vaccines without a pertussis component, undetermined, sequela" } end def _T50A25A do %ICDCode{full_code: "T50A25A", category_code: "T50", short_code: "A25A", full_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, initial encounter", short_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, initial encounter", category_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, initial encounter" } end def _T50A25D do %ICDCode{full_code: "T50A25D", category_code: "T50", short_code: "A25D", full_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, subsequent encounter", short_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, subsequent encounter", category_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, subsequent encounter" } end def _T50A25S do %ICDCode{full_code: "T50A25S", category_code: "T50", short_code: "A25S", full_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, sequela", short_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, sequela", category_name: "Adverse effect of mixed bacterial vaccines without a pertussis component, sequela" } end def _T50A26A do %ICDCode{full_code: "T50A26A", category_code: "T50", short_code: "A26A", full_name: "Underdosing of mixed bacterial vaccines without a pertussis component, initial encounter", short_name: "Underdosing of mixed bacterial vaccines without a pertussis component, initial encounter", category_name: "Underdosing of mixed bacterial vaccines without a pertussis component, initial encounter" } end def _T50A26D do %ICDCode{full_code: "T50A26D", category_code: "T50", short_code: "A26D", full_name: "Underdosing of mixed bacterial vaccines without a pertussis component, subsequent encounter", short_name: "Underdosing of mixed bacterial vaccines without a pertussis component, subsequent encounter", category_name: "Underdosing of mixed bacterial vaccines without a pertussis component, subsequent encounter" } end def _T50A26S do %ICDCode{full_code: "T50A26S", category_code: "T50", short_code: "A26S", full_name: "Underdosing of mixed bacterial vaccines without a pertussis component, sequela", short_name: "Underdosing of mixed bacterial vaccines without a pertussis component, sequela", category_name: "Underdosing of mixed bacterial vaccines without a pertussis component, sequela" } end def _T50A91A do %ICDCode{full_code: "T50A91A", category_code: "T50", short_code: "A91A", full_name: "Poisoning by other bacterial vaccines, accidental (unintentional), initial encounter", short_name: "Poisoning by other bacterial vaccines, accidental (unintentional), initial encounter", category_name: "Poisoning by other bacterial vaccines, accidental (unintentional), initial encounter" } end def _T50A91D do %ICDCode{full_code: "T50A91D", category_code: "T50", short_code: "A91D", full_name: "Poisoning by other bacterial vaccines, accidental (unintentional), subsequent encounter", short_name: "Poisoning by other bacterial vaccines, accidental (unintentional), subsequent encounter", category_name: "Poisoning by other bacterial vaccines, accidental (unintentional), subsequent encounter" } end def _T50A91S do %ICDCode{full_code: "T50A91S", category_code: "T50", short_code: "A91S", full_name: "Poisoning by other bacterial vaccines, accidental (unintentional), sequela", short_name: "Poisoning by other bacterial vaccines, accidental (unintentional), sequela", category_name: "Poisoning by other bacterial vaccines, accidental (unintentional), sequela" } end def _T50A92A do %ICDCode{full_code: "T50A92A", category_code: "T50", short_code: "A92A", full_name: "Poisoning by other bacterial vaccines, intentional self-harm, initial encounter", short_name: "Poisoning by other bacterial vaccines, intentional self-harm, initial encounter", category_name: "Poisoning by other bacterial vaccines, intentional self-harm, initial encounter" } end def _T50A92D do %ICDCode{full_code: "T50A92D", category_code: "T50", short_code: "A92D", full_name: "Poisoning by other bacterial vaccines, intentional self-harm, subsequent encounter", short_name: "Poisoning by other bacterial vaccines, intentional self-harm, subsequent encounter", category_name: "Poisoning by other bacterial vaccines, intentional self-harm, subsequent encounter" } end def _T50A92S do %ICDCode{full_code: "T50A92S", category_code: "T50", short_code: "A92S", full_name: "Poisoning by other bacterial vaccines, intentional self-harm, sequela", short_name: "Poisoning by other bacterial vaccines, intentional self-harm, sequela", category_name: "Poisoning by other bacterial vaccines, intentional self-harm, sequela" } end def _T50A93A do %ICDCode{full_code: "T50A93A", category_code: "T50", short_code: "A93A", full_name: "Poisoning by other bacterial vaccines, assault, initial encounter", short_name: "Poisoning by other bacterial vaccines, assault, initial encounter", category_name: "Poisoning by other bacterial vaccines, assault, initial encounter" } end def _T50A93D do %ICDCode{full_code: "T50A93D", category_code: "T50", short_code: "A93D", full_name: "Poisoning by other bacterial vaccines, assault, subsequent encounter", short_name: "Poisoning by other bacterial vaccines, assault, subsequent encounter", category_name: "Poisoning by other bacterial vaccines, assault, subsequent encounter" } end def _T50A93S do %ICDCode{full_code: "T50A93S", category_code: "T50", short_code: "A93S", full_name: "Poisoning by other bacterial vaccines, assault, sequela", short_name: "Poisoning by other bacterial vaccines, assault, sequela", category_name: "Poisoning by other bacterial vaccines, assault, sequela" } end def _T50A94A do %ICDCode{full_code: "T50A94A", category_code: "T50", short_code: "A94A", full_name: "Poisoning by other bacterial vaccines, undetermined, initial encounter", short_name: "Poisoning by other bacterial vaccines, undetermined, initial encounter", category_name: "Poisoning by other bacterial vaccines, undetermined, initial encounter" } end def _T50A94D do %ICDCode{full_code: "T50A94D", category_code: "T50", short_code: "A94D", full_name: "Poisoning by other bacterial vaccines, undetermined, subsequent encounter", short_name: "Poisoning by other bacterial vaccines, undetermined, subsequent encounter", category_name: "Poisoning by other bacterial vaccines, undetermined, subsequent encounter" } end def _T50A94S do %ICDCode{full_code: "T50A94S", category_code: "T50", short_code: "A94S", full_name: "Poisoning by other bacterial vaccines, undetermined, sequela", short_name: "Poisoning by other bacterial vaccines, undetermined, sequela", category_name: "Poisoning by other bacterial vaccines, undetermined, sequela" } end def _T50A95A do %ICDCode{full_code: "T50A95A", category_code: "T50", short_code: "A95A", full_name: "Adverse effect of other bacterial vaccines, initial encounter", short_name: "Adverse effect of other bacterial vaccines, initial encounter", category_name: "Adverse effect of other bacterial vaccines, initial encounter" } end def _T50A95D do %ICDCode{full_code: "T50A95D", category_code: "T50", short_code: "A95D", full_name: "Adverse effect of other bacterial vaccines, subsequent encounter", short_name: "Adverse effect of other bacterial vaccines, subsequent encounter", category_name: "Adverse effect of other bacterial vaccines, subsequent encounter" } end def _T50A95S do %ICDCode{full_code: "T50A95S", category_code: "T50", short_code: "A95S", full_name: "Adverse effect of other bacterial vaccines, sequela", short_name: "Adverse effect of other bacterial vaccines, sequela", category_name: "Adverse effect of other bacterial vaccines, sequela" } end def _T50A96A do %ICDCode{full_code: "T50A96A", category_code: "T50", short_code: "A96A", full_name: "Underdosing of other bacterial vaccines, initial encounter", short_name: "Underdosing of other bacterial vaccines, initial encounter", category_name: "Underdosing of other bacterial vaccines, initial encounter" } end def _T50A96D do %ICDCode{full_code: "T50A96D", category_code: "T50", short_code: "A96D", full_name: "Underdosing of other bacterial vaccines, subsequent encounter", short_name: "Underdosing of other bacterial vaccines, subsequent encounter", category_name: "Underdosing of other bacterial vaccines, subsequent encounter" } end def _T50A96S do %ICDCode{full_code: "T50A96S", category_code: "T50", short_code: "A96S", full_name: "Underdosing of other bacterial vaccines, sequela", short_name: "Underdosing of other bacterial vaccines, sequela", category_name: "Underdosing of other bacterial vaccines, sequela" } end def _T50B11A do %ICDCode{full_code: "T50B11A", category_code: "T50", short_code: "B11A", full_name: "Poisoning by smallpox vaccines, accidental (unintentional), initial encounter", short_name: "Poisoning by smallpox vaccines, accidental (unintentional), initial encounter", category_name: "Poisoning by smallpox vaccines, accidental (unintentional), initial encounter" } end def _T50B11D do %ICDCode{full_code: "T50B11D", category_code: "T50", short_code: "B11D", full_name: "Poisoning by smallpox vaccines, accidental (unintentional), subsequent encounter", short_name: "Poisoning by smallpox vaccines, accidental (unintentional), subsequent encounter", category_name: "Poisoning by smallpox vaccines, accidental (unintentional), subsequent encounter" } end def _T50B11S do %ICDCode{full_code: "T50B11S", category_code: "T50", short_code: "B11S", full_name: "Poisoning by smallpox vaccines, accidental (unintentional), sequela", short_name: "Poisoning by smallpox vaccines, accidental (unintentional), sequela", category_name: "Poisoning by smallpox vaccines, accidental (unintentional), sequela" } end def _T50B12A do %ICDCode{full_code: "T50B12A", category_code: "T50", short_code: "B12A", full_name: "Poisoning by smallpox vaccines, intentional self-harm, initial encounter", short_name: "Poisoning by smallpox vaccines, intentional self-harm, initial encounter", category_name: "Poisoning by smallpox vaccines, intentional self-harm, initial encounter" } end def _T50B12D do %ICDCode{full_code: "T50B12D", category_code: "T50", short_code: "B12D", full_name: "Poisoning by smallpox vaccines, intentional self-harm, subsequent encounter", short_name: "Poisoning by smallpox vaccines, intentional self-harm, subsequent encounter", category_name: "Poisoning by smallpox vaccines, intentional self-harm, subsequent encounter" } end def _T50B12S do %ICDCode{full_code: "T50B12S", category_code: "T50", short_code: "B12S", full_name: "Poisoning by smallpox vaccines, intentional self-harm, sequela", short_name: "Poisoning by smallpox vaccines, intentional self-harm, sequela", category_name: "Poisoning by smallpox vaccines, intentional self-harm, sequela" } end def _T50B13A do %ICDCode{full_code: "T50B13A", category_code: "T50", short_code: "B13A", full_name: "Poisoning by smallpox vaccines, assault, initial encounter", short_name: "Poisoning by smallpox vaccines, assault, initial encounter", category_name: "Poisoning by smallpox vaccines, assault, initial encounter" } end def _T50B13D do %ICDCode{full_code: "T50B13D", category_code: "T50", short_code: "B13D", full_name: "Poisoning by smallpox vaccines, assault, subsequent encounter", short_name: "Poisoning by smallpox vaccines, assault, subsequent encounter", category_name: "Poisoning by smallpox vaccines, assault, subsequent encounter" } end def _T50B13S do %ICDCode{full_code: "T50B13S", category_code: "T50", short_code: "B13S", full_name: "Poisoning by smallpox vaccines, assault, sequela", short_name: "Poisoning by smallpox vaccines, assault, sequela", category_name: "Poisoning by smallpox vaccines, assault, sequela" } end def _T50B14A do %ICDCode{full_code: "T50B14A", category_code: "T50", short_code: "B14A", full_name: "Poisoning by smallpox vaccines, undetermined, initial encounter", short_name: "Poisoning by smallpox vaccines, undetermined, initial encounter", category_name: "Poisoning by smallpox vaccines, undetermined, initial encounter" } end def _T50B14D do %ICDCode{full_code: "T50B14D", category_code: "T50", short_code: "B14D", full_name: "Poisoning by smallpox vaccines, undetermined, subsequent encounter", short_name: "Poisoning by smallpox vaccines, undetermined, subsequent encounter", category_name: "Poisoning by smallpox vaccines, undetermined, subsequent encounter" } end def _T50B14S do %ICDCode{full_code: "T50B14S", category_code: "T50", short_code: "B14S", full_name: "Poisoning by smallpox vaccines, undetermined, sequela", short_name: "Poisoning by smallpox vaccines, undetermined, sequela", category_name: "Poisoning by smallpox vaccines, undetermined, sequela" } end def _T50B15A do %ICDCode{full_code: "T50B15A", category_code: "T50", short_code: "B15A", full_name: "Adverse effect of smallpox vaccines, initial encounter", short_name: "Adverse effect of smallpox vaccines, initial encounter", category_name: "Adverse effect of smallpox vaccines, initial encounter" } end def _T50B15D do %ICDCode{full_code: "T50B15D", category_code: "T50", short_code: "B15D", full_name: "Adverse effect of smallpox vaccines, subsequent encounter", short_name: "Adverse effect of smallpox vaccines, subsequent encounter", category_name: "Adverse effect of smallpox vaccines, subsequent encounter" } end def _T50B15S do %ICDCode{full_code: "T50B15S", category_code: "T50", short_code: "B15S", full_name: "Adverse effect of smallpox vaccines, sequela", short_name: "Adverse effect of smallpox vaccines, sequela", category_name: "Adverse effect of smallpox vaccines, sequela" } end def _T50B16A do %ICDCode{full_code: "T50B16A", category_code: "T50", short_code: "B16A", full_name: "Underdosing of smallpox vaccines, initial encounter", short_name: "Underdosing of smallpox vaccines, initial encounter", category_name: "Underdosing of smallpox vaccines, initial encounter" } end def _T50B16D do %ICDCode{full_code: "T50B16D", category_code: "T50", short_code: "B16D", full_name: "Underdosing of smallpox vaccines, subsequent encounter", short_name: "Underdosing of smallpox vaccines, subsequent encounter", category_name: "Underdosing of smallpox vaccines, subsequent encounter" } end def _T50B16S do %ICDCode{full_code: "T50B16S", category_code: "T50", short_code: "B16S", full_name: "Underdosing of smallpox vaccines, sequela", short_name: "Underdosing of smallpox vaccines, sequela", category_name: "Underdosing of smallpox vaccines, sequela" } end def _T50B91A do %ICDCode{full_code: "T50B91A", category_code: "T50", short_code: "B91A", full_name: "Poisoning by other viral vaccines, accidental (unintentional), initial encounter", short_name: "Poisoning by other viral vaccines, accidental (unintentional), initial encounter", category_name: "Poisoning by other viral vaccines, accidental (unintentional), initial encounter" } end def _T50B91D do %ICDCode{full_code: "T50B91D", category_code: "T50", short_code: "B91D", full_name: "Poisoning by other viral vaccines, accidental (unintentional), subsequent encounter", short_name: "Poisoning by other viral vaccines, accidental (unintentional), subsequent encounter", category_name: "Poisoning by other viral vaccines, accidental (unintentional), subsequent encounter" } end def _T50B91S do %ICDCode{full_code: "T50B91S", category_code: "T50", short_code: "B91S", full_name: "Poisoning by other viral vaccines, accidental (unintentional), sequela", short_name: "Poisoning by other viral vaccines, accidental (unintentional), sequela", category_name: "Poisoning by other viral vaccines, accidental (unintentional), sequela" } end def _T50B92A do %ICDCode{full_code: "T50B92A", category_code: "T50", short_code: "B92A", full_name: "Poisoning by other viral vaccines, intentional self-harm, initial encounter", short_name: "Poisoning by other viral vaccines, intentional self-harm, initial encounter", category_name: "Poisoning by other viral vaccines, intentional self-harm, initial encounter" } end def _T50B92D do %ICDCode{full_code: "T50B92D", category_code: "T50", short_code: "B92D", full_name: "Poisoning by other viral vaccines, intentional self-harm, subsequent encounter", short_name: "Poisoning by other viral vaccines, intentional self-harm, subsequent encounter", category_name: "Poisoning by other viral vaccines, intentional self-harm, subsequent encounter" } end def _T50B92S do %ICDCode{full_code: "T50B92S", category_code: "T50", short_code: "B92S", full_name: "Poisoning by other viral vaccines, intentional self-harm, sequela", short_name: "Poisoning by other viral vaccines, intentional self-harm, sequela", category_name: "Poisoning by other viral vaccines, intentional self-harm, sequela" } end def _T50B93A do %ICDCode{full_code: "T50B93A", category_code: "T50", short_code: "B93A", full_name: "Poisoning by other viral vaccines, assault, initial encounter", short_name: "Poisoning by other viral vaccines, assault, initial encounter", category_name: "Poisoning by other viral vaccines, assault, initial encounter" } end def _T50B93D do %ICDCode{full_code: "T50B93D", category_code: "T50", short_code: "B93D", full_name: "Poisoning by other viral vaccines, assault, subsequent encounter", short_name: "Poisoning by other viral vaccines, assault, subsequent encounter", category_name: "Poisoning by other viral vaccines, assault, subsequent encounter" } end def _T50B93S do %ICDCode{full_code: "T50B93S", category_code: "T50", short_code: "B93S", full_name: "Poisoning by other viral vaccines, assault, sequela", short_name: "Poisoning by other viral vaccines, assault, sequela", category_name: "Poisoning by other viral vaccines, assault, sequela" } end def _T50B94A do %ICDCode{full_code: "T50B94A", category_code: "T50", short_code: "B94A", full_name: "Poisoning by other viral vaccines, undetermined, initial encounter", short_name: "Poisoning by other viral vaccines, undetermined, initial encounter", category_name: "Poisoning by other viral vaccines, undetermined, initial encounter" } end def _T50B94D do %ICDCode{full_code: "T50B94D", category_code: "T50", short_code: "B94D", full_name: "Poisoning by other viral vaccines, undetermined, subsequent encounter", short_name: "Poisoning by other viral vaccines, undetermined, subsequent encounter", category_name: "Poisoning by other viral vaccines, undetermined, subsequent encounter" } end def _T50B94S do %ICDCode{full_code: "T50B94S", category_code: "T50", short_code: "B94S", full_name: "Poisoning by other viral vaccines, undetermined, sequela", short_name: "Poisoning by other viral vaccines, undetermined, sequela", category_name: "Poisoning by other viral vaccines, undetermined, sequela" } end def _T50B95A do %ICDCode{full_code: "T50B95A", category_code: "T50", short_code: "B95A", full_name: "Adverse effect of other viral vaccines, initial encounter", short_name: "Adverse effect of other viral vaccines, initial encounter", category_name: "Adverse effect of other viral vaccines, initial encounter" } end def _T50B95D do %ICDCode{full_code: "T50B95D", category_code: "T50", short_code: "B95D", full_name: "Adverse effect of other viral vaccines, subsequent encounter", short_name: "Adverse effect of other viral vaccines, subsequent encounter", category_name: "Adverse effect of other viral vaccines, subsequent encounter" } end def _T50B95S do %ICDCode{full_code: "T50B95S", category_code: "T50", short_code: "B95S", full_name: "Adverse effect of other viral vaccines, sequela", short_name: "Adverse effect of other viral vaccines, sequela", category_name: "Adverse effect of other viral vaccines, sequela" } end def _T50B96A do %ICDCode{full_code: "T50B96A", category_code: "T50", short_code: "B96A", full_name: "Underdosing of other viral vaccines, initial encounter", short_name: "Underdosing of other viral vaccines, initial encounter", category_name: "Underdosing of other viral vaccines, initial encounter" } end def _T50B96D do %ICDCode{full_code: "T50B96D", category_code: "T50", short_code: "B96D", full_name: "Underdosing of other viral vaccines, subsequent encounter", short_name: "Underdosing of other viral vaccines, subsequent encounter", category_name: "Underdosing of other viral vaccines, subsequent encounter" } end def _T50B96S do %ICDCode{full_code: "T50B96S", category_code: "T50", short_code: "B96S", full_name: "Underdosing of other viral vaccines, sequela", short_name: "Underdosing of other viral vaccines, sequela", category_name: "Underdosing of other viral vaccines, sequela" } end def _T50Z11A do %ICDCode{full_code: "T50Z11A", category_code: "T50", short_code: "Z11A", full_name: "Poisoning by immunoglobulin, accidental (unintentional), initial encounter", short_name: "Poisoning by immunoglobulin, accidental (unintentional), initial encounter", category_name: "Poisoning by immunoglobulin, accidental (unintentional), initial encounter" } end def _T50Z11D do %ICDCode{full_code: "T50Z11D", category_code: "T50", short_code: "Z11D", full_name: "Poisoning by immunoglobulin, accidental (unintentional), subsequent encounter", short_name: "Poisoning by immunoglobulin, accidental (unintentional), subsequent encounter", category_name: "Poisoning by immunoglobulin, accidental (unintentional), subsequent encounter" } end def _T50Z11S do %ICDCode{full_code: "T50Z11S", category_code: "T50", short_code: "Z11S", full_name: "Poisoning by immunoglobulin, accidental (unintentional), sequela", short_name: "Poisoning by immunoglobulin, accidental (unintentional), sequela", category_name: "Poisoning by immunoglobulin, accidental (unintentional), sequela" } end def _T50Z12A do %ICDCode{full_code: "T50Z12A", category_code: "T50", short_code: "Z12A", full_name: "Poisoning by immunoglobulin, intentional self-harm, initial encounter", short_name: "Poisoning by immunoglobulin, intentional self-harm, initial encounter", category_name: "Poisoning by immunoglobulin, intentional self-harm, initial encounter" } end def _T50Z12D do %ICDCode{full_code: "T50Z12D", category_code: "T50", short_code: "Z12D", full_name: "Poisoning by immunoglobulin, intentional self-harm, subsequent encounter", short_name: "Poisoning by immunoglobulin, intentional self-harm, subsequent encounter", category_name: "Poisoning by immunoglobulin, intentional self-harm, subsequent encounter" } end def _T50Z12S do %ICDCode{full_code: "T50Z12S", category_code: "T50", short_code: "Z12S", full_name: "Poisoning by immunoglobulin, intentional self-harm, sequela", short_name: "Poisoning by immunoglobulin, intentional self-harm, sequela", category_name: "Poisoning by immunoglobulin, intentional self-harm, sequela" } end def _T50Z13A do %ICDCode{full_code: "T50Z13A", category_code: "T50", short_code: "Z13A", full_name: "Poisoning by immunoglobulin, assault, initial encounter", short_name: "Poisoning by immunoglobulin, assault, initial encounter", category_name: "Poisoning by immunoglobulin, assault, initial encounter" } end def _T50Z13D do %ICDCode{full_code: "T50Z13D", category_code: "T50", short_code: "Z13D", full_name: "Poisoning by immunoglobulin, assault, subsequent encounter", short_name: "Poisoning by immunoglobulin, assault, subsequent encounter", category_name: "Poisoning by immunoglobulin, assault, subsequent encounter" } end def _T50Z13S do %ICDCode{full_code: "T50Z13S", category_code: "T50", short_code: "Z13S", full_name: "Poisoning by immunoglobulin, assault, sequela", short_name: "Poisoning by immunoglobulin, assault, sequela", category_name: "Poisoning by immunoglobulin, assault, sequela" } end def _T50Z14A do %ICDCode{full_code: "T50Z14A", category_code: "T50", short_code: "Z14A", full_name: "Poisoning by immunoglobulin, undetermined, initial encounter", short_name: "Poisoning by immunoglobulin, undetermined, initial encounter", category_name: "Poisoning by immunoglobulin, undetermined, initial encounter" } end def _T50Z14D do %ICDCode{full_code: "T50Z14D", category_code: "T50", short_code: "Z14D", full_name: "Poisoning by immunoglobulin, undetermined, subsequent encounter", short_name: "Poisoning by immunoglobulin, undetermined, subsequent encounter", category_name: "Poisoning by immunoglobulin, undetermined, subsequent encounter" } end def _T50Z14S do %ICDCode{full_code: "T50Z14S", category_code: "T50", short_code: "Z14S", full_name: "Poisoning by immunoglobulin, undetermined, sequela", short_name: "Poisoning by immunoglobulin, undetermined, sequela", category_name: "Poisoning by immunoglobulin, undetermined, sequela" } end def _T50Z15A do %ICDCode{full_code: "T50Z15A", category_code: "T50", short_code: "Z15A", full_name: "Adverse effect of immunoglobulin, initial encounter", short_name: "Adverse effect of immunoglobulin, initial encounter", category_name: "Adverse effect of immunoglobulin, initial encounter" } end def _T50Z15D do %ICDCode{full_code: "T50Z15D", category_code: "T50", short_code: "Z15D", full_name: "Adverse effect of immunoglobulin, subsequent encounter", short_name: "Adverse effect of immunoglobulin, subsequent encounter", category_name: "Adverse effect of immunoglobulin, subsequent encounter" } end def _T50Z15S do %ICDCode{full_code: "T50Z15S", category_code: "T50", short_code: "Z15S", full_name: "Adverse effect of immunoglobulin, sequela", short_name: "Adverse effect of immunoglobulin, sequela", category_name: "Adverse effect of immunoglobulin, sequela" } end def _T50Z16A do %ICDCode{full_code: "T50Z16A", category_code: "T50", short_code: "Z16A", full_name: "Underdosing of immunoglobulin, initial encounter", short_name: "Underdosing of immunoglobulin, initial encounter", category_name: "Underdosing of immunoglobulin, initial encounter" } end def _T50Z16D do %ICDCode{full_code: "T50Z16D", category_code: "T50", short_code: "Z16D", full_name: "Underdosing of immunoglobulin, subsequent encounter", short_name: "Underdosing of immunoglobulin, subsequent encounter", category_name: "Underdosing of immunoglobulin, subsequent encounter" } end def _T50Z16S do %ICDCode{full_code: "T50Z16S", category_code: "T50", short_code: "Z16S", full_name: "Underdosing of immunoglobulin, sequela", short_name: "Underdosing of immunoglobulin, sequela", category_name: "Underdosing of immunoglobulin, sequela" } end def _T50Z91A do %ICDCode{full_code: "T50Z91A", category_code: "T50", short_code: "Z91A", full_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), initial encounter", short_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), initial encounter", category_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), initial encounter" } end def _T50Z91D do %ICDCode{full_code: "T50Z91D", category_code: "T50", short_code: "Z91D", full_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), subsequent encounter", short_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), subsequent encounter", category_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), subsequent encounter" } end def _T50Z91S do %ICDCode{full_code: "T50Z91S", category_code: "T50", short_code: "Z91S", full_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), sequela", short_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), sequela", category_name: "Poisoning by other vaccines and biological substances, accidental (unintentional), sequela" } end def _T50Z92A do %ICDCode{full_code: "T50Z92A", category_code: "T50", short_code: "Z92A", full_name: "Poisoning by other vaccines and biological substances, intentional self-harm, initial encounter", short_name: "Poisoning by other vaccines and biological substances, intentional self-harm, initial encounter", category_name: "Poisoning by other vaccines and biological substances, intentional self-harm, initial encounter" } end def _T50Z92D do %ICDCode{full_code: "T50Z92D", category_code: "T50", short_code: "Z92D", full_name: "Poisoning by other vaccines and biological substances, intentional self-harm, subsequent encounter", short_name: "Poisoning by other vaccines and biological substances, intentional self-harm, subsequent encounter", category_name: "Poisoning by other vaccines and biological substances, intentional self-harm, subsequent encounter" } end def _T50Z92S do %ICDCode{full_code: "T50Z92S", category_code: "T50", short_code: "Z92S", full_name: "Poisoning by other vaccines and biological substances, intentional self-harm, sequela", short_name: "Poisoning by other vaccines and biological substances, intentional self-harm, sequela", category_name: "Poisoning by other vaccines and biological substances, intentional self-harm, sequela" } end def _T50Z93A do %ICDCode{full_code: "T50Z93A", category_code: "T50", short_code: "Z93A", full_name: "Poisoning by other vaccines and biological substances, assault, initial encounter", short_name: "Poisoning by other vaccines and biological substances, assault, initial encounter", category_name: "Poisoning by other vaccines and biological substances, assault, initial encounter" } end def _T50Z93D do %ICDCode{full_code: "T50Z93D", category_code: "T50", short_code: "Z93D", full_name: "Poisoning by other vaccines and biological substances, assault, subsequent encounter", short_name: "Poisoning by other vaccines and biological substances, assault, subsequent encounter", category_name: "Poisoning by other vaccines and biological substances, assault, subsequent encounter" } end def _T50Z93S do %ICDCode{full_code: "T50Z93S", category_code: "T50", short_code: "Z93S", full_name: "Poisoning by other vaccines and biological substances, assault, sequela", short_name: "Poisoning by other vaccines and biological substances, assault, sequela", category_name: "Poisoning by other vaccines and biological substances, assault, sequela" } end def _T50Z94A do %ICDCode{full_code: "T50Z94A", category_code: "T50", short_code: "Z94A", full_name: "Poisoning by other vaccines and biological substances, undetermined, initial encounter", short_name: "Poisoning by other vaccines and biological substances, undetermined, initial encounter", category_name: "Poisoning by other vaccines and biological substances, undetermined, initial encounter" } end def _T50Z94D do %ICDCode{full_code: "T50Z94D", category_code: "T50", short_code: "Z94D", full_name: "Poisoning by other vaccines and biological substances, undetermined, subsequent encounter", short_name: "Poisoning by other vaccines and biological substances, undetermined, subsequent encounter", category_name: "Poisoning by other vaccines and biological substances, undetermined, subsequent encounter" } end def _T50Z94S do %ICDCode{full_code: "T50Z94S", category_code: "T50", short_code: "Z94S", full_name: "Poisoning by other vaccines and biological substances, undetermined, sequela", short_name: "Poisoning by other vaccines and biological substances, undetermined, sequela", category_name: "Poisoning by other vaccines and biological substances, undetermined, sequela" } end def _T50Z95A do %ICDCode{full_code: "T50Z95A", category_code: "T50", short_code: "Z95A", full_name: "Adverse effect of other vaccines and biological substances, initial encounter", short_name: "Adverse effect of other vaccines and biological substances, initial encounter", category_name: "Adverse effect of other vaccines and biological substances, initial encounter" } end def _T50Z95D do %ICDCode{full_code: "T50Z95D", category_code: "T50", short_code: "Z95D", full_name: "Adverse effect of other vaccines and biological substances, subsequent encounter", short_name: "Adverse effect of other vaccines and biological substances, subsequent encounter", category_name: "Adverse effect of other vaccines and biological substances, subsequent encounter" } end def _T50Z95S do %ICDCode{full_code: "T50Z95S", category_code: "T50", short_code: "Z95S", full_name: "Adverse effect of other vaccines and biological substances, sequela", short_name: "Adverse effect of other vaccines and biological substances, sequela", category_name: "Adverse effect of other vaccines and biological substances, sequela" } end def _T50Z96A do %ICDCode{full_code: "T50Z96A", category_code: "T50", short_code: "Z96A", full_name: "Underdosing of other vaccines and biological substances, initial encounter", short_name: "Underdosing of other vaccines and biological substances, initial encounter", category_name: "Underdosing of other vaccines and biological substances, initial encounter" } end def _T50Z96D do %ICDCode{full_code: "T50Z96D", category_code: "T50", short_code: "Z96D", full_name: "Underdosing of other vaccines and biological substances, subsequent encounter", short_name: "Underdosing of other vaccines and biological substances, subsequent encounter", category_name: "Underdosing of other vaccines and biological substances, subsequent encounter" } end def _T50Z96S do %ICDCode{full_code: "T50Z96S", category_code: "T50", short_code: "Z96S", full_name: "Underdosing of other vaccines and biological substances, sequela", short_name: "Underdosing of other vaccines and biological substances, sequela", category_name: "Underdosing of other vaccines and biological substances, sequela" } end def _T50901A do %ICDCode{full_code: "T50901A", category_code: "T50", short_code: "901A", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), initial encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), initial encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), initial encounter" } end def _T50901D do %ICDCode{full_code: "T50901D", category_code: "T50", short_code: "901D", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter" } end def _T50901S do %ICDCode{full_code: "T50901S", category_code: "T50", short_code: "901S", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), sequela", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), sequela", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, accidental (unintentional), sequela" } end def _T50902A do %ICDCode{full_code: "T50902A", category_code: "T50", short_code: "902A", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, initial encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, initial encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, initial encounter" } end def _T50902D do %ICDCode{full_code: "T50902D", category_code: "T50", short_code: "902D", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, subsequent encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, subsequent encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, subsequent encounter" } end def _T50902S do %ICDCode{full_code: "T50902S", category_code: "T50", short_code: "902S", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, sequela", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, sequela", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, intentional self-harm, sequela" } end def _T50903A do %ICDCode{full_code: "T50903A", category_code: "T50", short_code: "903A", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, initial encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, initial encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, initial encounter" } end def _T50903D do %ICDCode{full_code: "T50903D", category_code: "T50", short_code: "903D", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, subsequent encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, subsequent encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, subsequent encounter" } end def _T50903S do %ICDCode{full_code: "T50903S", category_code: "T50", short_code: "903S", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, sequela", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, sequela", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, assault, sequela" } end def _T50904A do %ICDCode{full_code: "T50904A", category_code: "T50", short_code: "904A", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, initial encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, initial encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, initial encounter" } end def _T50904D do %ICDCode{full_code: "T50904D", category_code: "T50", short_code: "904D", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, subsequent encounter", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, subsequent encounter", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, subsequent encounter" } end def _T50904S do %ICDCode{full_code: "T50904S", category_code: "T50", short_code: "904S", full_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, sequela", short_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, sequela", category_name: "Poisoning by unspecified drugs, medicaments and biological substances, undetermined, sequela" } end def _T50905A do %ICDCode{full_code: "T50905A", category_code: "T50", short_code: "905A", full_name: "Adverse effect of unspecified drugs, medicaments and biological substances, initial encounter", short_name: "Adverse effect of unspecified drugs, medicaments and biological substances, initial encounter", category_name: "Adverse effect of unspecified drugs, medicaments and biological substances, initial encounter" } end def _T50905D do %ICDCode{full_code: "T50905D", category_code: "T50", short_code: "905D", full_name: "Adverse effect of unspecified drugs, medicaments and biological substances, subsequent encounter", short_name: "Adverse effect of unspecified drugs, medicaments and biological substances, subsequent encounter", category_name: "Adverse effect of unspecified drugs, medicaments and biological substances, subsequent encounter" } end def _T50905S do %ICDCode{full_code: "T50905S", category_code: "T50", short_code: "905S", full_name: "Adverse effect of unspecified drugs, medicaments and biological substances, sequela", short_name: "Adverse effect of unspecified drugs, medicaments and biological substances, sequela", category_name: "Adverse effect of unspecified drugs, medicaments and biological substances, sequela" } end def _T50906A do %ICDCode{full_code: "T50906A", category_code: "T50", short_code: "906A", full_name: "Underdosing of unspecified drugs, medicaments and biological substances, initial encounter", short_name: "Underdosing of unspecified drugs, medicaments and biological substances, initial encounter", category_name: "Underdosing of unspecified drugs, medicaments and biological substances, initial encounter" } end def _T50906D do %ICDCode{full_code: "T50906D", category_code: "T50", short_code: "906D", full_name: "Underdosing of unspecified drugs, medicaments and biological substances, subsequent encounter", short_name: "Underdosing of unspecified drugs, medicaments and biological substances, subsequent encounter", category_name: "Underdosing of unspecified drugs, medicaments and biological substances, subsequent encounter" } end def _T50906S do %ICDCode{full_code: "T50906S", category_code: "T50", short_code: "906S", full_name: "Underdosing of unspecified drugs, medicaments and biological substances, sequela", short_name: "Underdosing of unspecified drugs, medicaments and biological substances, sequela", category_name: "Underdosing of unspecified drugs, medicaments and biological substances, sequela" } end def _T50991A do %ICDCode{full_code: "T50991A", category_code: "T50", short_code: "991A", full_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), initial encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), initial encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), initial encounter" } end def _T50991D do %ICDCode{full_code: "T50991D", category_code: "T50", short_code: "991D", full_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), subsequent encounter" } end def _T50991S do %ICDCode{full_code: "T50991S", category_code: "T50", short_code: "991S", full_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), sequela", short_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), sequela", category_name: "Poisoning by other drugs, medicaments and biological substances, accidental (unintentional), sequela" } end def _T50992A do %ICDCode{full_code: "T50992A", category_code: "T50", short_code: "992A", full_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, initial encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, initial encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, initial encounter" } end def _T50992D do %ICDCode{full_code: "T50992D", category_code: "T50", short_code: "992D", full_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, subsequent encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, subsequent encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, subsequent encounter" } end def _T50992S do %ICDCode{full_code: "T50992S", category_code: "T50", short_code: "992S", full_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, sequela", short_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, sequela", category_name: "Poisoning by other drugs, medicaments and biological substances, intentional self-harm, sequela" } end def _T50993A do %ICDCode{full_code: "T50993A", category_code: "T50", short_code: "993A", full_name: "Poisoning by other drugs, medicaments and biological substances, assault, initial encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, assault, initial encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, assault, initial encounter" } end def _T50993D do %ICDCode{full_code: "T50993D", category_code: "T50", short_code: "993D", full_name: "Poisoning by other drugs, medicaments and biological substances, assault, subsequent encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, assault, subsequent encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, assault, subsequent encounter" } end def _T50993S do %ICDCode{full_code: "T50993S", category_code: "T50", short_code: "993S", full_name: "Poisoning by other drugs, medicaments and biological substances, assault, sequela", short_name: "Poisoning by other drugs, medicaments and biological substances, assault, sequela", category_name: "Poisoning by other drugs, medicaments and biological substances, assault, sequela" } end def _T50994A do %ICDCode{full_code: "T50994A", category_code: "T50", short_code: "994A", full_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, initial encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, initial encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, initial encounter" } end def _T50994D do %ICDCode{full_code: "T50994D", category_code: "T50", short_code: "994D", full_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, subsequent encounter", short_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, subsequent encounter", category_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, subsequent encounter" } end def _T50994S do %ICDCode{full_code: "T50994S", category_code: "T50", short_code: "994S", full_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, sequela", short_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, sequela", category_name: "Poisoning by other drugs, medicaments and biological substances, undetermined, sequela" } end def _T50995A do %ICDCode{full_code: "T50995A", category_code: "T50", short_code: "995A", full_name: "Adverse effect of other drugs, medicaments and biological substances, initial encounter", short_name: "Adverse effect of other drugs, medicaments and biological substances, initial encounter", category_name: "Adverse effect of other drugs, medicaments and biological substances, initial encounter" } end def _T50995D do %ICDCode{full_code: "T50995D", category_code: "T50", short_code: "995D", full_name: "Adverse effect of other drugs, medicaments and biological substances, subsequent encounter", short_name: "Adverse effect of other drugs, medicaments and biological substances, subsequent encounter", category_name: "Adverse effect of other drugs, medicaments and biological substances, subsequent encounter" } end def _T50995S do %ICDCode{full_code: "T50995S", category_code: "T50", short_code: "995S", full_name: "Adverse effect of other drugs, medicaments and biological substances, sequela", short_name: "Adverse effect of other drugs, medicaments and biological substances, sequela", category_name: "Adverse effect of other drugs, medicaments and biological substances, sequela" } end def _T50996A do %ICDCode{full_code: "T50996A", category_code: "T50", short_code: "996A", full_name: "Underdosing of other drugs, medicaments and biological substances, initial encounter", short_name: "Underdosing of other drugs, medicaments and biological substances, initial encounter", category_name: "Underdosing of other drugs, medicaments and biological substances, initial encounter" } end def _T50996D do %ICDCode{full_code: "T50996D", category_code: "T50", short_code: "996D", full_name: "Underdosing of other drugs, medicaments and biological substances, subsequent encounter", short_name: "Underdosing of other drugs, medicaments and biological substances, subsequent encounter", category_name: "Underdosing of other drugs, medicaments and biological substances, subsequent encounter" } end def _T50996S do %ICDCode{full_code: "T50996S", category_code: "T50", short_code: "996S", full_name: "Underdosing of other drugs, medicaments and biological substances, sequela", short_name: "Underdosing of other drugs, medicaments and biological substances, sequela", category_name: "Underdosing of other drugs, medicaments and biological substances, sequela" } end end
49.940814
158
0.688067
73f3063f26513059d26733ee98fe0864555f3e71
1,212
exs
Elixir
Intermediate/behaviors_and_callbacks.exs
joelbandi/elixir-start-here
65722377d455a4b4678658eee56713681c6f16ce
[ "MIT" ]
null
null
null
Intermediate/behaviors_and_callbacks.exs
joelbandi/elixir-start-here
65722377d455a4b4678658eee56713681c6f16ce
[ "MIT" ]
null
null
null
Intermediate/behaviors_and_callbacks.exs
joelbandi/elixir-start-here
65722377d455a4b4678658eee56713681c6f16ce
[ "MIT" ]
null
null
null
# behaviours and callbacks are a way to standardize and enforce a consistent public user facing API if required. # in Java this is achieved using interfaces. # Many libraries like plug use behaviours to enforce a common api people can use # Lets create a behaviour module defmodule Parser do @callback parse(String.t)::{:ok, term} | {:error, String.t} @callback extensions()::[atom()] end defmodule JSONParser do @behaviour Parser def parse(str), do: {:ok, "some json" <> str} def extensions(), do: [:json] end defmodule SVParser do @behaviour Parser def parse(str), do: {:ok, "some sv" <>str} def extensions(), do: [:csv, :tsv] end defmodule YAMLParser do @behaviour Parser def parse(str), do: {:ok, "some yaml" <> str} def extensions(), do: [:yaml] end # if one of the methods defined by the behaviour module is not defined, # by a module using it, a compile error will be thrown defmodule SillyParser do @behaviour Parser def parse(_str), do: {:ok, "silly Parser I am"} end # warning: function extensions/0 required by behaviour Parser is not implemented (in module SillyParser) # /Users/appfolio/Devspace/elixir-start-here/Intermediate/behaviors_and_callbacks.exs:39
26.347826
112
0.723597
73f331fe8a4f46772e0a9a6c3a29d9c574e6b5ff
1,548
exs
Elixir
mix.exs
GmateApp/server
48e73e6331c2f880754c22ab08b8476cb4a1a528
[ "Apache-2.0" ]
null
null
null
mix.exs
GmateApp/server
48e73e6331c2f880754c22ab08b8476cb4a1a528
[ "Apache-2.0" ]
null
null
null
mix.exs
GmateApp/server
48e73e6331c2f880754c22ab08b8476cb4a1a528
[ "Apache-2.0" ]
null
null
null
defmodule Gm8.Mixfile do use Mix.Project def project do [ app: :gm8, version: "0.0.1", elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps() ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {Gm8.Application, []}, extra_applications: [:logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.3.2"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.2"}, {:postgrex, ">= 0.0.0"}, {:gettext, "~> 0.11"}, {:cowboy, "~> 1.0"}, {:httpoison, "~> 1.0"}, {:inflex, "~> 1.10.0"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to create, migrate and run the seeds file at once: # # $ mix ecto.setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], "test": ["ecto.create --quiet", "ecto.migrate", "test"] ] end end
25.377049
79
0.576227
73f34629038c86ae85f39f1e9e9a4461e60556f2
4,303
ex
Elixir
deps/ecto_sql/lib/mix/tasks/ecto.rollback.ex
matin360/TaksoWebApp
4dd8fef625ecc2364fe1d6e18e73c96c59d15349
[ "MIT" ]
null
null
null
deps/ecto_sql/lib/mix/tasks/ecto.rollback.ex
matin360/TaksoWebApp
4dd8fef625ecc2364fe1d6e18e73c96c59d15349
[ "MIT" ]
null
null
null
deps/ecto_sql/lib/mix/tasks/ecto.rollback.ex
matin360/TaksoWebApp
4dd8fef625ecc2364fe1d6e18e73c96c59d15349
[ "MIT" ]
null
null
null
defmodule Mix.Tasks.Ecto.Rollback do use Mix.Task import Mix.Ecto import Mix.EctoSQL @shortdoc "Rolls back the repository migrations" @aliases [ r: :repo, n: :step ] @switches [ all: :boolean, step: :integer, to: :integer, quiet: :boolean, prefix: :string, pool_size: :integer, log_sql: :boolean, repo: [:keep, :string], no_compile: :boolean, no_deps_check: :boolean, migrations_path: :keep ] @moduledoc """ Reverts applied migrations in the given repository. Migrations are expected at "priv/YOUR_REPO/migrations" directory of the current application, where "YOUR_REPO" is the last segment in your repository name. For example, the repository `MyApp.Repo` will use "priv/repo/migrations". The repository `Whatever.MyRepo` will use "priv/my_repo/migrations". You can configure a repository to use another directory by specifying the `:priv` key under the repository configuration. The "migrations" part will be automatically appended to it. For instance, to use "priv/custom_repo/migrations": config :my_app, MyApp.Repo, priv: "priv/custom_repo" This task rolls back the last applied migration by default. To roll back to a version number, supply `--to version_number`. To roll back a specific number of times, use `--step n`. To undo all applied migrations, provide `--all`. The repositories to rollback are the ones specified under the `:ecto_repos` option in the current app configuration. However, if the `-r` option is given, it replaces the `:ecto_repos` config. If a repository has not yet been started, one will be started outside your application supervision tree and shutdown afterwards. ## Examples $ mix ecto.rollback $ mix ecto.rollback -r Custom.Repo $ mix ecto.rollback -n 3 $ mix ecto.rollback --step 3 $ mix ecto.rollback --to 20080906120000 ## Command line options * `-r`, `--repo` - the repo to rollback * `--all` - revert all applied migrations * `--step`, `-n` - revert n number of applied migrations * `--to` - revert all migrations down to and including version * `--quiet` - do not log migration commands * `--prefix` - the prefix to run migrations on * `--pool-size` - the pool size if the repository is started only for the task (defaults to 2) * `--log-sql` - log the raw sql migrations are running * `--no-compile` - does not compile applications before rolling back * `--no-deps-check` - does not check dependencies before rolling back * `--migrations-path` - the path to load the migrations from, defaults to `"priv/repo/migrations"`. This option may be given multiple times in which case the migrations are loaded from all the given directories and sorted as if they were all in the same one. Note, if you have migrations paths e.g. `a/` and `b/`, and run `mix ecto.rollback --migrations-path a/`, only the latest migrations from `a/` will be rolled back (even if `b/` contains the overall latest migrations.) """ @impl true def run(args, migrator \\ &Ecto.Migrator.run/4) do repos = parse_repo(args) {opts, _} = OptionParser.parse! args, strict: @switches, aliases: @aliases opts = if opts[:to] || opts[:step] || opts[:all], do: opts, else: Keyword.put(opts, :step, 1) opts = if opts[:quiet], do: Keyword.merge(opts, [log: false, log_sql: false]), else: opts # Start ecto_sql explicitly before as we don't need # to restart those apps if migrated. {:ok, _} = Application.ensure_all_started(:ecto_sql) for repo <- repos do ensure_repo(repo, args) paths = ensure_migrations_paths(repo, opts) pool = repo.config[:pool] fun = if Code.ensure_loaded?(pool) and function_exported?(pool, :unboxed_run, 2) do &pool.unboxed_run(&1, fn -> migrator.(&1, paths, :down, opts) end) else &migrator.(&1, paths, :down, opts) end case Ecto.Migrator.with_repo(repo, fun, [mode: :temporary] ++ opts) do {:ok, _migrated, _apps} -> :ok {:error, error} -> Mix.raise "Could not start repo #{inspect repo}, error: #{inspect error}" end end :ok end end
31.639706
100
0.662561
73f383737cace887cc5a59654ceaef1ef630d70f
8,340
ex
Elixir
lib/kinesis_client/stream/coordinator.ex
knocklabs/kcl_ex
d032744cb037cea351af1fad826923253bced2b4
[ "Apache-2.0" ]
null
null
null
lib/kinesis_client/stream/coordinator.ex
knocklabs/kcl_ex
d032744cb037cea351af1fad826923253bced2b4
[ "Apache-2.0" ]
null
null
null
lib/kinesis_client/stream/coordinator.ex
knocklabs/kcl_ex
d032744cb037cea351af1fad826923253bced2b4
[ "Apache-2.0" ]
null
null
null
defmodule KinesisClient.Stream.Coordinator do @moduledoc """ This module will describe a given stream and enumerate all the shards. It will then handle starting and stopping `KinesisClient.Stream.Shard` processes as necessary to ensure the stream is processed completely and in the correct order. """ use GenServer require Logger alias KinesisClient.Kinesis alias KinesisClient.Stream.Shard alias KinesisClient.Stream.AppState defstruct [ :name, :app_name, :app_state_opts, :stream_name, :shard_supervisor_name, :notify_pid, :shard_graph, :shard_map, :kinesis_opts, :retry_timeout, # unique reference used to identify this instance KinesisClient.Stream :worker_ref, :shard_args, shard_ref_map: %{} ] @doc """ Starts a KinesisClient.Stream.Coordinator. KinesisClient.Stream should handle starting this. ## Options * `:name` - Required. The process name. * `:app_name` - Required. Will be used to name the DyanmoDB table. * `:stream_name` - Required. The stream to describe and start Shard workers for. * `:shard_supervisor_name` - Required. Needed in order to start Shard workers. """ def start_link(args) do GenServer.start_link(__MODULE__, args, name: args[:name]) end def close_shard(coordinator, shard_id) do GenServer.cast(coordinator, {:close_shard, shard_id}) end @impl GenServer def init(opts) do state = %__MODULE__{ name: opts[:name], app_name: opts[:app_name], app_state_opts: opts[:app_state_opts], stream_name: opts[:stream_name], shard_supervisor_name: opts[:shard_supervisor_name], worker_ref: opts[:worker_ref], shard_args: opts[:shard_args], notify_pid: Keyword.get(opts, :notify_pid), kinesis_opts: Keyword.get(opts, :kinesis_opts, []), retry_timeout: Keyword.get(opts, :retry_timeout, 30_000) } Logger.debug("Starting KinesisClient.Stream.Coordinates: #{inspect(state)}") {:ok, state, {:continue, :initialize}} end @impl GenServer def handle_continue(:initialize, state) do create_table_if_not_exists(state) describe_stream(state) end def handle_continue(:describe_stream, state) do describe_stream(state) end @impl GenServer def handle_call(:get_graph, _from, %{shard_graph: graph} = s) do {:reply, graph, s} end @impl GenServer def handle_cast( {:close_shard, shard_id}, %{shard_ref_map: shards, stream_name: sn, app_name: app_name} = state ) do {ref, _} = Enum.find(shards, fn {_monitor_ref, in_shard_id} -> in_shard_id == shard_id end) Process.demonitor(ref, :flush) Shard.stop(Shard.name(app_name, sn, shard_id)) {:noreply, state} end def create_table_if_not_exists(state) do AppState.initialize(state.app_name, state.app_state_opts) end defp describe_stream(state) do %{"StreamStatus" => status, "Shards" => shards} = get_shards(state.stream_name, state.kinesis_opts) notify({:shards, shards}, state) case status do "ACTIVE" -> shard_graph = build_shard_graph(shards) shard_map = Enum.reduce(shards, %{}, fn %{"ShardId" => shard_id} = s, acc -> Map.put(acc, shard_id, s) end) state = %{state | shard_map: shard_map} map = start_shards(shard_graph, state) {:noreply, %{state | shard_graph: shard_graph, shard_ref_map: map}} other -> Logger.info("Stream is not in active state, sleeping... Stream state: #{inspect(other)}") :timer.sleep(state.retry_timeout) notify({:retrying_describe_stream, self()}, state) {:noreply, state, {:continue, :describe_stream}} end end defp build_shard_graph(shard_list) do graph = :digraph.new([:acyclic]) Enum.each(shard_list, fn %{"ShardId" => shard_id} = s -> unless :digraph.vertex(graph, shard_id) do :digraph.add_vertex(graph, shard_id) end case s do %{"ParentShardId" => parent_shard_id} when not is_nil(parent_shard_id) -> add_vertex(graph, parent_shard_id) :digraph.add_edge(graph, parent_shard_id, shard_id, "parent-child") case s["AdjacentParentShardId"] do nil -> :ok x when is_binary(x) -> add_vertex(graph, x) :digraph.add_edge(graph, x, shard_id) end _ -> :ok end end) graph end defp start_shards(shard_graph, %__MODULE__{} = state) do shard_r = list_relationships(shard_graph) Enum.reduce(shard_r, state.shard_ref_map, fn {shard_id, parents}, acc -> shard_lease = get_lease(shard_id, state) case parents do [] -> case shard_lease do %{completed: true} -> acc _ -> case start_shard(shard_id, state) do {:ok, pid} -> Map.put(acc, Process.monitor(pid), shard_id) end end # handle shard splits [single_parent] -> case get_lease(single_parent, state) do %{completed: true} -> Logger.info("Parent shard #{single_parent} is completed so starting #{shard_id}") case start_shard(shard_id, state) do {:ok, pid} -> Map.put(acc, Process.monitor(pid), shard_id) end %{completed: false} -> Logger.info("Parent shard #{single_parent} is not completed so skipping #{shard_id}") acc end # handle shard merges [parent1, parent2] -> case {get_lease(parent1, state), get_lease(parent2, state)} do {%{completed: true}, %{completed: true}} -> case start_shard(shard_id, state) do {:ok, pid} -> Map.put(acc, Process.monitor(pid), shard_id) end _ -> acc end end end) end defp get_lease(shard_id, %{app_name: app_name, app_state_opts: app_state_opts}) do AppState.get_lease(app_name, shard_id, app_state_opts) end # Start a shard and return an updated worker map with the %{lease_ref => pid} @spec start_shard( shard_id :: String.t(), state :: map ) :: {:ok, pid} defp start_shard( shard_id, %{shard_supervisor_name: shard_supervisor, shard_args: shard_args} = state ) do shard_args = shard_args |> Keyword.put(:shard_id, shard_id) |> Keyword.put( :shard_name, Shard.name(state.app_name, state.stream_name, shard_id) ) {:ok, pid} = Shard.start(shard_supervisor, shard_args) notify({:shard_started, %{pid: pid, shard_id: shard_id}}, state) {:ok, pid} end ## # Returns a list of shape [{shard_id, [parent_shards]}]. The list is sorted from low to high on the # parent links list. defp list_relationships(graph) do n = graph |> :digraph.vertices() |> Enum.map(fn v -> {v, :digraph.in_neighbours(graph, v)} end) Enum.sort(n, fn {_, n1}, {_, n2} -> length(n1) <= length(n2) end) end defp get_shards(stream_name, kinesis_opts, shard_start_id \\ nil, shard_list \\ []) do {:ok, result} = case shard_start_id do nil -> Kinesis.describe_stream(stream_name, kinesis_opts) x when is_binary(x) -> Kinesis.describe_stream( stream_name, Keyword.merge(kinesis_opts, exclusive_start_shard_id: x) ) end case result do %{"StreamDescription" => %{"HasMoreShards" => true, "Shards" => shards}} -> get_shards( stream_name, kinesis_opts, hd(Enum.reverse(shards))["ShardId"], shards ++ shard_list ) %{"StreamDescription" => %{"HasMoreShards" => false, "Shards" => shards} = stream} -> stream |> Map.put("Shards", shards ++ shard_list) end end defp add_vertex(graph, shard_id) do case :digraph.vertex(graph, shard_id) do false -> :digraph.add_vertex(graph, shard_id) _ -> nil end end defp notify(message, %__MODULE__{notify_pid: notify_pid}) do case notify_pid do pid when is_pid(pid) -> send(pid, message) :ok nil -> :ok end end end
28.758621
101
0.616906
73f39e4bd634130af6b3bfe68fcccc071ac6a8d3
391
exs
Elixir
test/regressions/i050_lists_with_code_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
null
null
null
test/regressions/i050_lists_with_code_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
null
null
null
test/regressions/i050_lists_with_code_test.exs
ZeLarpMaster/earmark
35c9661d6647059e507c0278347e21d92351c417
[ "Apache-1.1" ]
1
2020-03-31T19:53:15.000Z
2020-03-31T19:53:15.000Z
defmodule Regressions.I050ListsWithCodeTest do use ExUnit.Case, async: true @i50_inline_code_in_list_item """ + ```escape``` """ test "https://github.com/pragdave/earmark/issues/50" do result = Earmark.as_html! @i50_inline_code_in_list_item assert result == ~s[<ul>\n<li><code class="inline">escape</code>\n</li>\n</ul>\n] end end # SPDX-License-Identifier: Apache-2.0
27.928571
85
0.703325
73f39f77799e0dc68833e64b224f1588fe914f10
1,965
ex
Elixir
clients/dfa_reporting/lib/google_api/dfa_reporting/v28/model/placements_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/dfa_reporting/lib/google_api/dfa_reporting/v28/model/placements_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/dfa_reporting/lib/google_api/dfa_reporting/v28/model/placements_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # 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 &quot;AS IS&quot; 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. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.DFAReporting.V28.Model.PlacementsListResponse do @moduledoc """ Placement List Response ## Attributes - kind (String.t): Identifies what kind of resource this is. Value: the fixed string \&quot;dfareporting#placementsListResponse\&quot;. Defaults to: `null`. - nextPageToken (String.t): Pagination token to be used for the next list operation. Defaults to: `null`. - placements ([Placement]): Placement collection. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :kind => any(), :nextPageToken => any(), :placements => list(GoogleApi.DFAReporting.V28.Model.Placement.t()) } field(:kind) field(:nextPageToken) field(:placements, as: GoogleApi.DFAReporting.V28.Model.Placement, type: :list) end defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V28.Model.PlacementsListResponse do def decode(value, options) do GoogleApi.DFAReporting.V28.Model.PlacementsListResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V28.Model.PlacementsListResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.388889
158
0.743003
73f3da4519303d98ac480630783be0000c88dc8d
2,000
ex
Elixir
lib/Base/QueuingSystems/queue.ex
ServusGameServer/Servus_Protobuf
cb870b7dccb6676e71045e231fd31547d63efa74
[ "Apache-2.0" ]
2
2018-10-19T06:14:08.000Z
2018-11-23T00:56:09.000Z
lib/Base/QueuingSystems/queue.ex
ServusGameServer/Servus_Protobuf
cb870b7dccb6676e71045e231fd31547d63efa74
[ "Apache-2.0" ]
null
null
null
lib/Base/QueuingSystems/queue.ex
ServusGameServer/Servus_Protobuf
cb870b7dccb6676e71045e231fd31547d63efa74
[ "Apache-2.0" ]
null
null
null
defmodule Servus.PlayerQueue do use GenServer require Logger alias Servus.PidStore alias Servus.Serverutils @doc """ Start a new player queue for a backend of type `logic` allowing `players_per_game` players. """ def start_link(players_per_game, logic, queueName) do {:ok, pid} = GenServer.start_link(__MODULE__, %{ queue: [], size: players_per_game, logic: logic }) Logger.info("Queuename: #{inspect(queueName)} QueuePid: #{inspect(pid)} with players: #{players_per_game} and logic #{logic}") Servus.ModuleStore.register(queueName, pid) end @doc """ Add a new player to the queue. This is a synchronous call and will return when the player was succesfully added. """ def push(pid, player) do GenServer.call(pid, {:push, player}) end def handle_call({:push, player}, _, state) do state = %{state | :queue => [player | state.queue]} gameID = Serverutils.get_unique_id(7) cond do state.size == length(state.queue) -> pid = state.logic.start(%{players: state.queue, gameID: gameID}) PidStore.put("#{gameID}", pid) Logger.info("Started a new #{state.logic} with #{state.size} players and ID #{gameID}") {:reply, :started, %{state | :queue => []}} true -> {:reply, :joined, state} end end @doc """ Remove a player from the queue (by it's pid). This function is called when a player that is still in the queue (and thus not in a game) aborts the connection. If we would not remove him at this point he would count as a valid opponent. """ def remove(pid, player) do GenServer.call(pid, {:remove, player}) end def handle_call({:remove, player}, _, state) do queue = Enum.reduce(state.queue, [], fn candidate, acc -> if candidate.id == player.id do acc else [candidate | acc] end end) state = %{state | :queue => queue} {:reply, :ok, state} end end
27.777778
131
0.6265
73f3fd63a0dbecca2f7825b78ac78b00071a3749
1,812
ex
Elixir
elixir/lib/homework_web/schemas/users_schema.ex
hogiyogi597/web-homework
d394458b7e0761301451ed51f69fd6a9629fba76
[ "MIT" ]
null
null
null
elixir/lib/homework_web/schemas/users_schema.ex
hogiyogi597/web-homework
d394458b7e0761301451ed51f69fd6a9629fba76
[ "MIT" ]
null
null
null
elixir/lib/homework_web/schemas/users_schema.ex
hogiyogi597/web-homework
d394458b7e0761301451ed51f69fd6a9629fba76
[ "MIT" ]
null
null
null
defmodule HomeworkWeb.Schemas.UsersSchema do @moduledoc """ Defines the graphql schema for user. """ use Absinthe.Schema.Notation alias HomeworkWeb.Resolvers.UsersResolver object :user do field(:id, non_null(:id)) field(:dob, :string) field(:first_name, :string) field(:last_name, :string) field(:inserted_at, :naive_datetime) field(:updated_at, :naive_datetime) field(:user, :user) do resolve(&UsersResolver.user/3) end end input_object :search_user do field(:first_name, :string) field(:last_name, :string) end object :users do field(:items, list_of(:user)) do arg(:pagination, :pagination) arg(:search, :search_user) resolve(&UsersResolver.users/3) end field(:total_items, :integer) do resolve(&UsersResolver.get_total/3) end end object :user_queries do @desc "Get a User by its id" field(:user, :user) do arg(:id, non_null(:id)) resolve(&UsersResolver.user/3) end @desc "Get all Users" field(:users, :users) do resolve(fn _, _ -> {:ok, %{}} end) end end object :user_mutations do @desc "Create a new user" field :create_user, :user do arg(:dob, non_null(:string)) arg(:first_name, non_null(:string)) arg(:last_name, non_null(:string)) resolve(&UsersResolver.create_user/3) end @desc "Update a new user" field :update_user, :user do arg(:id, non_null(:id)) arg(:dob, non_null(:string)) arg(:first_name, non_null(:string)) arg(:last_name, non_null(:string)) resolve(&UsersResolver.update_user/3) end @desc "Delete an existing user" field :delete_user, :user do arg(:id, non_null(:id)) resolve(&UsersResolver.delete_user/3) end end end
22.37037
44
0.637417
73f44d18fc0103962921f2f50abaf0359a66ed0a
2,096
ex
Elixir
lib/database.ex
cantsin/katakuri
f92c733b86ff8ca6f02a444ca773c25be9585d73
[ "Apache-2.0" ]
2
2015-04-11T04:30:34.000Z
2015-04-18T19:12:25.000Z
lib/database.ex
cantsin/katakuri
f92c733b86ff8ca6f02a444ca773c25be9585d73
[ "Apache-2.0" ]
null
null
null
lib/database.ex
cantsin/katakuri
f92c733b86ff8ca6f02a444ca773c25be9585d73
[ "Apache-2.0" ]
null
null
null
defmodule SlackDatabase do use GenServer require Logger @db_hostname "localhost" @db_username "postgres" @db_password "postgres" @db_database "katakuri" def start_link(_state) do GenServer.start_link(__MODULE__, :ok, [name: :database]) end def timestamp_to_calendar(ts) do {{ts.year, ts.month, ts.day}, {ts.hour, ts.min, ts.sec}} end def write!(query, args \\ []) do GenServer.cast(:database, {:write!, [query, args]}) end def query?(query, args \\ []) do GenServer.call(:database, {:query?, [query, args]}) end def handle_cast({:write!, [query, args]}, state) do Postgrex.Connection.query!(state.db_pid, query, args) {:noreply, state} end def handle_call({:query?, [query, args]}, _from, state) do result = Postgrex.Connection.query!(state.db_pid, query, args) {:reply, result, state} end def init(:ok) do {:ok, pid} = Postgrex.Connection.start_link(extensions: [{Extensions.JSON, library: Poison}], hostname: @db_hostname, username: @db_username, password: @db_password, database: @db_database) Logger.info "Postgrex enabled." state = %{db_pid: pid} {:ok, state} end end defmodule Extensions.JSON do alias Postgrex.TypeInfo @behaviour Postgrex.Extension @moduledoc "Encode and decode Elixir maps to Postgres' JSON." def init(_parameters, opts), do: Keyword.fetch!(opts, :library) def matching(_library), do: [type: "json", type: "jsonb"] def format(_library), do: :binary def encode(%TypeInfo{type: "json"}, map, _state, library), do: library.encode!(map) def encode(%TypeInfo{type: "jsonb"}, map, _state, library), do: <<1, library.encode!(map)::binary>> def decode(%TypeInfo{type: "json"}, json, _state, library), do: library.decode!(json) def decode(%TypeInfo{type: "jsonb"}, <<1, json::binary>>, _state, library), do: library.decode!(json) end
27.578947
97
0.606393
73f45c7ac79de2ed22a91d53c09a6048ec240575
378
ex
Elixir
lib/rpx/summarizer.ex
andrewaguiar/rpx
945ff12edc0f64a0c45a15aaa0af65b73e51bb9b
[ "MIT" ]
1
2018-04-24T13:34:16.000Z
2018-04-24T13:34:16.000Z
lib/rpx/summarizer.ex
andrewaguiar/rpx
945ff12edc0f64a0c45a15aaa0af65b73e51bb9b
[ "MIT" ]
null
null
null
lib/rpx/summarizer.ex
andrewaguiar/rpx
945ff12edc0f64a0c45a15aaa0af65b73e51bb9b
[ "MIT" ]
null
null
null
defmodule Rpx.Summarizer do alias Rpx.Colors def print(matched_lines) do total_lines = matched_lines |> length total_files = matched_lines |> Enum.map(fn {_, file, _, _} -> file end) |> Enum.uniq |> length IO.puts( "\n#{Colors.green(total_files)} files and #{Colors.green(total_lines)} " <> "lines found\n" ) end end
19.894737
81
0.603175
73f4671863dffdb82af011a0ea15b21bc7a180f7
2,160
ex
Elixir
lib/phoenix_live_view/plug.ex
tiagoefmoraes/phoenix_live_view
ed77fa52443c77bd9f281f1a64da832a6e8724e8
[ "MIT" ]
null
null
null
lib/phoenix_live_view/plug.ex
tiagoefmoraes/phoenix_live_view
ed77fa52443c77bd9f281f1a64da832a6e8724e8
[ "MIT" ]
null
null
null
lib/phoenix_live_view/plug.ex
tiagoefmoraes/phoenix_live_view
ed77fa52443c77bd9f281f1a64da832a6e8724e8
[ "MIT" ]
null
null
null
defmodule Phoenix.LiveView.Plug do @moduledoc false alias Phoenix.LiveView.Controller @behaviour Plug @link_header "x-requested-with" def link_header, do: @link_header @impl Plug def init(view) when is_atom(view), do: view def init(opts) when is_list(opts) do view = Keyword.fetch!(opts, :view) %{view: view, opts: __live_opts__(opts)} end @impl Plug def call(%Plug.Conn{private: %{phoenix_live_view: opts}} = conn, view) when is_atom(view) do do_call(conn, view, opts) end def call(%Plug.Conn{} = conn, %{view: view, opts: opts}) when is_atom(view) and is_list(opts) do do_call(conn, view, opts) end defp do_call(conn, view, opts) do render_opts = Keyword.take(opts, [:container, :router, :session]) if live_link?(conn) do html = Phoenix.LiveView.Static.container_render(conn, view, render_opts) conn |> put_cache_headers() |> Plug.Conn.put_resp_header(@link_header, "live-link") |> Phoenix.Controller.html(html) else conn |> put_new_layout_from_router(opts) |> Controller.live_render(view, render_opts) end end @doc false def put_cache_headers(conn) do conn |> Plug.Conn.put_resp_header("vary", @link_header) |> Plug.Conn.put_resp_header( "cache-control", "max-age=0, no-cache, no-store, must-revalidate, post-check=0, pre-check=0" ) end defp put_new_layout_from_router(conn, opts) do cond do live_link?(conn) -> Phoenix.Controller.put_layout(conn, false) layout = opts[:layout] -> Phoenix.Controller.put_new_layout(conn, layout) true -> conn end end defp live_link?(%Plug.Conn{} = conn) do Plug.Conn.get_req_header(conn, @link_header) == ["live-link"] end def __live_opts__(opts) do router = Keyword.fetch!(opts, :router) new_opts = opts |> Keyword.put_new_lazy(:layout, fn -> layout_view = router |> Atom.to_string() |> String.split(".") |> Enum.drop(-1) |> Kernel.++(["LayoutView"]) |> Module.concat() {layout_view, :app} end) new_opts end end
24.827586
98
0.636111
73f46c978d581e2c03973289f1ba232730d22e13
6,196
ex
Elixir
lib/bakeware/assembler.ex
doawoo/bakeware
17afc53b6e5e5c5b98d45f942433400d64be0a1c
[ "Apache-2.0" ]
1
2021-12-27T23:27:07.000Z
2021-12-27T23:27:07.000Z
lib/bakeware/assembler.ex
doawoo/bakeware
17afc53b6e5e5c5b98d45f942433400d64be0a1c
[ "Apache-2.0" ]
null
null
null
lib/bakeware/assembler.ex
doawoo/bakeware
17afc53b6e5e5c5b98d45f942433400d64be0a1c
[ "Apache-2.0" ]
null
null
null
defmodule Bakeware.Assembler do @moduledoc false defstruct [ :start_command, :compress?, :compression_level, :cpio, :launcher, :name, :output, :path, :release, :rel_path, :trailer ] @type t() :: %__MODULE__{ start_command: binary(), compress?: boolean(), compression_level: 1..19, cpio: Path.t(), launcher: Path.t(), name: String.t(), output: Path.t(), path: Path.t(), release: Mix.Release.t(), rel_path: Path.t(), trailer: Path.t() } alias Bakeware.CPIO @doc false @spec assemble(Mix.Release.t()) :: Mix.Release.t() def assemble(%Mix.Release{} = release) do %__MODULE__{name: release.name, rel_path: release.path, release: release} |> do_assemble() # Assembler requires %Mix.Release{} struct returned |> Map.get(:release) end @doc false @spec assemble(Path.t(), String.t()) :: Mix.Release.t() def assemble(path, name) do %__MODULE__{name: name, rel_path: Path.expand(path)} |> do_assemble() |> Map.get(:release) end @doc false @spec executable_name(term()) :: binary() def executable_name(base_name) do string_base_name = to_string(base_name) case :os.type() do {:win32, _} -> string_base_name <> ".exe" _ -> string_base_name end end defp create_paths(assembler) do bake_path = Path.dirname(assembler.rel_path) |> Path.join("bakeware") tmp_name = :crypto.strong_rand_bytes(16) |> Base.encode16() _ = File.mkdir_p!(bake_path) %{ assembler | path: bake_path, cpio: Path.join(bake_path, "#{tmp_name}.cpio"), launcher: Application.app_dir(:bakeware, ["launcher", "launcher"]), output: Path.join(bake_path, executable_name(assembler.name)), trailer: Path.join(bake_path, "#{tmp_name}.trailer") } end defp do_assemble(assembler) do IO.puts(""" #{IO.ANSI.green()}* assembling#{IO.ANSI.default_color()} bakeware #{assembler.name} """) assembler |> create_paths() |> set_compression() |> set_start_command() |> add_start_script() |> add_start_batch() |> CPIO.build() |> build_trailer() |> concat_files() |> cleanup_files() end defp add_start_script(assembler) do start_path = Path.join(assembler.rel_path, "start") start_script_path = "bin/#{assembler.name}" script = """ #!/bin/sh SELF=$(readlink "$0" || true) if [ -z "$SELF" ]; then SELF="$0"; fi ROOT="$(cd "$(dirname "$SELF")" && pwd -P)" $ROOT/#{start_script_path} $1 """ File.write!(start_path, script) File.chmod!(start_path, 0o755) assembler end defp add_start_batch(assembler) do start_path = Path.join(assembler.rel_path, "start.bat") start_script_path = "bin/#{assembler.name}" script = """ @echo off setlocal enabledelayedexpansion set ROOT=%~dp0 %ROOT%/#{start_script_path} %1 """ File.write!(start_path, script) File.chmod!(start_path, 0o755) assembler end defp build_trailer(assembler) do # maybe stream here to be more efficient hash = :crypto.hash(:sha, File.read!(assembler.cpio)) cmd_len = byte_size(assembler.start_command) cmd_padding = :binary.copy(<<0>>, 12 - cmd_len) offset = File.stat!(assembler.launcher).size cpio_size = File.stat!(assembler.cpio).size compression = if assembler.compress?, do: 1, else: 0 trailer_version = 1 flags = 0 trailer_bin = <<hash::20-bytes, assembler.start_command::binary, cmd_padding::binary, cpio_size::32, offset::32, flags::16, compression::8, trailer_version::8, "BAKE">> File.write!(assembler.trailer, trailer_bin) assembler end defp cleanup_files(assembler) do _ = File.rm_rf!(assembler.cpio) _ = File.rm_rf!(assembler.trailer) IO.puts("Bakeware successfully assembled executable at:\n") IO.puts(" #{Path.relative_to(assembler.output, File.cwd!())}") assembler end defp concat_files(assembler) do _ = :os.cmd( 'cat #{assembler.launcher} #{assembler.cpio} #{assembler.trailer} > #{assembler.output}' ) File.chmod!(assembler.output, 0o755) assembler end defp set_compression(assembler) do ## # TODO: Make compression required and move this compress? = case System.find_executable("zstd") do nil -> # no compression IO.puts(""" #{IO.ANSI.yellow()}* warning#{IO.ANSI.default_color()} [Bakeware] zstd not installed. Skipping compression... """) false _path -> true end check_invalid_option!(assembler.release, :compression_level) compression_level = assembler.release.options[:bakeware][:compression_level] || 15 if compression_level not in 1..19 do Mix.raise( "[Bakeware] invalid zstd compression level - Must be an integer 1-19. Got: #{ inspect(compression_level) }" ) end %{assembler | compression_level: compression_level, compress?: compress?} end defp set_start_command(assembler) do check_invalid_option!(assembler.release, :start_command) command = assembler.release.options[:bakeware][:start_command] || "start" cmd_len = byte_size(command) if cmd_len > 12 do err = """ [Bakeware] invalid start command. See the mix release documentation for options https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-bin-release_name-commands """ Mix.raise(err) end %{assembler | start_command: command} end defp check_invalid_option!(release, option) do if value = release.options[option] do Mix.raise(""" [Bakeware] setting :#{option} in the release options outside of the :bakeware key is no longer supported. Please adjust your release options in mix.exs to continue: def release do [ ... steps: [&Bakeware.assemble/1, :assemble], bakeware: [#{option}: #{inspect(value)}] ... ] end """) end :ok end end
25.603306
119
0.618464
73f49a58e34451bd8e9d92f1f5c4161d84030ac6
1,888
ex
Elixir
clients/cloud_build/lib/google_api/cloud_build/v1/model/volume.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/cloud_build/lib/google_api/cloud_build/v1/model/volume.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/cloud_build/lib/google_api/cloud_build/v1/model/volume.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.CloudBuild.V1.Model.Volume do @moduledoc """ Volume describes a Docker container volume which is mounted into build steps in order to persist files across build step execution. ## Attributes * `name` (*type:* `String.t`, *default:* `nil`) - Name of the volume to mount. Volume names must be unique per build step and must be valid names for Docker volumes. Each named volume must be used by at least two build steps. * `path` (*type:* `String.t`, *default:* `nil`) - Path at which to mount the volume. Paths must be absolute and cannot conflict with other volume paths on the same build step or with certain reserved volume paths. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :name => String.t(), :path => String.t() } field(:name) field(:path) end defimpl Poison.Decoder, for: GoogleApi.CloudBuild.V1.Model.Volume do def decode(value, options) do GoogleApi.CloudBuild.V1.Model.Volume.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudBuild.V1.Model.Volume do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
33.122807
88
0.71928
73f49d8cb32fdcf25e656261684f1e595187d64f
3,110
ex
Elixir
lib/versioning/change.ex
nsweeting/versioning
0de0102deea00c020025d74a64f5e57617c855da
[ "MIT" ]
24
2018-11-11T15:02:18.000Z
2020-11-11T21:21:58.000Z
lib/versioning/change.ex
nsweeting/versioning
0de0102deea00c020025d74a64f5e57617c855da
[ "MIT" ]
null
null
null
lib/versioning/change.ex
nsweeting/versioning
0de0102deea00c020025d74a64f5e57617c855da
[ "MIT" ]
null
null
null
defmodule Versioning.Change do @moduledoc """ Defines a versioning change. A versioning change is used to make small changes to data of a certain type. They are used within a `Versioning.Schema`. Changes should attempt to be as focused as possible to ensure complexity is kept to a minimum. ## Example defmodule MyApp.Cheanges.PostStatusChange do use Versioning.Change @desc "The 'active' attribute has been changed in favour of the 'status' attribute" @impl Versioning.Change def down(versioning, _opts) do case Versioning.pop_data(versioning, "status") do {:active, versioning} -> Versioning.put_data(versioning, "active", true) {_, versioning} -> Versioning.put_data(versioning, "active", false) end end @impl Versioning.Change def up(versioning, _opts) do case Versioning.pop_data(versioning, "active") do {true, versioning} -> Versioning.put_data(versioning, "status", "active") {false, versioning} -> Versioning.put_data(versioning, "status", "hidden") {_, versioning} -> versioning end end end The above change module represents us modifying our `Post` data to support a new attribute - `status` - which replaces the previous `active` attribute. When changing data "down", we must remove the `status` attribte, and replace it with a value that represents the previous `active` attribute. When changing data "up", we must remove the `active` attribute and replace it with a value that represents the new `status` attribute. ## Descriptions Change modules can optionally include a `@desc` module attribute. This will be used to describe the changes made in the change module when constructing changelogs. Please see the `Versioning.Changelog` documentation for more information on changelogs. """ @doc """ Accepts a `Versioning` struct, and applies changes upward. ## Examples MyApp.Change.up(versioning) """ @callback up(versioning :: Versioning.t(), opts :: any()) :: Versioning.t() @doc """ Accepts a `Versioning` struct and applies changes downward. ## Examples MyApp.Change.down(versioning) """ @callback down(versioning :: Versioning.t(), opts :: any()) :: Versioning.t() defmacro __using__(_opts) do quote do @behaviour Versioning.Change @desc "No Description" @before_compile Versioning.Change end end defmacro __before_compile__(_env) do quote do def __change__(:desc) do @desc end end end @doc false @spec up(Versioning.t(), atom(), any()) :: Versioning.t() def up(versioning, change, opts) do versioning |> change.up(opts) |> put_change(change) end @doc false @spec down(Versioning.t(), atom(), any()) :: Versioning.t() def down(versioning, change, opts) do versioning |> change.down(opts) |> put_change(change) end defp put_change(versioning, change) do %{versioning | changed: true, changes: [change | versioning.changes]} end end
30.194175
91
0.673633
73f49dcf82a0f17985db9cd341b78ddf95e5c272
286
ex
Elixir
lib/rocketpay/accounts/transactions/response.ex
leoferreiralima/rocketpay
afc8e89d30e7cef6c9e8f1a3bc4007cffd0ece31
[ "MIT" ]
null
null
null
lib/rocketpay/accounts/transactions/response.ex
leoferreiralima/rocketpay
afc8e89d30e7cef6c9e8f1a3bc4007cffd0ece31
[ "MIT" ]
null
null
null
lib/rocketpay/accounts/transactions/response.ex
leoferreiralima/rocketpay
afc8e89d30e7cef6c9e8f1a3bc4007cffd0ece31
[ "MIT" ]
null
null
null
defmodule Rocketpay.Accounts.Transactions.Response do alias Rocketpay.Account defstruct [:to_account, :from_account] def build(%Account{} = from_account, %Account{} = to_account) do %__MODULE__{ from_account: from_account, to_account: to_account } end end
22
66
0.72028
73f4cbbb717a4d6a61cdab137816290777102795
1,475
exs
Elixir
config/config.exs
dbernazal/html_playback
489c4a26ad3aafb9484a143f9352f0ce5dd26a7f
[ "MIT" ]
null
null
null
config/config.exs
dbernazal/html_playback
489c4a26ad3aafb9484a143f9352f0ce5dd26a7f
[ "MIT" ]
2
2021-03-09T11:51:15.000Z
2021-05-10T01:10:16.000Z
config/config.exs
dbernazal/html_playback
489c4a26ad3aafb9484a143f9352f0ce5dd26a7f
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. # General application configuration use Mix.Config # Configures the endpoint config :html_playback, HtmlPlaybackWeb.Endpoint, url: [host: "localhost"], secret_key_base: "51AXe2UgW4ycP/0D1eZ18OWmSR2AVVXqNmVL8ihP+jTu1t/vU9Np6XFqNU7AfQ1t", render_errors: [view: HtmlPlaybackWeb.ErrorView, accepts: ~w(html json)], pubsub: [name: HtmlPlayback.PubSub, adapter: Phoenix.PubSub.PG2], live_view: [ signing_salt: "rVeFmJEroV2BBbNads01KTwiMAAcTOAZ34CZa7xP8BFI4yQ9Lobjtc64VtspClID" ] # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] # Use Jason for JSON parsing in Phoenix config :phoenix, json_library: Jason, template_engines: [leex: Phoenix.LiveView.Engine] config :pooler, pools: [ [ name: :riaklocal1, group: :riak, max_count: 10, init_count: 5, start_mfa: {Riak.Connection, :start_link, []} ], [ name: :riaklocal2, group: :riak, max_count: 15, init_count: 2, start_mfa: {Riak.Connection, :start_link, []} ] ] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs"
28.921569
86
0.718644
73f4cc82260407af372defba8b32f86c9ea42272
144
ex
Elixir
lib/crc32c_rust.ex
jamesvl/crc32c
e9dc4b3ffed2ea486c62eab970c65f742e777426
[ "MIT" ]
null
null
null
lib/crc32c_rust.ex
jamesvl/crc32c
e9dc4b3ffed2ea486c62eab970c65f742e777426
[ "MIT" ]
null
null
null
lib/crc32c_rust.ex
jamesvl/crc32c
e9dc4b3ffed2ea486c62eab970c65f742e777426
[ "MIT" ]
null
null
null
defmodule Crc32c do use Rustler, otp_app: :crc32c, crate: "crc32crust" def calc(_data), do: :erlang.nif_error(:nif_not_loaded) end
18
57
0.701389
73f4e51c9bca757b86ac874b962e37b2cf9a0b00
749
ex
Elixir
lib/freddy/adapter/sandbox/channel.ex
ajkeys/ex_freddy
c59d0bcfad4b89de8a9b09c7124d0499824a0710
[ "MIT" ]
10
2017-06-28T11:39:39.000Z
2021-11-19T23:23:16.000Z
lib/freddy/adapter/sandbox/channel.ex
ajkeys/ex_freddy
c59d0bcfad4b89de8a9b09c7124d0499824a0710
[ "MIT" ]
16
2017-01-07T15:34:36.000Z
2021-05-05T11:07:31.000Z
lib/freddy/adapter/sandbox/channel.ex
ajkeys/ex_freddy
c59d0bcfad4b89de8a9b09c7124d0499824a0710
[ "MIT" ]
4
2018-10-08T19:54:46.000Z
2021-05-05T10:49:10.000Z
defmodule Freddy.Adapter.Sandbox.Channel do @moduledoc false use GenServer alias Freddy.Adapter.Sandbox.Connection def open(connection) do case Connection.get_on_open_channel(connection) do :ok -> GenServer.start_link(__MODULE__, connection) other -> other end end def monitor(channel) do Process.monitor(channel) end def close(channel) do GenServer.stop(channel) end def register(channel, event, args) do GenServer.call(channel, {:register, event, args}) end @impl true def init(connection) do {:ok, connection} end @impl true def handle_call({:register, event, args}, _from, connection) do {:reply, Connection.register(connection, event, args), connection} end end
20.243243
70
0.70494
73f52c8e2ce1bbc16e9405580ab95039af54c8da
39,473
exs
Elixir
test/row_test.exs
hou8/ecto_tablestore
523967c72622755ad050de6ed6add296721fcbbb
[ "MIT" ]
null
null
null
test/row_test.exs
hou8/ecto_tablestore
523967c72622755ad050de6ed6add296721fcbbb
[ "MIT" ]
null
null
null
test/row_test.exs
hou8/ecto_tablestore
523967c72622755ad050de6ed6add296721fcbbb
[ "MIT" ]
null
null
null
defmodule EctoTablestore.RowTest do use ExUnit.Case alias EctoTablestore.TestSchema.{Order, User, User2, User3, User4, EmbedItem} alias EctoTablestore.TestRepo alias Ecto.Changeset import EctoTablestore.Query, only: [condition: 2, condition: 1, filter: 1] setup_all do TestHelper.setup_all() EctoTablestore.Support.Table.create_order() EctoTablestore.Support.Table.create_user() EctoTablestore.Support.Table.create_user2() EctoTablestore.Support.Table.create_user3() EctoTablestore.Support.Table.create_user4() on_exit(fn -> EctoTablestore.Support.Table.delete_order() EctoTablestore.Support.Table.delete_user() EctoTablestore.Support.Table.delete_user2() EctoTablestore.Support.Table.delete_user3() EctoTablestore.Support.Table.delete_user4() end) Process.sleep(3_000) end test "repo - embed schema c/r/u/d" do user4 = %User4{ id: "1", cars: [ %User4.Car{name: "car1", status: :bar}, %User4.Car{name: "car2", status: :foo} ], info: %User4.Info{ name: "Mike", status: :baz, money: Decimal.new(1) }, item: %EmbedItem{name: "item1"} } {status, _inserted_result} = TestRepo.insert(user4, condition: condition(:ignore), return_type: :pk) assert :ok == status one_result = TestRepo.one(user4) assert user4 == one_result info = %{ name: "Ben" } embed_item = %{ name: "item2" } changeset = user4 |> Ecto.Changeset.change() |> Ecto.Changeset.put_embed(:info, info) |> Ecto.Changeset.put_embed(:item, embed_item) {status, _updated_result} = TestRepo.update(changeset, condition: condition(:expect_exist), return_type: :pk) assert :ok == status {status, _updated_result} = TestRepo.delete(%User4{id: "1"}, condition: condition(:expect_exist)) assert :ok == status end test "repo - insert/get/delete" do input_id = "1" input_desc = "order_desc" input_num = 1 input_order_name = "order_name" input_success = true input_price = 100.09 order = %Order{ id: input_id, name: input_order_name, desc: input_desc, num: input_num, success?: input_success, price: input_price } assert_raise Ecto.ConstraintError, fn -> TestRepo.insert(order, condition: condition(:expect_not_exist), return_type: :pk) end {status, saved_order} = TestRepo.insert(order, condition: condition(:ignore), return_type: :pk) assert status == :ok saved_order_internal_id = saved_order.internal_id assert saved_order.id == input_id # autogenerate primary key return in schema assert saved_order_internal_id != nil and is_integer(saved_order_internal_id) == true order_with_non_exist_num = %Order{id: input_id, internal_id: saved_order_internal_id, num: 2} query_result = TestRepo.one(order_with_non_exist_num, entity_full_match: true) assert query_result == nil query_result = TestRepo.one(order_with_non_exist_num) assert query_result != nil query_result = TestRepo.one(%Order{id: "fake", internal_id: 0}) assert query_result == nil # `num` attribute field will be used in condition filter order_with_matched_num = %Order{ id: input_id, internal_id: saved_order_internal_id, num: input_num } query_result_by_one = TestRepo.one(order_with_matched_num, entity_full_match: true) assert query_result_by_one != nil assert query_result_by_one.desc == input_desc assert query_result_by_one.num == input_num assert query_result_by_one.name == input_order_name assert query_result_by_one.success? == input_success assert query_result_by_one.price == input_price # query and return fields in `columns_to_get` query_result2_by_one = TestRepo.one(order_with_matched_num, columns_to_get: ["num", "desc"], entity_full_match: true ) assert query_result2_by_one.desc == input_desc assert query_result2_by_one.num == input_num assert query_result2_by_one.name == nil assert query_result2_by_one.success? == nil assert query_result2_by_one.price == nil # Optional use case `get/3` query_result_by_get = TestRepo.get(Order, id: input_id, internal_id: saved_order_internal_id) assert query_result_by_get == query_result_by_one query_result2_by_get = TestRepo.get(Order, [internal_id: saved_order_internal_id, id: input_id], columns_to_get: ["num", "desc"] ) assert query_result2_by_get == query_result2_by_one query_result = TestRepo.get(Order, [id: input_id, internal_id: saved_order_internal_id], filter: filter("num" == 2) ) assert query_result == nil query_result = TestRepo.get(Order, [id: input_id, internal_id: saved_order_internal_id], filter: filter("num" == input_num) ) assert query_result == query_result_by_get assert_raise Ecto.ChangeError, fn -> TestRepo.delete!(%Order{id: input_id, internal_id: "invalid"}) end assert_raise Ecto.NoPrimaryKeyValueError, fn -> TestRepo.delete(%Order{id: input_id}) end order = %Order{internal_id: saved_order_internal_id, id: input_id} assert_raise Ecto.StaleEntryError, fn -> TestRepo.delete(order, condition: condition(:expect_exist, "num" == "invalid_num")) end {result, _} = TestRepo.delete(order, condition: condition(:expect_exist, "num" == input_num)) assert result == :ok end test "repo - update" do input_id = "1001" input_desc = "order_desc" input_num = 10 increment = 1 input_price = 99.9 order = %Order{id: input_id, desc: input_desc, num: input_num, price: input_price} {:ok, saved_order} = TestRepo.insert(order, condition: condition(:ignore), return_type: :pk) assert saved_order.price == input_price new_input_num = 100 changeset = Order.test_changeset(saved_order, %{name: "new_name1", num: new_input_num, price: 88.8}) {:ok, updated_order0} = TestRepo.update(changeset, condition: condition(:expect_exist), return_type: :pk) # since the above `test_changeset` don't update price assert updated_order0.price == input_price assert updated_order0.name == "new_name1" assert updated_order0.num == 100 # 1, atom increment `num` field # 2, delete `desc` field # 3, update `name` field as "new_order" updated_order_name = "new_order_name" changeset = saved_order |> Ecto.Changeset.change(num: {:increment, increment}, desc: nil) |> Ecto.Changeset.change(name: updated_order_name) {:ok, updated_order} = TestRepo.update(changeset, condition: condition(:expect_exist), returning: [:num]) assert updated_order.desc == nil assert updated_order.num == new_input_num + increment assert updated_order.name == updated_order_name order = TestRepo.get(Order, internal_id: saved_order.internal_id, id: input_id) assert order.desc == nil assert order.num == new_input_num + increment assert order.name == updated_order_name TestRepo.delete(%Order{id: input_id, internal_id: saved_order.internal_id}, condition: condition(:expect_exist) ) end test "repo - update with timestamps" do user = %User{name: "username", level: 10, level2: 0, id: 1} {:ok, user} = TestRepo.insert(user, condition: condition(:ignore)) # Notice: # Require to set `returning` option when use `{:increment, number}`. assert_raise Ecto.ConstraintError, ~r(Require to set `:level` in the :returning option), fn -> changeset = Ecto.Changeset.change(user, level: {:increment, 1}, name: "updated_name") TestRepo.update(changeset, condition: condition(:expect_exist)) end {:ok, user} = user |> Ecto.Changeset.change(level: {:increment, 1}, name: "updated_name") |> TestRepo.update(condition: condition(:expect_exist), returning: [:level]) assert user.level == 11 and user.level2 == 0 {:ok, user} = user |> Ecto.Changeset.change(level: {:increment, -1}, level2: {:increment, 1}) |> TestRepo.update(condition: condition(:expect_exist), returning: [:level, :level2]) assert user.level == 10 and user.level2 == 1 {:ok, user} = user |> Ecto.Changeset.change(level: {:increment, 1}, level2: {:increment, 0}) |> TestRepo.update(condition: condition(:expect_exist), returning: [:level2, :level]) assert user.level == 11 and user.level2 == 1 {:ok, user} = user |> Ecto.Changeset.change(level: {:increment, 1}, name: "username2") |> TestRepo.update(condition: condition(:expect_exist), returning: [:level]) assert user.level == 12 and user.level2 == 1 and user.name == "username2" and user.inserted_at != nil naive_dt = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) dt = DateTime.utc_now() |> DateTime.truncate(:second) {:ok, user} = user |> Ecto.Changeset.change( level: {:increment, 1}, level2: 2, name: "username3", naive_dt: naive_dt, dt: dt, profile: %{"test" => 1}, tags: ["A", "B"] ) |> TestRepo.update(condition: condition(:expect_exist), returning: true) # Since `returning: true` but the :inserted_at field is not in the changes, it will be replaced as `nil` in the updated user. assert user.level == 13 and user.level2 == 2 and user.inserted_at == nil and user.name == "username3" and user.inserted_at == nil {:ok, user} = user |> Ecto.Changeset.change(level: {:increment, 1}, name: "username3", tags: ["C", "D"]) |> TestRepo.update(condition: condition(:expect_exist), returning: [:level, :tags]) assert user.level == 14 and user.level2 == 2 and user.tags == ["C", "D"] TestRepo.delete(user, condition: condition(:expect_exist)) user = %User{name: "username", level: 1, level2: 1, id: 1} {:ok, saved_user} = TestRepo.insert(user, condition: condition(:ignore)) assert saved_user.updated_at == saved_user.inserted_at assert is_integer(saved_user.updated_at) user = TestRepo.get(User, id: 1) new_name = "username2" changeset = Ecto.Changeset.change(user, name: new_name, level: {:increment, 1}) # Make sure there is a time difference between `updated_at` and `inserted_at` Process.sleep(1000) {:ok, updated_user} = TestRepo.update(changeset, condition: condition(:expect_exist), returning: [:level]) assert updated_user.level == 2 assert updated_user.name == new_name assert updated_user.updated_at > updated_user.inserted_at TestRepo.delete(user, condition: condition(:expect_exist)) end test "repo - insert/update with ecto types" do assert_raise Ecto.StaleEntryError, ~r/attempted to insert a stale struct/, fn -> user = %User{ name: "username2", profile: %{"level" => 1, "age" => 20}, tags: ["tag_a", "tag_b"], id: 2 } TestRepo.insert(user, condition: condition(:expect_exist)) end naive_dt = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) dt = DateTime.utc_now() |> DateTime.truncate(:second) user = %User{ id: 1, name: "username", naive_dt: naive_dt, dt: dt, profile: %{"level" => 1, "age" => 20}, tags: ["tag_a", "tag_b"] } {:ok, _saved_user} = TestRepo.insert(user, condition: condition(:ignore)) get_user = TestRepo.get(User, id: 1) profile = get_user.profile assert get_user.naive_dt == naive_dt assert get_user.dt == dt assert Map.get(profile, "level") == 1 assert Map.get(profile, "age") == 20 assert get_user.tags == ["tag_a", "tag_b"] naive_dt = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) dt = DateTime.utc_now() |> DateTime.truncate(:second) changeset = Ecto.Changeset.change(get_user, name: "username2", profile: %{name: 1}, naive_dt: naive_dt, dt: dt ) {:ok, updated_user} = TestRepo.update(changeset, condition: condition(:expect_exist)) assert updated_user.naive_dt == naive_dt assert updated_user.dt == dt assert updated_user.profile == %{name: 1} get_user = TestRepo.get(User, id: 1) # Please notice that Jason.decode use :key option as :strings by default, we don't # provide a way to modify this option so far. assert get_user.profile == %{"name" => 1} TestRepo.delete(user, condition: condition(:expect_exist)) end describe "range" do setup do saved_orders = Enum.map(1..9, fn var -> {:ok, saved_order} = TestRepo.insert(%Order{id: "#{var}", desc: "desc#{var}", num: var, price: 20.5 * var}, condition: condition(:ignore), return_type: :pk ) saved_order end) # double A {:ok, order_10_1} = TestRepo.insert(%Order{id: "A", desc: "descA", num: 10, price: 20.5 * 10}, condition: condition(:ignore), return_type: :pk ) {:ok, order_10_2} = TestRepo.insert(%Order{id: "A", desc: "descA", num: 10, price: 20.5 * 10}, condition: condition(:ignore), return_type: :pk ) saved_orders = saved_orders ++ [order_10_1, order_10_2] on_exit(fn -> for order <- saved_orders do TestRepo.delete(%Order{id: order.id, internal_id: order.internal_id}, condition: condition(:expect_exist) ) end end) end test "repo - get_range/1-2" do assert {nil, nil} = TestRepo.get_range(%Order{id: "0"}) assert {orders, nil} = TestRepo.get_range(%Order{id: "1"}) assert length(orders) == 1 assert {orders, nil} = TestRepo.get_range(%Order{id: "A"}) assert length(orders) == 2 assert {orders, nil} = TestRepo.get_range(Order) assert length(orders) == 11 assert {backward_orders, nil} = TestRepo.get_range(Order, direction: :backward) assert orders == Enum.reverse(backward_orders) assert {limit_orders, next_token} = TestRepo.get_range(Order, limit: 3) assert length(limit_orders) == 3 assert is_binary(next_token) end test "repo - get_range/3-4" do start_pks = [{"id", "0a"}, {"internal_id", :inf_min}] end_pks = [{"id", "0b"}, {"internal_id", :inf_max}] {orders, next_start_primary_key} = TestRepo.get_range(Order, start_pks, end_pks) assert orders == nil and next_start_primary_key == nil start_pks = [{"id", "1"}, {"internal_id", :inf_min}, {"id", "1"}] end_pks = [{"id", "3"}, {"internal_id", :inf_max}, {"id", "3"}] assert {orders, nil} = TestRepo.get_range(Order, start_pks, end_pks) assert length(orders) == 3 start_pks = [{"id", "3"}, {"internal_id", :inf_max}] end_pks = [{"id", "1"}, {"internal_id", :inf_min}] {backward_orders, _next_start_primary_key} = TestRepo.get_range(Order, start_pks, end_pks, direction: :backward) assert orders == Enum.reverse(backward_orders) start_pks = [{"id", "7"}, {"internal_id", :inf_max}] end_pks = [{"id", "4"}, {"internal_id", :inf_min}] {orders, next_start_primary_key} = TestRepo.get_range(Order, start_pks, end_pks, limit: 3, direction: :backward) assert next_start_primary_key != nil assert length(orders) == 3 {orders2, next_start_primary_key} = TestRepo.get_range(Order, next_start_primary_key, end_pks, limit: 3, direction: :backward) assert next_start_primary_key == nil assert length(orders2) == 1 end test "repo - stream" do # since it is enumerable, no matched data will return `[]`. assert [] = %Order{id: "0"} |> TestRepo.stream() |> Enum.to_list() assert 1 = %Order{id: "1"} |> TestRepo.stream() |> Enum.count() assert 2 = %Order{id: "A"} |> TestRepo.stream() |> Enum.count() orders = TestRepo.stream(Order) |> Enum.to_list() assert 11 = Enum.count(orders) assert ^orders = Order |> TestRepo.stream(direction: :backward) |> Enum.reverse() assert 5 = Order |> TestRepo.stream(limit: 3) |> Enum.take(5) |> Enum.count() end test "repo - stream_range" do start_pks = [{"id", "0a"}, {"internal_id", :inf_min}] end_pks = [{"id", "0b"}, {"internal_id", :inf_max}] # since it is enumerable, no matched data will return `[]`. assert [] = Order |> TestRepo.stream_range(start_pks, end_pks, direction: :forward) |> Enum.to_list() start_pks = [{"id", "1"}, {"internal_id", :inf_min}] end_pks = [{"id", "3"}, {"internal_id", :inf_max}] orders = Order |> TestRepo.stream_range(start_pks, end_pks, direction: :forward, limit: 1) |> Enum.to_list() assert length(orders) == 3 # start/end pks with an invalid `direction` [{:error, error}] = Order |> TestRepo.stream_range(start_pks, end_pks, direction: :backward) |> Enum.to_list() assert error.code == "OTSParameterInvalid" and error.message == "Begin key must more than end key in BACKWARD" start_pks = [{"id", "3"}, {"internal_id", :inf_max}] end_pks = [{"id", "1"}, {"internal_id", :inf_min}] assert ^orders = Order |> TestRepo.stream_range(start_pks, end_pks, direction: :backward) |> Enum.reverse() start_pks = [{"id", "1"}, {"internal_id", :inf_min}] end_pks = [{"id", "9"}, {"internal_id", :inf_max}] assert 9 = Order |> TestRepo.stream_range(start_pks, end_pks, limit: 3) |> Enum.count() assert 5 = Order |> TestRepo.stream_range(start_pks, end_pks, limit: 3) |> Enum.take(5) |> Enum.count() end end test "repo - batch_get" do {saved_orders, saved_users} = Enum.reduce(1..3, {[], []}, fn var, {cur_orders, cur_users} -> order = %Order{id: "#{var}", desc: "desc#{var}", num: var, price: 1.8 * var} {:ok, saved_order} = TestRepo.insert(order, condition: condition(:ignore), return_type: :pk) user = %User{id: var, name: "name#{var}", level: var} {:ok, saved_user} = TestRepo.insert(user, condition: condition(:expect_not_exist), return_type: :pk) {cur_orders ++ [saved_order], cur_users ++ [saved_user]} end) requests1 = [ {Order, [[{"id", "1"}, {"internal_id", List.first(saved_orders).internal_id}]], columns_to_get: ["num"]}, [%User{id: 1, name: "name1"}, %User{id: 2, name: "name2"}] ] {:ok, result} = TestRepo.batch_get(requests1) [{Order, query_orders}, {User, query_users}] = result assert length(query_orders) == 1 assert length(query_users) == 2 for query_user <- query_users do assert query_user.level != nil end # provide attribute column `name` in schema, and set `entity_full_match: true` will use these attribute field(s) in the filter and add `name` into columns_to_get if specially set columns_to_get. requests2 = [ {User, [ [{"id", 1}], [{"id", 2}] ]} ] {:ok, result2} = TestRepo.batch_get(requests2) query_users2 = Keyword.get(result2, User) assert length(query_users2) == 2 requests2 = [ {User, [ [{"id", 1}], [{"id", 2}] ], columns_to_get: ["level"]} ] {:ok, result2} = TestRepo.batch_get(requests2) query_users2 = Keyword.get(result2, User) assert length(query_users2) == 2 for query_user <- query_users2 do assert query_user.level != nil end requests2 = [ {[%User{id: 1, name: "name1"}, %User{id: 2, name: "name2"}], columns_to_get: ["level"], entity_full_match: true} ] {:ok, result2} = TestRepo.batch_get(requests2) query_users2 = Keyword.get(result2, User) assert length(query_users2) == 2 for query_user <- query_users2 do assert query_user.name != nil assert query_user.level != nil end requests_with_fake = [ {[%User{id: 1, name: "name_fake"}, %User{id: 2, name: "name2"}], columns_to_get: ["level"], entity_full_match: true} ] {:ok, [{_, result_users}]} = TestRepo.batch_get(requests_with_fake) assert length(result_users) == 1 assert_raise RuntimeError, fn -> # When use `entity_full_match: true`, one schema provides `name` attribute, # another schema only has primary key, # in this case, there exist conflict will raise a RuntimeError for requests_invalid = [ {[%User{id: 1, name: "name1"}, %User{id: 2}], entity_full_match: true} ] TestRepo.batch_get(requests_invalid) end # The filter of following case is ((name == "name1" and level == 2) or (name == "name2" and level == 2) requests3 = [ {[%User{id: 1, name: "name1"}, %User{id: 2, name: "name2"}], filter: filter("level" == 2)} ] {:ok, result3} = TestRepo.batch_get(requests3) query_users3 = Keyword.get(result3, User) assert length(query_users3) == 1 query3_user = List.first(query_users3) assert query3_user.id == 2 assert query3_user.name == "name2" changeset = Ecto.Changeset.change(%User{id: 1}, name: "new_name1") TestRepo.update(changeset, condition: condition(:expect_exist)) # After update User(id: 1)'s name as `new_name1`, in the next batch get, attribute columns will be used in filter. # # The following case will only return User(id: 2) in batch get. requests3_1 = [ {[%User{id: 1, name: "name1"}, %User{id: 2, name: "name2"}], entity_full_match: true} ] {:ok, result3_1} = TestRepo.batch_get(requests3_1) query_result3_1 = Keyword.get(result3_1, User) assert length(query_result3_1) == 1 query3_1_user = List.first(query_result3_1) assert query3_1_user.id == 2 assert query3_1_user.name == "name2" # Although User(id: 1)'s name is changed, but by default `batch_get` only use the primary keys of User entity to fetch rows. requests4 = [ [%User{id: 1, name: "not_existed_name1"}] ] {:ok, result4} = TestRepo.batch_get(requests4) assert Keyword.get(result4, User) != nil for order <- saved_orders do TestRepo.delete(%Order{id: order.id, internal_id: order.internal_id}, condition: condition(:expect_exist) ) end for user <- saved_users do TestRepo.delete(%User{id: user.id}, condition: condition(:expect_exist)) end end test "repo - batch_write" do order0 = %Order{id: "order0", desc: "desc0"} {:ok, saved_order0} = TestRepo.insert(order0, condition: condition(:ignore), return_type: :pk) order1_num = 10 order1 = %Order{id: "order1", desc: "desc1", num: order1_num, price: 89.1} {:ok, saved_order1} = TestRepo.insert(order1, condition: condition(:ignore), return_type: :pk) order2 = %Order{id: "order2", desc: "desc2", num: 5, price: 76.6} {:ok, saved_order2} = TestRepo.insert(order2, condition: condition(:ignore), return_type: :pk) order3 = %Order{id: "order3", desc: "desc3", num: 10, price: 55.67} order4_changeset = Changeset.cast(%Order{id: "order4_1", desc: "desc3"}, %{num: 40}, [:num]) user1_lv = 8 user1 = %User{id: 100, name: "u1", level: user1_lv} {:ok, _} = TestRepo.insert(user1, condition: condition(:expect_not_exist)) user2 = %User{id: 101, name: "u2", level: 11} {:ok, _} = TestRepo.insert(user2, condition: condition(:expect_not_exist)) user3 = %User{id: 102, name: "u3", level: 12} changeset_order1 = Order |> TestRepo.get(id: "order1", internal_id: saved_order1.internal_id) |> Changeset.change(num: {:increment, 1}, price: nil) changeset_user1 = User |> TestRepo.get(id: 100) |> Changeset.change(level: {:increment, 1}, name: "new_user_2") writes = [ delete: [ saved_order2, {Order, [id: "order0", internal_id: saved_order0.internal_id], condition: condition(:ignore)}, {user2, return_type: :pk} ], update: [ {changeset_user1, return_type: :pk}, {changeset_order1, return_type: :pk} ], put: [ {order3, condition: condition(:ignore), return_type: :pk}, {order4_changeset, condition: condition(:ignore), return_type: :pk}, {user3, condition: condition(:expect_not_exist), return_type: :pk} ] ] {:ok, result} = TestRepo.batch_write(writes) order_batch_write_result = Keyword.get(result, Order) {:ok, batch_write_update_order} = Keyword.get(order_batch_write_result, :update) |> List.first() assert batch_write_update_order.num == order1_num + 1 assert batch_write_update_order.id == order1.id assert batch_write_update_order.internal_id == saved_order1.internal_id assert batch_write_update_order.price == nil [{:ok, batch_write_delete_order2}, {:ok, batch_write_delete_order0}] = Keyword.get(order_batch_write_result, :delete) assert batch_write_delete_order2.id == saved_order2.id assert batch_write_delete_order2.internal_id == saved_order2.internal_id assert batch_write_delete_order0.id == saved_order0.id assert batch_write_delete_order0.internal_id == saved_order0.internal_id {:ok, batch_write_put_order} = Keyword.get(order_batch_write_result, :put) |> List.first() assert batch_write_put_order.id == order3.id assert batch_write_put_order.desc == "desc3" assert batch_write_put_order.num == 10 assert batch_write_put_order.price == 55.67 {:ok, batch_write_put_order4} = Keyword.get(order_batch_write_result, :put) |> List.last() assert batch_write_put_order4.id == order4_changeset.data.id assert is_integer(batch_write_put_order4.internal_id) == true assert batch_write_put_order4.num == order4_changeset.changes.num user_batch_write_result = Keyword.get(result, User) {:ok, batch_write_update_user} = Keyword.get(user_batch_write_result, :update) |> List.first() assert batch_write_update_user.level == user1_lv + 1 assert batch_write_update_user.name == "new_user_2" assert batch_write_update_user.id == 100 {:ok, batch_write_delete_user} = Keyword.get(user_batch_write_result, :delete) |> List.first() assert batch_write_delete_user.level == 11 assert batch_write_delete_user.id == 101 assert batch_write_delete_user.name == "u2" {:ok, batch_write_put_user} = Keyword.get(user_batch_write_result, :put) |> List.first() assert batch_write_put_user.level == 12 assert batch_write_put_user.id == 102 assert batch_write_put_user.name == "u3" changeset_user3 = Changeset.change(batch_write_put_user, level: {:increment, 2}) # failed case writes2 = [ delete: [ batch_write_put_user ], update: [ changeset_user3 ] ] {:ok, result2} = TestRepo.batch_write(writes2) fail_batch_write_result = Keyword.get(result2, User) {:error, batch_write_update_response} = Keyword.get(fail_batch_write_result, :update) |> List.first() assert batch_write_update_response.is_ok == false {:error, batch_write_delete_response} = Keyword.get(fail_batch_write_result, :delete) |> List.first() assert batch_write_delete_response.is_ok == false {:ok, _} = TestRepo.delete(batch_write_put_user, condition: condition(:expect_exist)) {:ok, _} = TestRepo.delete(batch_write_update_user, condition: condition(:expect_exist)) {:ok, _} = TestRepo.delete(batch_write_put_order, condition: condition(:ignore)) {:ok, _} = TestRepo.delete(batch_write_update_order, condition: condition(:ignore)) end test "repo - batch_update with timestamps" do inserted_users = for index <- 1..3 do u = %User{id: index, name: "u#{index}", level: index} {:ok, inserted_user} = TestRepo.insert(u, condition: condition(:expect_not_exist)) assert inserted_user.inserted_at == inserted_user.updated_at inserted_user end user1 = List.first(inserted_users) Process.sleep(1000) new_user1_name = "new_u1" changeset1 = Changeset.change(user1, name: new_user1_name, level: nil) changeset2 = Changeset.change(%User{id: 2}, level: {:increment, 1}) writes = [ update: [ {changeset1, condition: condition(:expect_exist)}, {changeset2, condition: condition(:expect_exist)} ], put: [ {%User{id: 10, name: "new10", level: 10}, condition: condition(:expect_not_exist)}, {%User{id: 11, name: "new11", level: 11}, condition: condition(:expect_not_exist)} ] ] {:ok, result} = TestRepo.batch_write(writes) user_writes = Keyword.get(result, User) put_opers = Keyword.get(user_writes, :put) for {:ok, put_user} <- put_opers do assert put_user.inserted_at == put_user.updated_at end update_opers = Keyword.get(user_writes, :update) for {:ok, update_user} <- update_opers do case update_user.id do 1 -> update_updated_at = update_user.updated_at update_inserted_at = update_user.inserted_at user1_inserted_at = user1.inserted_at assert update_updated_at > user1_inserted_at and update_updated_at > update_inserted_at and update_inserted_at == user1_inserted_at assert update_user.level == nil assert update_user.name == new_user1_name 2 -> updated_at = update_user.updated_at assert updated_at != nil and is_integer(updated_at) assert update_user.level == 3 assert update_user.name == nil end end TestRepo.delete(%User{id: 1}, condition: condition(:expect_exist)) TestRepo.delete(%User{id: 2}, condition: condition(:expect_exist)) TestRepo.delete(%User{id: 3}, condition: condition(:expect_exist)) TestRepo.delete(%User{id: 10}, condition: condition(:expect_exist)) TestRepo.delete(%User{id: 11}, condition: condition(:expect_exist)) end test "repo - at least one attribute column" do u = %User3{id: "1"} assert_raise Ecto.ConstraintError, fn -> TestRepo.insert(u, condition: condition(:expect_not_exist)) end end test "repo - get/one/get_range/batch_get with not matched filter" do input_id = "10001" input_desc = "order_desc" input_num = 1 input_order_name = "order_name" input_success = true input_price = 100.09 order = %Order{ id: input_id, name: input_order_name, desc: input_desc, num: input_num, success?: input_success, price: input_price } {:ok, saved_order} = TestRepo.insert(order, condition: condition(:ignore), return_type: :pk) start_pks = [{"id", input_id}, {"internal_id", :inf_min}] end_pks = [{"id", "100010"}, {"internal_id", :inf_max}] get_result = TestRepo.get(Order, [id: input_id, internal_id: saved_order.internal_id], filter: filter("num" == 1000) ) assert get_result == nil one_result = TestRepo.one(%Order{id: input_id, internal_id: saved_order.internal_id}, filter: filter("num" > 10) ) assert one_result == nil {records, next} = TestRepo.get_range(Order, start_pks, end_pks, filter: filter("num" == 100)) assert records == nil and next == nil requests = [ {Order, [{"id", input_id}, {"internal_id", saved_order.internal_id}], filter: filter("num" == 100)} ] {:ok, [{Order, batch_get_result}]} = TestRepo.batch_get(requests) assert batch_get_result == nil TestRepo.delete(%Order{id: input_id, internal_id: saved_order.internal_id}, condition: condition(:expect_exist) ) end test "repo - insert/batch_write:put with changeset" do id = "1001" changeset = Order.test_changeset(%Order{}, %{id: id, name: "test_name", num: 100}) {:ok, new_order} = TestRepo.insert(changeset, condition: condition(:ignore)) assert new_order.id == id and new_order.name == "test_name" and new_order.num == 100 id2 = "1002" changeset2 = Order.test_changeset(%Order{}, %{id: id2, name: "test_name2", num: 102}) id3 = "1003" changeset3 = Order.test_changeset(%Order{}, %{id: id3, name: "test_name2", num: 102}) writes = [ put: [ {changeset2, condition: condition(:ignore), return_type: :pk}, {changeset3, condition: condition(:ignore)} ] ] {:ok, batch_writes_result} = TestRepo.batch_write(writes) [{Order, [put: result_items]}] = batch_writes_result [{:ok, result1}, {:ok, result2}] = result_items assert result1.internal_id != nil and result1.id == "1002" # since the second item does not require return pk assert result2.internal_id == nil and result2.id == "1003" id4 = "1004" changeset4 = Order.test_changeset(%Order{}, %{id: id4, name: "test_name2"}) {:error, changeset} = TestRepo.insert(changeset4, condition: condition(:ignore)) assert changeset.valid? == false writes = [ put: [ {changeset4, condition: condition(:ignore), return_type: :pk} ] ] assert_raise RuntimeError, ~r/Using invalid changeset/, fn -> TestRepo.batch_write(writes) end start_pks = [{"id", "1001"}, {"internal_id", :inf_min}] end_pks = [{"id", "1003"}, {"internal_id", :inf_max}] {orders, _next} = TestRepo.get_range(Order, start_pks, end_pks) Enum.map(orders, fn order -> TestRepo.delete(order, condition: condition(:expect_exist)) end) end test "repo - check insert stale_error" do user = %User3{id: "check_insert_stale", name: "name"} {:ok, _} = TestRepo.insert(user, condition: condition(:ignore)) stale_error_field = :id stale_error_message = "Row already exists" {:error, invalid_changeset} = TestRepo.insert(user, condition: condition(:expect_not_exist), stale_error_field: stale_error_field, stale_error_message: stale_error_message ) assert {^stale_error_message, [stale: true]} = Keyword.get(invalid_changeset.errors, stale_error_field) end test "repo - check stale_error" do input_id = "10001" input_desc = "order_desc" input_num = 10 increment = 1 input_price = 99.9 order = %Order{id: input_id, desc: input_desc, num: input_num, price: input_price} {:ok, saved_order} = TestRepo.insert(order, condition: condition(:ignore), return_type: :pk) changeset = %Order{internal_id: saved_order.internal_id, id: saved_order.id} |> Ecto.Changeset.change(num: {:increment, increment}, desc: nil) # `stale_error_field` can be any value of atom. stale_error_field = :num stale_error_message = "check num condition failed" {:error, invalid_changeset} = TestRepo.update(changeset, condition: condition(:expect_exist, "num" > 1000), stale_error_field: stale_error_field, stale_error_message: stale_error_message, returning: [:num] ) {^stale_error_message, error} = Keyword.get(invalid_changeset.errors, stale_error_field) assert error == [stale: true] {:ok, _} = TestRepo.delete(saved_order, condition: condition(:expect_exist)) end test "repo - naive_datetime timestamp" do id = Ecto.UUID.generate() {:ok, user} = %User2{id: id} |> TestRepo.insert(condition: condition(:ignore)) assert NaiveDateTime.compare(NaiveDateTime.utc_now(), user.inserted_at) == :gt end test "repo batch write to delete with an array field" do user1 = %User{id: 1, tags: ["1", "2"], name: "name1"} user2 = %User{id: 2, tags: ["a", "b", "c"], name: "name2"} {:ok, _} = TestRepo.batch_write( put: [ {user1, condition: condition(:ignore)}, {user2, condition: condition(:ignore)} ] ) {:ok, _} = TestRepo.batch_write( delete: [ user1, user2 ] ) {:ok, [{User, users}]} = TestRepo.batch_get([ [ %User{id: 1}, %User{id: 2} ] ]) assert users == nil end test "repo batch write to delete with a default value" do user = %User2{id: "1", name: "username0", age: 30} user2 = %User2{id: "2", name: "username2", age: 25} {:ok, _} = TestRepo.batch_write( put: [ {user, condition: condition(:ignore)}, {user2, condition: condition(:ignore)} ] ) {:ok, [{User2, results}]} = TestRepo.batch_write( delete: [ {%User2{id: "1", age: 30}, condition: condition(:expect_exist, "name" == "username0")} ] ) [{:ok, deleted_user2}] = results[:delete] assert deleted_user2.id == "1" {:ok, [{User2, results}]} = TestRepo.batch_write( delete: [ {%User2{id: "2", age: 0}, condition: condition(:expect_exist, "name" == "username2" and "age" == 25)} ] ) [{:ok, deleted_user2}] = results[:delete] assert deleted_user2.id == "2" end test "optimistic_lock/3" do order = TestRepo.insert!(%Order{id: "1001", name: "name1"}, condition: condition(:ignore), return_type: :pk ) valid_change = Order.changeset(:update, order, %{name: "bar"}) stale_change = Order.changeset(:update, order, %{name: "baz"}) {:ok, order} = TestRepo.update(valid_change, condition: condition(:ignore)) assert order.name == "bar" and order.lock_version == 2 assert_raise Ecto.StaleEntryError, fn -> TestRepo.update(stale_change, condition: condition(:ignore)) end # since we don't explicitly fetch the "lock_version" field in query, fetched_order = TestRepo.get(Order, [id: order.id, internal_id: order.internal_id], columns_to_get: ["name"]) # the returned dataset of order struct will use the default value of "lock_version" as 1 assert fetched_order.lock_version == 1 # and this case will make the next update fail when we use `Ecto.Changeset.optimistic_lock/3` in the changeset # once we use the optimistic_lock, please remember append the fresh "version" field in the update operation for # the condition check. stale_change = Order.changeset(:update, fetched_order, %{name: "foo"}) assert_raise Ecto.StaleEntryError, fn -> TestRepo.update(stale_change, condition: condition(:ignore)) end # compare a success case to the previous stale error fetched_order = TestRepo.get(Order, [id: order.id, internal_id: order.internal_id], columns_to_get: ["name", "lock_version"] ) assert fetched_order.lock_version == 2 valid_change = Order.changeset(:update, fetched_order, %{name: "foo"}) {:ok, order} = TestRepo.update(valid_change, condition: condition(:expect_exist, "name" == "bar")) assert order.name == "foo" and order.lock_version == 3 end end
32.541632
198
0.636663
73f55a5310b4d12aa4856f07bac7603fe663d38a
473
ex
Elixir
lib/toki/parser.ex
tommy351/toki
099591c6ab5dcbad91c4c45ff87ab7e6d05959bc
[ "MIT" ]
3
2016-07-19T03:23:33.000Z
2016-09-15T11:57:37.000Z
lib/toki/parser.ex
tommy351/toki
099591c6ab5dcbad91c4c45ff87ab7e6d05959bc
[ "MIT" ]
null
null
null
lib/toki/parser.ex
tommy351/toki
099591c6ab5dcbad91c4c45ff87ab7e6d05959bc
[ "MIT" ]
null
null
null
defmodule Toki.Parser do use Toki.Unit.Year, :parse use Toki.Unit.Month, :parse use Toki.Unit.Day, :parse use Toki.Unit.Hour, :parse use Toki.Unit.Minute, :parse use Toki.Unit.Second, :parse @spec parse(String.t, String.t) :: Toki.DateTime.t def parse(value, pattern) do Toki.Pattern.compile(pattern) |> Regex.named_captures(value) |> Map.to_list |> do_parse(%Toki.DateTime{}) end defp do_parse([], date) do date end end
22.52381
52
0.661734
73f57e2e675b4beb9759acf58a63fc12aaeb407a
2,996
ex
Elixir
lib/tty2048/grid.ex
lexmag/tty2048
f800247354593929b653f9f947a7c6f1844ad9fe
[ "0BSD" ]
171
2015-01-05T16:25:57.000Z
2022-01-14T03:05:51.000Z
lib/tty2048/grid.ex
lexmag/tty2048
f800247354593929b653f9f947a7c6f1844ad9fe
[ "0BSD" ]
1
2016-06-16T11:53:27.000Z
2016-06-16T11:53:27.000Z
lib/tty2048/grid.ex
lexmag/tty2048
f800247354593929b653f9f947a7c6f1844ad9fe
[ "0BSD" ]
29
2015-04-30T15:02:54.000Z
2021-03-04T18:48:42.000Z
defmodule Tty2048.Grid do @sides [:up, :down, :right, :left] def new(size) when size > 0 do make_grid(size) |> seed |> seed end def move(grid, side) when is_list(grid) and side in @sides do case try_move(grid, side) do :noop -> {grid, 0} {:ok, grid, points} -> {seed(grid), points} end end def has_move?(grid) do Enum.any?(@sides, &(try_move(grid, &1) != :noop)) end defp try_move(grid, side) do case do_move(grid, side) do {^grid, _} -> :noop {grid, points} -> {:ok, grid, points} end end defp do_move(grid, :left) do collapse(grid) |> compose(&Enum.reverse(&1, &2)) end defp do_move(grid, :right) do Enum.map(grid, &Enum.reverse/1) |> collapse |> compose(&(&2 ++ &1)) end defp do_move(grid, :up) do transpose(grid) |> do_move(:left) |> transpose end defp do_move(grid, :down) do transpose(grid) |> do_move(:right) |> transpose end defp make_grid(size) do for _ <- 1..size, do: make_row(size) end defp make_row(size) do for _ <- 1..size, do: 0 end defp compose(chunks, fun) do Enum.map_reduce chunks, 0, fn {acc, tail, points}, sum -> {fun.(acc, tail), sum + points} end end defp transpose({grid, points}), do: {transpose(grid), points} defp transpose(grid, acc \\ []) defp transpose([[] | _], acc), do: Enum.reverse(acc) defp transpose(grid, acc) do {tail, row} = Enum.map_reduce(grid, [], fn [el | rest], row -> {rest, [el | row]} end) transpose(tail, [Enum.reverse(row) | acc]) end defp collapse(grid) do Stream.map(grid, &collapse(&1, [], [])) end defp collapse([], acc, tail) do Enum.reverse(acc) |> merge([], tail, 0) end defp collapse([0 | rest], acc, tail) do collapse(rest, acc, [0 | tail]) end defp collapse([el | rest], acc, tail) do collapse(rest, [el | acc], tail) end defp merge([], acc, tail, points), do: {acc, tail, points} defp merge([el, el | rest], acc, tail, points) do sum = el + el merge(rest, [sum | acc], [0 | tail], points + sum) end defp merge([el | rest], acc, tail, points) do merge(rest, [el | acc], tail, points) end defp seed(grid) do seed(if(:random.uniform < 0.9, do: 2, else: 4), grid) end defp seed(num, grid) do take_empties(grid) |> sample |> insert_at(num, grid) end defp sample({count, empties}) do Enum.at(empties, :random.uniform(count) - 1) end defp insert_at({row_index, index}, num, grid) do List.update_at(grid, row_index, &List.replace_at(&1, index, num)) end defp take_empties(grid) do Stream.with_index(grid) |> Enum.reduce({0, []}, &take_empties/2) end defp take_empties({row, row_index}, acc) do Stream.with_index(row) |> Enum.reduce(acc, fn {0, index}, {count, empties} -> {count + 1, [{row_index, index} | empties]} _cell, acc -> acc end) end end
20.662069
69
0.579105
73f5aedf98b9d484e5c3dfb37e545ad59bd67258
1,848
ex
Elixir
lib/auth0_ex/authentication/login.ex
warmwaffles/auth0_ex
d0d7ad895c4db79d366c9c55e289a944c891936c
[ "Apache-2.0" ]
38
2016-08-31T12:44:19.000Z
2021-06-17T18:23:21.000Z
lib/auth0_ex/authentication/login.ex
warmwaffles/auth0_ex
d0d7ad895c4db79d366c9c55e289a944c891936c
[ "Apache-2.0" ]
24
2017-01-12T17:53:10.000Z
2022-03-14T13:43:12.000Z
lib/auth0_ex/authentication/login.ex
warmwaffles/auth0_ex
d0d7ad895c4db79d366c9c55e289a944c891936c
[ "Apache-2.0" ]
24
2017-01-27T20:51:57.000Z
2022-03-11T19:58:40.000Z
defmodule Auth0Ex.Authentication.Login do @moduledoc """ A module that handles login stuff for authentication API """ use Auth0Ex.Api @doc """ Given the social provider's access_token and the connection, this endpoint will authenticate the user with the provider and return a JSON with the `access_token` and, optionally, an `id_token`. This endpoint only works for Facebook, Google, Twitter and Weibo. iex> Auth0Ex.Authentication.Login.social("client_id", "access_token", "facebook") iex> Auth0Ex.Authentication.Login.social("client_id", "access_token", "facebook", "openid profile email") """ def social(client_id, access_token, connection, scope \\ "openid") do payload = %{ client_id: client_id, access_token: access_token, connection: connection, scope: scope } do_post("oauth/access_token", payload) end @doc """ Given the user credentials and the connection specified, it will do the authentication on the provider and return a JSON with the `access_token` and `id_token`. You can pass optional parameters as a map in the last `params` argument. An example params map would be: %{scope: "openid app_metadata"} %{device: "ios", id_token: "id_token_touchid"} iex> Auth0Ex.Authentication.Login.database("client_id", "samar", "samarpwd", "dev", "password") iex> Auth0Ex.Authentication.Login.database("client_id", "samar", "samarpwd", "dev", "password", %{scope: "openid app_metadata"}) """ def database(client_id, username, password, connection, grant_type, params \\ %{}) when is_map(params) do payload = %{ client_id: client_id, username: username, password: password, connection: connection, grant_type: grant_type } do_post("oauth/ro", Map.merge(payload, params)) end end
33.6
134
0.694805
73f5b9764322da1cabae32c60ae186daa1d50ff1
257
exs
Elixir
config/test.exs
embik/blog
ee8e604fe0bba0bade5466cc180475dbe80bb6b6
[ "Apache-2.0" ]
6
2017-04-17T22:19:53.000Z
2019-05-14T09:49:22.000Z
blog/config/test.exs
xymbol/otp-examples
daa9bc1392d4324d2aa9f37657b205f9b1dfa447
[ "MIT" ]
1
2017-08-14T09:00:30.000Z
2017-08-14T16:18:44.000Z
blog/config/test.exs
xymbol/otp-examples
daa9bc1392d4324d2aa9f37657b205f9b1dfa447
[ "MIT" ]
null
null
null
use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :blog, Blog.Endpoint, http: [port: 4001], server: false # Print only warnings and errors during test config :logger, level: :warn
23.363636
56
0.727626
73f5c6f2c9c8ee96c8898203784fa292497ea292
1,698
exs
Elixir
mix.exs
tinenbruno/verk_web
70911a77ba12efcafca495bb43e3074c6cad3cfb
[ "MIT" ]
null
null
null
mix.exs
tinenbruno/verk_web
70911a77ba12efcafca495bb43e3074c6cad3cfb
[ "MIT" ]
null
null
null
mix.exs
tinenbruno/verk_web
70911a77ba12efcafca495bb43e3074c6cad3cfb
[ "MIT" ]
null
null
null
defmodule VerkWeb.Mixfile do use Mix.Project @description """ A Verk dashboard """ def project do [app: :verk_web, version: "1.4.0", elixir: "~> 1.3", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, test_coverage: [tool: Coverex.Task, coveralls: true], name: "Verk Web", description: @description, package: package(), deps: deps()] end @default_config [http: [port: 4000], server: false, pubsub: [name: VerkWeb.PubSub, adapter: Phoenix.PubSub.PG2]] def application do [mod: {VerkWeb, []}, env: [{VerkWeb.Endpoint, @default_config}], applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext, :verk, :timex, :basic_auth]] end defp elixirc_paths(:test), do: ["lib", "web", "test/support"] defp elixirc_paths(_), do: ["lib", "web"] defp deps do [{:phoenix, "~> 1.3.0"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_html, "~> 2.6"}, {:gettext, "~> 0.9"}, {:verk, "~> 1.1"}, {:cowboy, "~> 1.0"}, {:basic_auth, "~> 2.0"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:earmark, "~> 1.0", only: :dev}, {:ex_doc, "~> 0.13", only: :dev}, {:coverex, "~> 1.4", only: :test}, {:meck, "~> 0.8", only: :test}, {:timex, "~> 3.1.0"}] end defp package do [maintainers: ["Eduardo Gurgel Pinho", "Alisson Sales"], licenses: ["MIT"], links: %{"Github" => "https://github.com/edgurgel/verk_web"}, files: ["lib", "web", "priv", "mix.exs", "README*", "LICENSE*"]] end end
29.275862
118
0.556537
73f5e288ed5ed0ee725b36dc30187122c8efcaf3
10,620
ex
Elixir
lib/iex/lib/iex/evaluator.ex
flash4syth/elixir
466bfc79fbad69eb6c9e4e3f19c262cdd93d7817
[ "Apache-2.0" ]
null
null
null
lib/iex/lib/iex/evaluator.ex
flash4syth/elixir
466bfc79fbad69eb6c9e4e3f19c262cdd93d7817
[ "Apache-2.0" ]
1
2020-09-14T16:23:33.000Z
2021-03-25T17:38:59.000Z
lib/iex/lib/iex/evaluator.ex
flash4syth/elixir
466bfc79fbad69eb6c9e4e3f19c262cdd93d7817
[ "Apache-2.0" ]
null
null
null
defmodule IEx.Evaluator do @moduledoc false @doc """ Eval loop for an IEx session. Its responsibilities include: * loading of .iex files * evaluating code * trapping exceptions in the code being evaluated * keeping expression history """ def init(command, server, leader, opts) do ref = make_ref() old_leader = Process.group_leader() Process.group_leader(self(), leader) old_server = Process.get(:iex_server) Process.put(:iex_server, server) old_evaluator = Process.get(:iex_evaluator) Process.put(:iex_evaluator, ref) if old_evaluator do send(self(), {:done, old_evaluator}) end state = loop_state(ref, server, IEx.History.init(), opts) command == :ack && :proc_lib.init_ack(self()) try do loop(state) after Process.group_leader(self(), old_leader) if old_server do Process.put(:iex_server, old_server) else Process.delete(:iex_server) end if old_evaluator do Process.put(:iex_evaluator, old_evaluator) else Process.delete(:iex_evaluator) end :ok end end @doc """ Gets a value out of the binding, using the provided variable name and map key path. """ @spec value_from_binding(pid, pid, atom, [atom]) :: {:ok, any} | :error def value_from_binding(evaluator, server, var_name, map_key_path) do ref = make_ref() send(evaluator, {:value_from_binding, server, ref, self(), var_name, map_key_path}) receive do {^ref, result} -> result after 5000 -> :error end end @doc """ Gets a list of variables out of the binding that match the passed variable prefix. """ @spec variables_from_binding(pid, pid, String.t()) :: [String.t()] def variables_from_binding(evaluator, server, variable_prefix) do ref = make_ref() send(evaluator, {:variables_from_binding, server, ref, self(), variable_prefix}) receive do {^ref, result} -> result after 5000 -> [] end end @doc """ Returns the named fields from the current session environment. """ @spec fields_from_env(pid, pid, [atom]) :: %{optional(atom) => term} def fields_from_env(evaluator, server, fields) do ref = make_ref() send(evaluator, {:fields_from_env, server, ref, self(), fields}) receive do {^ref, result} -> result after 5000 -> %{} end end defp loop(%{server: server, ref: ref} = state) do receive do {:eval, ^server, code, iex_state} -> {result, state} = eval(code, iex_state, state) send(server, {:evaled, self(), result}) loop(state) {:fields_from_env, ^server, ref, receiver, fields} -> send(receiver, {ref, Map.take(state.env, fields)}) loop(state) {:value_from_binding, ^server, ref, receiver, var_name, map_key_path} -> value = traverse_binding(state.binding, var_name, map_key_path) send(receiver, {ref, value}) loop(state) {:variables_from_binding, ^server, ref, receiver, var_prefix} -> value = find_matched_variables(state.binding, var_prefix) send(receiver, {ref, value}) loop(state) {:done, ^server} -> :ok {:done, ^ref} -> :ok end end defp traverse_binding(binding, var_name, map_key_path) do accumulator = Keyword.fetch(binding, var_name) Enum.reduce(map_key_path, accumulator, fn key, {:ok, map} when is_map(map) -> Map.fetch(map, key) _key, _acc -> :error end) end defp find_matched_variables(binding, var_prefix) do for {var_name, _value} <- binding, is_atom(var_name), var_name = Atom.to_string(var_name), String.starts_with?(var_name, var_prefix), do: var_name end defp loop_state(ref, server, history, opts) do env = opts[:env] || :elixir.env_for_eval(file: "iex") env = %{env | prematch_vars: :apply} {_, _, env} = :elixir.eval_quoted(quote(do: import(IEx.Helpers)), [], env) stacktrace = opts[:stacktrace] binding = opts[:binding] || [] state = %{ binding: binding, env: env, server: server, history: history, stacktrace: stacktrace, ref: ref } case opts[:dot_iex_path] do "" -> state path -> load_dot_iex(state, path) end end defp load_dot_iex(state, path) do candidates = if path do [path] else Enum.map([".iex.exs", "~/.iex.exs"], &Path.expand/1) end path = Enum.find(candidates, &File.regular?/1) if is_nil(path) do state else eval_dot_iex(state, path) end end defp eval_dot_iex(state, path) do try do code = File.read!(path) quoted = :elixir.string_to_quoted!(String.to_charlist(code), 1, 1, path, []) # Evaluate the contents in the same environment server_loop will run in env = :elixir.env_for_eval(state.env, file: path, line: 1) Process.put(:iex_imported_paths, MapSet.new([path])) {_result, binding, env} = :elixir.eval_forms(quoted, state.binding, env) %{state | binding: binding, env: :elixir.env_for_eval(env, file: "iex", line: 1)} catch kind, error -> io_result("Error while evaluating: #{path}") print_error(kind, error, __STACKTRACE__) state after Process.delete(:iex_imported_paths) end end # Instead of doing just :elixir.eval, we first parse the expression to see # if it's well formed. If parsing succeeds, we evaluate the AST as usual. # # If parsing fails, this might be a TokenMissingError which we treat in # a special way (to allow for continuation of an expression on the next # line in IEx). # # Returns updated state. # # The first two clauses provide support for the break-trigger allowing to # break out from a pending incomplete expression. See # https://github.com/elixir-lang/elixir/issues/1089 for discussion. @break_trigger '#iex:break\n' defp eval(code, iex_state, state) do try do do_eval(String.to_charlist(code), iex_state, state) catch kind, error -> print_error(kind, error, __STACKTRACE__) {%{iex_state | cache: ''}, state} end end defp do_eval(@break_trigger, %IEx.State{cache: ''} = iex_state, state) do {iex_state, state} end defp do_eval(@break_trigger, iex_state, _state) do :elixir_errors.parse_error([line: iex_state.counter], "iex", "incomplete expression", "") end defp do_eval(latest_input, iex_state, state) do code = iex_state.cache ++ latest_input line = iex_state.counter put_history(state) put_whereami(state) quoted = Code.string_to_quoted(code, line: line, file: "iex") handle_eval(quoted, code, line, iex_state, state) after Process.delete(:iex_history) Process.delete(:iex_whereami) end defp put_history(%{history: history}) do Process.put(:iex_history, history) end defp put_whereami(%{env: %{file: "iex"}}) do :ok end defp put_whereami(%{env: %{file: file, line: line}, stacktrace: stacktrace}) do Process.put(:iex_whereami, {file, line, stacktrace}) end defp handle_eval({:ok, forms}, code, line, iex_state, state) do {result, binding, env} = :elixir.eval_forms(forms, state.binding, state.env) unless result == IEx.dont_display_result() do io_inspect(result) end iex_state = %{iex_state | cache: '', counter: iex_state.counter + 1} state = %{state | env: env, binding: binding} {iex_state, update_history(state, line, code, result)} end defp handle_eval({:error, {_, _, ""}}, code, _line, iex_state, state) do # Update iex_state.cache so that IEx continues to add new input to # the unfinished expression in "code" {%{iex_state | cache: code}, state} end defp handle_eval({:error, {location, error, token}}, _code, _line, _iex_state, _state) do # Encountered malformed expression :elixir_errors.parse_error(location, "iex", error, token) end defp update_history(state, counter, _cache, result) do history_size = IEx.Config.history_size() update_in(state.history, &IEx.History.append(&1, {counter, result}, history_size)) end defp io_inspect(result) do io_result(inspect(result, IEx.inspect_opts())) end defp io_result(result) do IO.puts(:stdio, IEx.color(:eval_result, result)) end ## Error handling defp print_error(kind, reason, stacktrace) do {blamed, stacktrace} = Exception.blame(kind, reason, stacktrace) ansidata = case blamed do %FunctionClauseError{} -> {_, inspect_opts} = pop_in(IEx.inspect_opts()[:syntax_colors][:reset]) banner = Exception.format_banner(kind, reason, stacktrace) blame = FunctionClauseError.blame(blamed, &inspect(&1, inspect_opts), &blame_match/2) [IEx.color(:eval_error, banner), pad(blame)] _ -> [IEx.color(:eval_error, Exception.format_banner(kind, blamed, stacktrace))] end stackdata = Exception.format_stacktrace(prune_stacktrace(stacktrace)) IO.write(:stdio, [ansidata, ?\n, IEx.color(:stack_info, stackdata)]) end defp pad(string) do " " <> String.replace(string, "\n", "\n ") end defp blame_match(%{match?: true, node: node}, _), do: Macro.to_string(node) defp blame_match(%{match?: false, node: node}, _), do: blame_ansi(:blame_diff, "-", node) defp blame_match(_, string), do: string defp blame_ansi(color, no_ansi, node) do case IEx.Config.color(color) do nil -> no_ansi <> Macro.to_string(node) <> no_ansi ansi -> [ansi | Macro.to_string(node)] |> IO.ANSI.format(true) |> IO.iodata_to_binary() end end @elixir_internals [:elixir, :elixir_expand, :elixir_compiler, :elixir_module] ++ [:elixir_clauses, :elixir_lexical, :elixir_def, :elixir_map] ++ [:elixir_erl, :elixir_erl_clauses, :elixir_erl_pass] defp prune_stacktrace(stacktrace) do # The order in which each drop_while is listed is important. # For example, the user may call Code.eval_string/2 in IEx # and if there is an error we should not remove erl_eval # and eval_bits information from the user stacktrace. stacktrace |> Enum.reverse() |> Enum.drop_while(&(elem(&1, 0) == :proc_lib)) |> Enum.drop_while(&(elem(&1, 0) == __MODULE__)) |> Enum.drop_while(&(elem(&1, 0) == :elixir)) |> Enum.drop_while(&(elem(&1, 0) in [:erl_eval, :eval_bits])) |> Enum.reverse() |> Enum.reject(&(elem(&1, 0) in @elixir_internals)) end end
29.831461
95
0.645292
73f5e9af6f1e6657f67929e4cd782db523ad2f48
2,723
ex
Elixir
examples/grpc/elixir/car5g/lib/generated_proto_files/common.pb.ex
niclaslind/signalbroker-server
afb80514dcbabe561ac2da42adc08843a15c37c5
[ "Apache-2.0" ]
17
2020-06-20T11:29:43.000Z
2022-03-21T05:53:06.000Z
examples/grpc/elixir/car5g/lib/generated_proto_files/common.pb.ex
niclaslind/signalbroker-server
afb80514dcbabe561ac2da42adc08843a15c37c5
[ "Apache-2.0" ]
2
2020-07-09T10:22:50.000Z
2020-09-01T14:46:40.000Z
examples/grpc/elixir/car5g/lib/generated_proto_files/common.pb.ex
niclaslind/signalbroker-server
afb80514dcbabe561ac2da42adc08843a15c37c5
[ "Apache-2.0" ]
3
2020-07-17T20:04:36.000Z
2022-01-24T14:19:46.000Z
defmodule Base.Empty do @moduledoc false use Protobuf, syntax: :proto3 defstruct [] end defmodule Base.ClientId do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ id: String.t } defstruct [:id] field :id, 1, type: :string end defmodule Base.SignalId do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ name: String.t, namespace: Base.NameSpace.t } defstruct [:name, :namespace] field :name, 1, type: :string field :namespace, 2, type: Base.NameSpace end defmodule Base.SignalInfo do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ id: Base.SignalId.t, metaData: Base.MetaData.t } defstruct [:id, :metaData] field :id, 1, type: Base.SignalId field :metaData, 2, type: Base.MetaData end defmodule Base.MetaData do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ description: String.t, max: integer, min: integer, unit: String.t, size: integer, isRaw: boolean } defstruct [:description, :max, :min, :unit, :size, :isRaw] field :description, 4, type: :string field :max, 5, type: :int32 field :min, 6, type: :int32 field :unit, 7, type: :string field :size, 8, type: :int32 field :isRaw, 9, type: :bool end defmodule Base.NameSpace do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ name: String.t } defstruct [:name] field :name, 1, type: :string end defmodule Base.Configuration do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ networkInfo: [Base.NetworkInfo.t] } defstruct [:networkInfo] field :networkInfo, 1, repeated: true, type: Base.NetworkInfo end defmodule Base.NetworkInfo do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ namespace: Base.NameSpace.t, type: String.t, description: String.t } defstruct [:namespace, :type, :description] field :namespace, 1, type: Base.NameSpace field :type, 2, type: :string field :description, 3, type: :string end defmodule Base.FrameInfo do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ signalInfo: Base.SignalInfo.t, childInfo: [Base.SignalInfo.t] } defstruct [:signalInfo, :childInfo] field :signalInfo, 1, type: Base.SignalInfo field :childInfo, 2, repeated: true, type: Base.SignalInfo end defmodule Base.Frames do @moduledoc false use Protobuf, syntax: :proto3 @type t :: %__MODULE__{ frame: [Base.FrameInfo.t] } defstruct [:frame] field :frame, 1, repeated: true, type: Base.FrameInfo end
19.875912
63
0.661036
73f647f1923c98142ac12cf56007f8bd21366f8a
1,269
exs
Elixir
config/prod.secret.exs
mCodex/rocketseat-ignite-rockelivery
8592c95962acd6578f28583307df2ea4464d4750
[ "MIT" ]
1
2021-09-27T06:15:08.000Z
2021-09-27T06:15:08.000Z
config/prod.secret.exs
mCodex/rocketseat-ignite-rockelivery
8592c95962acd6578f28583307df2ea4464d4750
[ "MIT" ]
null
null
null
config/prod.secret.exs
mCodex/rocketseat-ignite-rockelivery
8592c95962acd6578f28583307df2ea4464d4750
[ "MIT" ]
1
2021-12-21T12:47:59.000Z
2021-12-21T12:47:59.000Z
# In this file, we load production configuration and secrets # from environment variables. You can also hardcode secrets, # although such is generally not recommended and you have to # remember to add this file to your .gitignore. use Mix.Config database_url = System.get_env("DATABASE_URL") || raise """ environment variable DATABASE_URL is missing. For example: ecto://USER:PASS@HOST/DATABASE """ config :rockelivery, Rockelivery.Repo, # ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10") secret_key_base = System.get_env("SECRET_KEY_BASE") || raise """ environment variable SECRET_KEY_BASE is missing. You can generate one by calling: mix phx.gen.secret """ config :rockelivery, RockeliveryWeb.Endpoint, http: [ port: String.to_integer(System.get_env("PORT") || "4000"), transport_options: [socket_opts: [:inet6]] ], secret_key_base: secret_key_base # ## Using releases (Elixir v1.9+) # # If you are doing OTP releases, you need to instruct Phoenix # to start each relevant endpoint: # # config :rockelivery, RockeliveryWeb.Endpoint, server: true # # Then you can assemble a release by calling `mix release`. # See `mix help release` for more information.
30.214286
67
0.724192
73f6a1d848b6325db205e613669063f6a2c45956
2,012
exs
Elixir
config/prod.exs
brunodantas/wabanex
4d8e4258969203cf0adf5b6561fbd862085afed7
[ "MIT" ]
61
2021-06-22T00:15:59.000Z
2022-01-31T15:13:51.000Z
config/prod.exs
brunodantas/wabanex
4d8e4258969203cf0adf5b6561fbd862085afed7
[ "MIT" ]
1
2021-06-21T18:42:41.000Z
2021-06-21T18:42:41.000Z
config/prod.exs
brunodantas/wabanex
4d8e4258969203cf0adf5b6561fbd862085afed7
[ "MIT" ]
56
2021-06-21T17:17:36.000Z
2022-03-15T02:48:59.000Z
use Mix.Config # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. # # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. config :wabanex, WabanexWeb.Endpoint, url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production config :logger, level: :info # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :wabanex, WabanexWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [ # port: 443, # cipher_suite: :strong, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH"), # transport_options: [socket_opts: [:inet6]] # ] # # The `cipher_suite` is set to `:strong` to support only the # latest and more secure SSL ciphers. This means old browsers # and clients may not be supported. You can set it to # `:compatible` for wider support. # # `:keyfile` and `:certfile` expect an absolute path to the key # and cert in disk or a relative path inside priv, for example # "priv/ssl/server.key". For all supported SSL configuration # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 # # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # # config :wabanex, WabanexWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # Finally import the config/prod.secret.exs which loads secrets # and configuration from environment variables. import_config "prod.secret.exs"
35.928571
66
0.714712
73f6c5736966d3a40e5cd0091870e4a27fc4fd1f
3,213
ex
Elixir
lib/versioned/migration.ex
rossvz/versioned
22fd40ce7833d0ede80ac9c3dd2e2b8482b50322
[ "MIT" ]
null
null
null
lib/versioned/migration.ex
rossvz/versioned
22fd40ce7833d0ede80ac9c3dd2e2b8482b50322
[ "MIT" ]
null
null
null
lib/versioned/migration.ex
rossvz/versioned
22fd40ce7833d0ede80ac9c3dd2e2b8482b50322
[ "MIT" ]
null
null
null
defmodule Versioned.Migration do @moduledoc """ Allows creating tables for versioned schemas. ## Example defmodule MyApp.Repo.Migrations.CreateCar do use Versioned.Migration def change do create_versioned_table(:cars) do add :name, :string end end end """ alias Versioned.Helpers defmacro __using__(_) do quote do use Ecto.Migration import unquote(__MODULE__) end end @doc """ Create a table whose data is versioned by also creating a secondary table with the immutable, append-only history. """ defmacro create_versioned_table(name_plural, opts \\ [], do: block) do name_singular = Keyword.get(opts, :singular, String.trim_trailing("#{name_plural}", "s")) {:__block__, mid, lines} = Helpers.normalize_block(block) # For versions table, rewrite references to avoid database constraints: # If a record is deleted, we don't want version records with its foreign # key to be affected. versions_block = lines |> Enum.reduce([], &do_version_line/2) |> Enum.reverse() |> (fn lines -> {:__block__, mid, lines} end).() quote do create table(unquote(name_plural), primary_key: false) do add(:id, :uuid, primary_key: true) timestamps(type: :utc_datetime_usec) unquote(block) end create table(:"#{unquote(name_plural)}_versions", primary_key: false) do add(:id, :uuid, primary_key: true) add(:is_deleted, :boolean, null: false) add(:"#{unquote(name_singular)}_id", :uuid, null: false) timestamps(type: :utc_datetime_usec, updated_at: false) unquote(versions_block) end create(index(:"#{unquote(name_plural)}_versions", :"#{unquote(name_singular)}_id")) end end # Take the original migration ast and attach to the accumulator the # corresponding ast to use for the version table. @spec do_version_line(Macro.t(), Macro.t()) :: Macro.t() defp do_version_line({:add, a, [b, {:references, _, _} = tup]}, acc) do do_version_line({:add, a, [b, tup, []]}, acc) end defp do_version_line( {:add, m, [foreign_key, {:references, _m2, [_plural, ref_opts]}, field_opts]}, acc ) do # Drop reference in favor if plain ole field of the same type. # This way, referenced records can be deleted while the referencing version # records remain intact. type = Keyword.get(ref_opts, :type, :uuid) line = {:add, m, [foreign_key, type, field_opts]} [line | acc] end defp do_version_line(line, acc) do [line | acc] end @doc "Add a new column to both the main table and the versions table." defmacro add_versioned_column(table_name, name, type, opts \\ []) do {singular, opts} = Keyword.pop(opts, :singular, to_string(table_name)) quote bind_quoted: [ table_name: table_name, name: name, opts: opts, type: type, singular: singular ] do alter table(table_name) do add(name, type, opts) end alter table(:"#{singular}_versions") do add(name, type, opts) end end end end
30.028037
93
0.633053
73f6cd351637d7a1ede445c1e5edda84de68056f
563
exs
Elixir
test/easypost/response_test.exs
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
6
2017-09-21T13:19:56.000Z
2021-01-07T18:31:42.000Z
test/easypost/response_test.exs
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
null
null
null
test/easypost/response_test.exs
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
2
2018-07-11T07:12:08.000Z
2020-06-29T02:04:48.000Z
defmodule EasyPost.ResponseTest do use ExUnit.Case, async: true alias EasyPost.{ Config, Response } test "new/2" do body = "{ \"ok\": true }" headers = [{ "some-header", "some-header-value" }] status_code = 200 expected = %Response{} expected = Map.put(expected, :body, %{ "ok" => true }) expected = Map.put(expected, :headers, headers) expected = Map.put(expected, :status_code, status_code) assert ^expected = EasyPost.Response.new(%{ body: body, headers: headers, status_code: status_code }, Config.new()) end end
26.809524
119
0.650089
73f710566b9751782d990f7ce0415642ad1f3afa
791
ex
Elixir
lib/flop/custom_types/operator.ex
tedgkassen/flop
7268b14b8eff4e4ca93f9541382e46f8d249f2ec
[ "MIT" ]
null
null
null
lib/flop/custom_types/operator.ex
tedgkassen/flop
7268b14b8eff4e4ca93f9541382e46f8d249f2ec
[ "MIT" ]
null
null
null
lib/flop/custom_types/operator.ex
tedgkassen/flop
7268b14b8eff4e4ca93f9541382e46f8d249f2ec
[ "MIT" ]
null
null
null
defmodule Flop.CustomTypes.Operator do @moduledoc false use Ecto.Type def type, do: :string @allowed_operators [:==, :!=, :=~, :<=, :<, :>=, :>, :in] @allowed_operators_str Enum.map(@allowed_operators, &to_string/1) def cast(operator) when operator in @allowed_operators_str do {:ok, String.to_existing_atom(operator)} end def cast(operator) when operator in @allowed_operators do {:ok, operator} end def cast(_), do: :error def load(operator) when is_binary(operator) do {:ok, String.to_existing_atom(operator)} end def dump(operator) when is_atom(operator), do: {:ok, to_string(operator)} def dump(operator) when is_binary(operator), do: {:ok, operator} def dump(_), do: :error @doc false def __operators__, do: @allowed_operators end
25.516129
75
0.692794
73f73a44b3c2c0ac533ba68565fec9c0787d61d6
595
ex
Elixir
elixir/lib/com/spoonacular/client/model/inline_response_200_28_servings.ex
ddsky/spoonacular-api-clients
63f955ceb2c356fefdd48ec634deb3c3e16a6ae7
[ "MIT" ]
21
2019-08-09T18:53:26.000Z
2022-03-14T22:10:10.000Z
elixir/lib/com/spoonacular/client/model/inline_response_200_28_servings.ex
ddsky/spoonacular-api-clients
63f955ceb2c356fefdd48ec634deb3c3e16a6ae7
[ "MIT" ]
null
null
null
elixir/lib/com/spoonacular/client/model/inline_response_200_28_servings.ex
ddsky/spoonacular-api-clients
63f955ceb2c356fefdd48ec634deb3c3e16a6ae7
[ "MIT" ]
55
2019-08-13T17:52:47.000Z
2022-03-27T04:29:34.000Z
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # https://openapi-generator.tech # Do not edit the class manually. defmodule com.spoonacular.client.Model.InlineResponse20028Servings do @moduledoc """ """ @derive [Poison.Encoder] defstruct [ :"number", :"size", :"unit" ] @type t :: %__MODULE__{ :"number" => float(), :"size" => float(), :"unit" => String.t } end defimpl Poison.Decoder, for: com.spoonacular.client.Model.InlineResponse20028Servings do def decode(value, _options) do value end end
19.833333
91
0.665546
73f7a971f9698f0c932eca3f78d4d733e40f5def
1,888
exs
Elixir
clients/memcache/mix.exs
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/memcache/mix.exs
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/memcache/mix.exs
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # 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. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Memcache.Mixfile do use Mix.Project @version "0.8.2" def project() do [ app: :google_api_memcache, version: @version, elixir: "~> 1.6", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/googleapis/elixir-google-api/tree/master/clients/memcache" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:google_gax, "~> 0.4"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Cloud Memorystore for Memcached API client library. Google Cloud Memorystore for Memcached API is used for creating and managing Memcached instances in GCP. """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching", "Daniel Azuma"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/googleapis/elixir-google-api/tree/master/clients/memcache", "Homepage" => "https://cloud.google.com/memorystore/" } ] end end
28.179104
160
0.660487